From patchwork Sat Apr 20 00:02:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 1925775 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=sUXvI2Jm; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLsDy6Sm2z1yZP for ; Sat, 20 Apr 2024 10:04:02 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE4F3885D7; Sat, 20 Apr 2024 02:03:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org 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=jookia.org header.i=@jookia.org header.b="sUXvI2Jm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1BE5885D7; Sat, 20 Apr 2024 02:03:47 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from out-175.mta1.migadu.com (out-175.mta1.migadu.com [IPv6:2001:41d0:203:375::af]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D98ED88634 for ; Sat, 20 Apr 2024 02:03:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=contact@jookia.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1713571423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZMzPyHXbOQWPIO3wvZEVMLraltX+9cKUlUqGJ6gLShs=; b=sUXvI2Jm835LJGx4Y2xKbEuuBY06xX67INHrZst8KeF+aS9jtVjRZrRDbnmh1iS6U8d1/P tk2CIOVQZalFO7RSMycI8qrJUQqK68x0mCQuGfrsQXQpmiHKlLcGunlfw6N1ljxb3qxlpN UgzwO7/4LZ4WZ1imwMT2jcE3rOfHa1A3A832x318ncKsbuuGe/w3EyGvClxT8/qBYOiVZo I84QtDujy7D1KK5ync8+dgOG1nV1F8PAyNgUzVrZBrausbds+aNDYsfrPcaLUovGbkgKaR rrgYF3mZnAZQe7lUueinolqx1iBpzP0owehwRJPKw4Nsr0rQCfG1C/oTbf80Xg== From: John Watts Date: Sat, 20 Apr 2024 10:02:34 +1000 Subject: [PATCH RFC 1/9] sunxi: clock: support H6/D1 video clocks MIME-Version: 1.0 Message-Id: <20240420-d1_de2-v1-1-297efca674ba@jookia.org> References: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> In-Reply-To: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> To: Jagan Teki , Andre Przywara , Tom Rini , Anatolij Gustschin Cc: u-boot@lists.denx.de, John Watts X-Developer-Signature: v=1; a=openssh-sha256; t=1713571363; l=5736; i=contact@jookia.org; h=from:subject:message-id; bh=xEXLRG7YN7TAro4qiYtYHZoWTBViz32rLkH19ffOWrw=; b=U1NIU0lHAAAAAQAAAEoAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgpGuA3uho2 8zVxm554DVLHyl4gq5/nBHglU5WIWN8/zYAAAAEc3NoOgAAAAZwYXRhdHQAAAAAAAAABnNoYTUx MgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABA8kpcAD0J9P6osJxBLOVfIoZ LGxJjS3mOoqrd0lOv0LOjUF1PG7w9ue2ddV5pPHG2j7kMgPxClz2k50e2vYeOAQUAAOoV X-Developer-Key: i=contact@jookia.org; a=openssh; fpr=SHA256:6LBQmZH5u7i/edmEZXzCTwCrpSevs/ZshZxNmlD1thY X-Migadu-Flow: FLOW_OUT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean This code adds support for clocking VIDEO0 and VIDEO1, as well as registers used for the DE2. This code deliberately uses a 12MHz step in clocking to align with the DE2 code's expectation of double 6MHz steps. Signed-off-by: John Watts --- arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h | 56 ++++++++++++++++++ arch/arm/mach-sunxi/clock_sun50i_h6.c | 71 +++++++++++++++++++++++ 2 files changed, 127 insertions(+) diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h b/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h index a84a57e5b4..dfe8d9315f 100644 --- a/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h +++ b/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h @@ -236,6 +236,28 @@ struct sunxi_ccm_reg { #define CCM_PLL1_CTRL_P(p) ((p) << 16) #define CCM_PLL1_CTRL_N(n) (((n) - 1) << 8) +/* pll3 (video0) bit field */ +#define CCM_PLL3_CTRL_EN BIT(31) +#define CCM_PLL3_LDO_EN BIT(30) +#define CCM_PLL3_LOCK_EN BIT(29) +#define CCM_PLL3_LOCK BIT(28) +#define CCM_PLL3_OUT_EN BIT(27) +#define CCM_PLL3_INPUT_DIV2 BIT(1) +#define CCM_PLL3_CTRL_N(n) (((n) - 1) << 8) +#define CCM_PLL3_CTRL_N_SHIFT 8 +#define CCM_PLL3_CTRL_N_MASK (0xff << CCM_PLL3_CTRL_N_SHIFT) + +/* video1 bit field */ +#define CCM_VIDEO1_CTRL_EN BIT(31) +#define CCM_VIDEO1_LDO_EN BIT(30) +#define CCM_VIDEO1_LOCK_EN BIT(29) +#define CCM_VIDEO1_LOCK BIT(28) +#define CCM_VIDEO1_OUT_EN BIT(27) +#define CCM_VIDEO1_INPUT_DIV2 BIT(1) +#define CCM_VIDEO1_CTRL_N(n) (((n) - 1) << 8) +#define CCM_VIDEO1_CTRL_N_SHIFT 8 +#define CCM_VIDEO1_CTRL_N_MASK (0xff << CCM_VIDEO1_CTRL_N_SHIFT) + /* pll5 bit field */ #define CCM_PLL5_CTRL_EN BIT(31) #define CCM_PLL5_LOCK_EN BIT(29) @@ -258,6 +280,16 @@ struct sunxi_ccm_reg { #define CCM_PLL6_CTRL_DIV2_SHIFT 1 #define CCM_PLL6_CTRL_DIV2_MASK (0x1 << CCM_PLL6_CTRL_DIV2_SHIFT) +/* pll10 bit field */ +#define CCM_PLL10_CTRL_EN BIT(31) +#define CCM_PLL10_LOCK_EN BIT(29) +#define CCM_PLL10_LOCK BIT(28) +#define CCM_PLL10_OUT_EN BIT(27) +#define CCM_PLL10_INPUT_DIV2 BIT(1) +#define CCM_PLL10_CTRL_N(n) (((n) - 1) << 8) +#define CCM_PLL10_CTRL_N_SHIFT 8 +#define CCM_PLL10_CTRL_N_MASK (0xff << CCM_PLL10_CTRL_N_SHIFT) + /* cpu_axi bit field*/ #define CCM_CPU_AXI_MUX_MASK (0x3 << 24) #define CCM_CPU_AXI_MUX_OSC24M (0x0 << 24) @@ -341,9 +373,33 @@ struct sunxi_ccm_reg { #define CCM_MMC_CTRL_OCLK_DLY(a) ((void) (a), 0) #define CCM_MMC_CTRL_SCLK_DLY(a) ((void) (a), 0) +/* TCON0 clock bit field */ +#define CCM_TCON0_CTRL_ENABLE (0x1 << 31) +#define CCM_TCON0_CTRL_VIDEO0_4X (0x1 << 24) +#define CCM_TCON0_CTRL_M(m) ((((m) - 1) & 0xf) << 0) + +/* TCON1 clock bit field */ +#define CCM_TCON1_CTRL_ENABLE (0x1 << 31) +#define CCM_TCON1_CTRL_VIDEO0_4X (0x1 << 24) +#define CCM_TCON1_CTRL_M(m) ((((m) - 1) & 0xf) << 0) + +/* CCM bits common to all Display Engine 2.0 clock ctrl regs */ +#define CCM_DE2_CTRL_M(n) ((((n) - 1) & 0xf) << 0) +#define CCM_DE2_CTRL_PLL_MASK (3 << 24) +#define CCM_DE2_CTRL_PLL10_H6 (0 << 24) +#define CCM_DE2_CTRL_VIDEO1_4X_NCAT (2 << 24) +#define CCM_DE2_CTRL_GATE (0x1 << 31) + #ifndef __ASSEMBLY__ void clock_set_pll1(unsigned int hz); unsigned int clock_get_pll6(void); + +#ifdef CONFIG_SUNXI_DE2 +void clock_set_pll3(unsigned int hz); +void clock_set_video1(unsigned int hz); +void clock_set_pll10(unsigned int hz); +unsigned int clock_get_pll3(void); +#endif #endif #endif /* _SUNXI_CLOCK_SUN50I_H6_H */ diff --git a/arch/arm/mach-sunxi/clock_sun50i_h6.c b/arch/arm/mach-sunxi/clock_sun50i_h6.c index dac3663e1b..11e303f801 100644 --- a/arch/arm/mach-sunxi/clock_sun50i_h6.c +++ b/arch/arm/mach-sunxi/clock_sun50i_h6.c @@ -160,3 +160,74 @@ int clock_twi_onoff(int port, int state) return 0; } + +#ifdef CONFIG_SUNXI_DE2 + +void clock_set_pll3(unsigned int clk) +{ + struct sunxi_ccm_reg * const ccm = + (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; + + if (clk == 0) { + clrbits_le32(&ccm->pll3_cfg, CCM_PLL3_CTRL_EN); + return; + } + + /* PLL3 rate = 24000000 * n / 2 */ + writel(CCM_PLL3_CTRL_EN | CCM_PLL3_LOCK_EN | CCM_PLL3_OUT_EN | CCM_PLL3_LDO_EN | + CCM_PLL3_INPUT_DIV2 | CCM_PLL3_CTRL_N(clk / 12000000), + &ccm->pll3_cfg); + + while (!(readl(&ccm->pll3_cfg) & CCM_PLL3_LOCK)) + ; +} + +void clock_set_video1(unsigned int clk) +{ + struct sunxi_ccm_reg * const ccm = + (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; + + if (clk == 0) { + clrbits_le32(&ccm->pll_video1_cfg, CCM_VIDEO1_CTRL_EN); + return; + } + + /* VIDEO1 rate = 24000000 * n / 2 */ + writel(CCM_VIDEO1_CTRL_EN | CCM_VIDEO1_LOCK_EN | CCM_VIDEO1_OUT_EN | CCM_VIDEO1_LDO_EN | + CCM_VIDEO1_INPUT_DIV2 | CCM_VIDEO1_CTRL_N(clk / 12000000), + &ccm->pll_video1_cfg); + + while (!(readl(&ccm->pll_video1_cfg) & CCM_VIDEO1_LOCK)) + ; +} + +void clock_set_pll10(unsigned int clk) +{ + struct sunxi_ccm_reg * const ccm = + (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; + + if (clk == 0) { + clrbits_le32(&ccm->pll10_cfg, CCM_PLL10_CTRL_EN); + return; + } + + /* PLL10 rate = 24000000 * n / 2 */ + writel(CCM_PLL10_CTRL_EN | CCM_PLL10_LOCK_EN | CCM_PLL10_OUT_EN | + CCM_PLL10_INPUT_DIV2 | CCM_PLL10_CTRL_N(clk / 12000000), + &ccm->pll_video1_cfg); + + while (!(readl(&ccm->pll_video1_cfg) & CCM_PLL10_LOCK)) + ; +} + +unsigned int clock_get_pll3(void) +{ + struct sunxi_ccm_reg *const ccm = + (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; + u32 rval = readl(&ccm->pll3_cfg); + int n = ((rval & CCM_PLL3_CTRL_N_MASK) >> CCM_PLL3_CTRL_N_SHIFT) + 1; + + return 12000 * n * 1000; +} + +#endif From patchwork Sat Apr 20 00:02:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 1925776 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=DEmT2jCS; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLsF32PJ4z1yZP for ; Sat, 20 Apr 2024 10:04:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5708D885BD; Sat, 20 Apr 2024 02:03:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org 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=jookia.org header.i=@jookia.org header.b="DEmT2jCS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C777388682; Sat, 20 Apr 2024 02:03:53 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EF6AD885BD for ; Sat, 20 Apr 2024 02:03:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=contact@jookia.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1713571431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AxRJ2nG9UujNTuxU6MTu7vtW2CXebfxIx8hc0C985lM=; b=DEmT2jCSoFYPy9tEEPhPsJtufj3Piu0CG2Da11NNjuxfoUuRpA1UIzfRpTi+BUv+WUBTYv LKuxlb1L5+gdVVQnxSB7ua3Jkg6ReENSKRnpqvFcGnb+NnQkstEBNptPmFnu9JpoBKGVGq dUfBY0+2jyZTKC9d+eoYmaU/ViwYPzd9+jbUYHl1t/jVELn+IQyLhltmc0aC4764uG5YqT b0n9GfnsQLdYfHRgBlCgPk3CSBp/Vln+ziqtuQaL8EnpKIYYA+VLeN43/gPJnmpuqLlAOE +N+E2adEQfNuDddEtcwC8NzdQbiQfs2wVFfDGzhIVK9Lo+z/06ofOcu45bXxnA== From: John Watts Date: Sat, 20 Apr 2024 10:02:35 +1000 Subject: [PATCH RFC 2/9] sunxi: ncat2: Specify DE2 and LCD0 base addresses MIME-Version: 1.0 Message-Id: <20240420-d1_de2-v1-2-297efca674ba@jookia.org> References: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> In-Reply-To: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> To: Jagan Teki , Andre Przywara , Tom Rini , Anatolij Gustschin Cc: u-boot@lists.denx.de, John Watts X-Developer-Signature: v=1; a=openssh-sha256; t=1713571368; l=751; i=contact@jookia.org; h=from:subject:message-id; bh=9YL8q2WjZiB5Cqnq61xa5zuf9DW+sNLlJm02Kmt1ocw=; b=U1NIU0lHAAAAAQAAAEoAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgpGuA3uho2 8zVxm554DVLHyl4gq5/nBHglU5WIWN8/zYAAAAEc3NoOgAAAAZwYXRhdHQAAAAAAAAABnNoYTUx MgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABA34nAFkDJsYdWfUnmHaXVSkf LWO7sn+tFUlh5sxjwk+gOXOoU56V0LG/2zh1iH85Dz6+X3oCsLiisqNiGJWQuAwUAAOoj X-Developer-Key: i=contact@jookia.org; a=openssh; fpr=SHA256:6LBQmZH5u7i/edmEZXzCTwCrpSevs/ZshZxNmlD1thY X-Migadu-Flow: FLOW_OUT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean These are used for operating the LCD on the D1/T113. Signed-off-by: John Watts --- arch/arm/include/asm/arch-sunxi/cpu_sunxi_ncat2.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sunxi_ncat2.h b/arch/arm/include/asm/arch-sunxi/cpu_sunxi_ncat2.h index 908a582ae0..4ae93b5095 100644 --- a/arch/arm/include/asm/arch-sunxi/cpu_sunxi_ncat2.h +++ b/arch/arm/include/asm/arch-sunxi/cpu_sunxi_ncat2.h @@ -25,6 +25,9 @@ #define SUNXI_MMC1_BASE 0x04021000 #define SUNXI_MMC2_BASE 0x04022000 +#define SUNXI_DE2_BASE 0x05000000 +#define SUNXI_LCD0_BASE 0x05461000 + #define SUNXI_R_CPUCFG_BASE 0x07000400 #define SUNXI_PRCM_BASE 0x07010000 From patchwork Sat Apr 20 00:02:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 1925777 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=DvV2R+d1; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLsFG3yFjz1yZP for ; Sat, 20 Apr 2024 10:04:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D61DA88670; Sat, 20 Apr 2024 02:04:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org 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=jookia.org header.i=@jookia.org header.b="DvV2R+d1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4A0858813F; Sat, 20 Apr 2024 02:04:05 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [IPv6:2001:41d0:203:375::ad]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 04F6088693 for ; Sat, 20 Apr 2024 02:04:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=contact@jookia.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1713571439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T5T0wjPghC0sRbkAsuag1RhqTJCyLnvCIwEVua2GVeY=; b=DvV2R+d1uacy3TmheUleVEW1ByJvxyXsJGNDWfDbK79ITXgFn584D8GnSFLCFGyokW6D7M /qMFOOPaeyfcHr5E0bB99C7vGF58McC2axvUi4A9emg967GOQJLkvP+itaYQHSbFxbWzEn yS19naKOcM3Umf5wdMdArCfFr439oeTmD8QvatsWrjMfiIU7y1m3qq1lDbmvuQ9iwdAq88 oxukv6cV+oX5U/Rq2e4GKwFJgx31UYjZaaLC9EEaO9rIJPzNzJ4/jpB88+UCJP7D3zr0t/ IlRDeNu/qw3mJ4tDeDn2XXpE6t0E8ZAruSLv4F2R33cmWFG84/N4LAv885TfPw== From: John Watts Date: Sat, 20 Apr 2024 10:02:36 +1000 Subject: [PATCH RFC 3/9] sunxi: sun50i-h6: Specify DE2 and LCD0 base addresses MIME-Version: 1.0 Message-Id: <20240420-d1_de2-v1-3-297efca674ba@jookia.org> References: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> In-Reply-To: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> To: Jagan Teki , Andre Przywara , Tom Rini , Anatolij Gustschin Cc: u-boot@lists.denx.de, John Watts X-Developer-Signature: v=1; a=openssh-sha256; t=1713571372; l=748; i=contact@jookia.org; h=from:subject:message-id; bh=IySDGZDJQ9iUzaxPdy5nvMjMDL09d9dIHpL39uDY5p0=; b=U1NIU0lHAAAAAQAAAEoAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgpGuA3uho2 8zVxm554DVLHyl4gq5/nBHglU5WIWN8/zYAAAAEc3NoOgAAAAZwYXRhdHQAAAAAAAAABnNoYTUx MgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABAcdKgMHgHCRd2cjZ/Mg6gH+z oMP59/yK3pg22mBkiwUyrpY6Ho1hVeVZ8BZ7wD2ZsY5Yzht3cYtvqdi3nxyxaBQUAAOoy X-Developer-Key: i=contact@jookia.org; a=openssh; fpr=SHA256:6LBQmZH5u7i/edmEZXzCTwCrpSevs/ZshZxNmlD1thY X-Migadu-Flow: FLOW_OUT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean These are used for operating the LCD on the H6/H616. Signed-off-by: John Watts --- arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h index 8a3f465545..2c9fe18289 100644 --- a/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h +++ b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h @@ -31,6 +31,9 @@ #define SUNXI_DRAM_PHY0_BASE 0x04800000 #endif +#define SUNXI_DE2_BASE 0x01000000 +#define SUNXI_LCD0_BASE 0x06515000 + #define SUNXI_TWI0_BASE 0x05002000 #define SUNXI_TWI1_BASE 0x05002400 #define SUNXI_TWI2_BASE 0x05002800 From patchwork Sat Apr 20 00:02:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 1925778 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=GEXW8bz4; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLsFT1wBqz1yZP for ; Sat, 20 Apr 2024 10:04:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD8D68869E; Sat, 20 Apr 2024 02:04:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org 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=jookia.org header.i=@jookia.org header.b="GEXW8bz4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D8EA18813F; Sat, 20 Apr 2024 02:04:13 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D33398869E for ; Sat, 20 Apr 2024 02:04:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=contact@jookia.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1713571450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u8oK0VOk8rYQ3vJ9vXEpOrB1j+vVgQIm2UFIxpx5/zQ=; b=GEXW8bz4hKb2Z5UXDjssH4oTLlrKGSvpC/m+l8GwbFlZOlw6+6pFEkW8sZvSXB30vLuATS VIGvALVCM0+D85lroeWLiQAuPa7Cn0m7f9Es5SmuBly+CuWVDRUXhO/FgyiuR9DOzsySkX IWeUX7fHchm8mx/iirCgYS+bDAZBhsHjemsIlLM8A1EbdZFkwGx0qgB7uqx8lC/P4IeVGX OD7C+X46vHa4pCxm88Evy6gKbVJ5N459U6JNYsGtNuZHHMJ+LqtSDku5Tk7COxs9bTDehd PA8FOhLtbjEM0HUPx2Nit84PTiXftPXbEgsAJ01vgWMdtZkLuJMiecQY7tVpiQ== From: John Watts Date: Sat, 20 Apr 2024 10:02:37 +1000 Subject: [PATCH RFC 4/9] sunxi: video: support LCD on H6/D1 MIME-Version: 1.0 Message-Id: <20240420-d1_de2-v1-4-297efca674ba@jookia.org> References: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> In-Reply-To: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> To: Jagan Teki , Andre Przywara , Tom Rini , Anatolij Gustschin Cc: u-boot@lists.denx.de, John Watts X-Developer-Signature: v=1; a=openssh-sha256; t=1713571377; l=3146; i=contact@jookia.org; h=from:subject:message-id; bh=rEvFd18YwRHNn/jxbegK4wU2B8UsGXHXGeMz/kbD8/M=; b=U1NIU0lHAAAAAQAAAEoAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgpGuA3uho2 8zVxm554DVLHyl4gq5/nBHglU5WIWN8/zYAAAAEc3NoOgAAAAZwYXRhdHQAAAAAAAAABnNoYTUx MgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABA0Z3N/IfBEBAy7hx/nK6xbxc VcycfBEn5mwaiGWZzHUhLnB6nG9fZQo3JvmuXoifV9dNy37ULZ5KHyMhWfccJBwUAAOo8 X-Developer-Key: i=contact@jookia.org; a=openssh; fpr=SHA256:6LBQmZH5u7i/edmEZXzCTwCrpSevs/ZshZxNmlD1thY X-Migadu-Flow: FLOW_OUT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean The H6/D1/R528 don't require any big changes, just some small tweaks to support new clock and reset logic. Signed-off-by: John Watts --- drivers/video/sunxi/lcdc.c | 20 ++++++++++++++++++++ drivers/video/sunxi/sunxi_lcd.c | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/video/sunxi/lcdc.c b/drivers/video/sunxi/lcdc.c index 73033c3b85..ea21d602be 100644 --- a/drivers/video/sunxi/lcdc.c +++ b/drivers/video/sunxi/lcdc.c @@ -277,6 +277,12 @@ void lcdc_pll_set(struct sunxi_ccm_reg *ccm, int tcon, int dotclock, } } +#if IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2) + /* No need to clock doubling, just ask for a higher PLL clock */ + best_double = 0; + step *= 2; +#endif + #ifdef CONFIG_MACH_SUN6I /* * Use the MIPI pll if we've been unable to find any matching setting @@ -302,6 +308,19 @@ void lcdc_pll_set(struct sunxi_ccm_reg *ccm, int tcon, int dotclock, best_double + 1, step, best_n, best_m); } +#if IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2) + if (tcon == 0) { + writel(CCM_TCON0_CTRL_VIDEO0_4X | CCM_TCON0_CTRL_ENABLE, + &ccm->tcon_lcd0_clk_cfg); + setbits_le32(&ccm->tcon_lcd_gate_reset, BIT(RESET_SHIFT)); + setbits_le32(&ccm->tcon_lcd_gate_reset, BIT(GATE_SHIFT)); + } else { + writel(CCM_TCON1_CTRL_VIDEO0_4X | CCM_TCON1_CTRL_ENABLE, + &ccm->tcon_tv0_clk_cfg); + setbits_le32(&ccm->tcon_tv_gate_reset, BIT(RESET_SHIFT)); + setbits_le32(&ccm->tcon_tv_gate_reset, BIT(GATE_SHIFT)); + } +#else if (tcon == 0) { u32 pll; @@ -329,6 +348,7 @@ void lcdc_pll_set(struct sunxi_ccm_reg *ccm, int tcon, int dotclock, setbits_le32(&ccm->lcd0_ch1_clk_cfg, CCM_LCD_CH1_CTRL_HALF_SCLK1); } +#endif #endif *clk_div = best_m; diff --git a/drivers/video/sunxi/sunxi_lcd.c b/drivers/video/sunxi/sunxi_lcd.c index 7a01cc343c..3b0e63233f 100644 --- a/drivers/video/sunxi/sunxi_lcd.c +++ b/drivers/video/sunxi/sunxi_lcd.c @@ -26,7 +26,7 @@ struct sunxi_lcd_priv { static void sunxi_lcdc_config_pinmux(void) { -#ifdef CONFIG_MACH_SUN50I +#if IS_ENABLED(CONFIG_MACH_SUN50I) || IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_MACH_SUN8I_R528) int pin; for (pin = SUNXI_GPD(0); pin <= SUNXI_GPD(21); pin++) { @@ -47,10 +47,12 @@ static int sunxi_lcd_enable(struct udevice *dev, int bpp, struct udevice *backlight; int clk_div, clk_double, ret; +#if !IS_ENABLED(CONFIG_SUN50I_GEN_H6) && !IS_ENABLED(CONFIG_MACH_SUN8I_R528) /* Reset off */ setbits_le32(&ccm->ahb_reset1_cfg, 1 << AHB_RESET_OFFSET_LCD0); /* Clock on */ setbits_le32(&ccm->ahb_gate1, 1 << AHB_GATE_OFFSET_LCD0); +#endif lcdc_init(lcdc); sunxi_lcdc_config_pinmux(); @@ -146,7 +148,7 @@ U_BOOT_DRIVER(sunxi_lcd) = { .priv_auto = sizeof(struct sunxi_lcd_priv), }; -#ifdef CONFIG_MACH_SUN50I +#if IS_ENABLED(CONFIG_MACH_SUN50I) || IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_MACH_SUN8I_R528) U_BOOT_DRVINFO(sunxi_lcd) = { .name = "sunxi_lcd" }; From patchwork Sat Apr 20 00:02:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 1925779 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=FGqhikG/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLsFj2KbZz1yZP for ; Sat, 20 Apr 2024 10:04:41 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AD515886A5; Sat, 20 Apr 2024 02:04:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org 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=jookia.org header.i=@jookia.org header.b="FGqhikG/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3B00F886CF; Sat, 20 Apr 2024 02:04:23 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CF047881F6 for ; Sat, 20 Apr 2024 02:04:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=contact@jookia.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1713571458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BU1iC6gVG3dJUyc04farFgf4QliHt9fc540Un9bkKzg=; b=FGqhikG/qMOk8h78ZPmX/SjG+6TgI/oefoNshw81mxZqc01aKzGfH2hV4cZ9+zMVmXjWXL /G772WaJxu+TbQEOt8OweU69Y4NtsILbfzQn+5aCEfSGivycZlBdKThY2c/4fWwWtKYl3I Gh77nV7cEg2cHfbyfn/dKSiLSVuChbBRMdixtg6AMLUWZzN+8/dJmwI2ADzQu4p8U/psuL wOBlK9iMMUDYyPxawuI9AftBmIdOkTtO8sivAXrD38TQ+Uu44E9KhaAPdwPFq3Wz9ISJaE vp9hTzgB/vb2jlRoPBo3bp5fQ6i55Dow0xCN7IqP6t6GbIrjmdOUxu00S8aBRQ== From: John Watts Date: Sat, 20 Apr 2024 10:02:38 +1000 Subject: [PATCH RFC 5/9] sunxi: video: enable DE2 on H6/D1 MIME-Version: 1.0 Message-Id: <20240420-d1_de2-v1-5-297efca674ba@jookia.org> References: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> In-Reply-To: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> To: Jagan Teki , Andre Przywara , Tom Rini , Anatolij Gustschin Cc: u-boot@lists.denx.de, John Watts X-Developer-Signature: v=1; a=openssh-sha256; t=1713571381; l=1517; i=contact@jookia.org; h=from:subject:message-id; bh=CXRmt137o26NSf5yQUCmUV0QW+NJzP/eXJkYV/+fOhE=; b=U1NIU0lHAAAAAQAAAEoAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgpGuA3uho2 8zVxm554DVLHyl4gq5/nBHglU5WIWN8/zYAAAAEc3NoOgAAAAZwYXRhdHQAAAAAAAAABnNoYTUx MgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABAixuIL/X++RoZtmFaWm5EHLb 0FPsZr9EvwWICZ/hOs70kIkC6XkSoyR6UJNpQpc1LIa9r9ckqd1bRgxd8w4pbAwUAAOpC X-Developer-Key: i=contact@jookia.org; a=openssh; fpr=SHA256:6LBQmZH5u7i/edmEZXzCTwCrpSevs/ZshZxNmlD1thY X-Migadu-Flow: FLOW_OUT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean This requires just a little change to clocking and reset logic. Signed-off-by: John Watts --- drivers/video/sunxi/sunxi_de2.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/video/sunxi/sunxi_de2.c b/drivers/video/sunxi/sunxi_de2.c index e02d359cd2..9b6c41b212 100644 --- a/drivers/video/sunxi/sunxi_de2.c +++ b/drivers/video/sunxi/sunxi_de2.c @@ -45,6 +45,23 @@ static void sunxi_de2_composer_init(void) writel(reg_value, SUNXI_SRAMC_BASE + 0x04); #endif +#if IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2) + if (IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2)) { + /* Set DE parent to video1 */ + clock_set_video1(432000000); + clrsetbits_le32(&ccm->de_clk_cfg, CCM_DE2_CTRL_PLL_MASK, + CCM_DE2_CTRL_VIDEO1_4X_NCAT); + } else { + /* Set DE parent to pll10 */ + clock_set_pll10(432000000); + clrsetbits_le32(&ccm->de_clk_cfg, CCM_DE2_CTRL_PLL_MASK, + CCM_DE2_CTRL_PLL10_H6); + } + + /* Ungate the DE */ + setbits_le32(&ccm->de_gate_reset, BIT(RESET_SHIFT)); + setbits_le32(&ccm->de_gate_reset, BIT(GATE_SHIFT)); +#else clock_set_pll10(432000000); /* Set DE parent to pll10 */ @@ -54,6 +71,7 @@ static void sunxi_de2_composer_init(void) /* Set ahb gating to pass */ setbits_le32(&ccm->ahb_reset1_cfg, 1 << AHB_RESET_OFFSET_DE); setbits_le32(&ccm->ahb_gate1, 1 << AHB_GATE_OFFSET_DE); +#endif /* Clock on */ setbits_le32(&ccm->de_clk_cfg, CCM_DE2_CTRL_GATE); From patchwork Sat Apr 20 00:02:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 1925780 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=Qc9XWR0r; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLsFv4qw5z1yZP for ; Sat, 20 Apr 2024 10:04:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 22348886C8; Sat, 20 Apr 2024 02:04:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org 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=jookia.org header.i=@jookia.org header.b="Qc9XWR0r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2E5C088208; Sat, 20 Apr 2024 02:04:29 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from out-176.mta0.migadu.com (out-176.mta0.migadu.com [IPv6:2001:41d0:1004:224b::b0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3FDE6881F6 for ; Sat, 20 Apr 2024 02:04:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=contact@jookia.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1713571466; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9btPr7nTz+E9V369ulyHjBkjkOj/pyjB80GKXiSBb3E=; b=Qc9XWR0rupmWeygz9nUayqGe18hyeLCNYVZv1ZEDd+4pT1xgL0ENldumdj6ftuG9/j46Fy mzVnURLSWI9bAvd0xiRgYuaSLTN1KeWdKs1anGBfdQ/Ck1h3cpqd6eJqmSse5I45ypStBN sDup7RpaJHc2BSyJlzxN0g2rzHT4dE0PYaUTuT+QK+FO43bqnDxwsLHxLNrJLzG8y+lGCo iAw2qbpjUByGPV8msZnHFFfagj2yOekReKrykmhRiFgt4xjw3ajS/3+nFaO+H3uIheS2ZP MkT2vLvVk+JewzlQIW26/MbGvSvYh9TycXHv7LRhDH5DatDZRTwHRQwdNNQjcQ== From: John Watts Date: Sat, 20 Apr 2024 10:02:39 +1000 Subject: [PATCH RFC 6/9] sunxi: video: silence unused use_mipi_pll warning MIME-Version: 1.0 Message-Id: <20240420-d1_de2-v1-6-297efca674ba@jookia.org> References: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> In-Reply-To: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> To: Jagan Teki , Andre Przywara , Tom Rini , Anatolij Gustschin Cc: u-boot@lists.denx.de, John Watts X-Developer-Signature: v=1; a=openssh-sha256; t=1713571385; l=716; i=contact@jookia.org; h=from:subject:message-id; bh=Ok8mqtDbaaH/r9VTt7O13r+9FeXV+IoN3/tMHI3c+EU=; b=U1NIU0lHAAAAAQAAAEoAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgpGuA3uho2 8zVxm554DVLHyl4gq5/nBHglU5WIWN8/zYAAAAEc3NoOgAAAAZwYXRhdHQAAAAAAAAABnNoYTUx MgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABAxbBRBM9DnTX+McitCjANTHZ vSw03stlXvb5zvma4/Nppq97Z444xCFQKn5vzDnBj0dP7T3KPREavOZpMGvTDAQUAAOpL X-Developer-Key: i=contact@jookia.org; a=openssh; fpr=SHA256:6LBQmZH5u7i/edmEZXzCTwCrpSevs/ZshZxNmlD1thY X-Migadu-Flow: FLOW_OUT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean This variable is only used sometimes, so gate it behind an #ifdef. Signed-off-by: John Watts --- drivers/video/sunxi/lcdc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/sunxi/lcdc.c b/drivers/video/sunxi/lcdc.c index ea21d602be..1474f6cb2e 100644 --- a/drivers/video/sunxi/lcdc.c +++ b/drivers/video/sunxi/lcdc.c @@ -216,7 +216,10 @@ void lcdc_pll_set(struct sunxi_ccm_reg *ccm, int tcon, int dotclock, int value, n, m, min_m, max_m, diff, step; int best_n = 0, best_m = 0, best_diff = 0x0FFFFFFF; int best_double = 0; + +#ifdef CONFIG_MACH_SUN6I bool use_mipi_pll = false; +#endif #ifdef CONFIG_SUNXI_DE2 step = 6000; From patchwork Sat Apr 20 00:02:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 1925781 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=ctav8YZS; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLsG71wH5z1yZP for ; Sat, 20 Apr 2024 10:05:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 83A4F886A8; Sat, 20 Apr 2024 02:04:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org 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=jookia.org header.i=@jookia.org header.b="ctav8YZS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 474EC88208; Sat, 20 Apr 2024 02:04:39 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [IPv6:2001:41d0:1004:224b::b5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1AD69886D1 for ; Sat, 20 Apr 2024 02:04:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=contact@jookia.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1713571474; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tnvyU/UgHwRxIG96DAwQ4nQ19tS60e37buWb18wuHJY=; b=ctav8YZSssWGmzB7NxEz/Y1rkD/23BHZKDSN7Keoi+2dEvg2toJvLuMq9y6tl8SKjR7uHn COqLOvCyAMakyCdT+FTkotJQSwzn3xra2i0b94BHoZPIxfLf8nUQp1h2+wJrRewrjGjBSi RwA29qDYRvD7F1IfsQg/TWKzlUbyEfvTzK0FF4EGyvP8CnzAeGX45ITNV02dmjkO/u4qpI hf+BOFzz+YBmrXUzIbR6Dh3BqbLNBcVhHHAckwV6mrdHD8PvsHUkxfoQzKXd0nT656HXEz gm8BpQ+5ZlMpPopdxOydh08MVsctRr1AOSENPF22GEWVAuFJ9vrGVA8O2CvMCw== From: John Watts Date: Sat, 20 Apr 2024 10:02:40 +1000 Subject: [PATCH RFC 7/9] sunxi: video: dummy out HDMI on H6/D1 MIME-Version: 1.0 Message-Id: <20240420-d1_de2-v1-7-297efca674ba@jookia.org> References: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> In-Reply-To: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> To: Jagan Teki , Andre Przywara , Tom Rini , Anatolij Gustschin Cc: u-boot@lists.denx.de, John Watts X-Developer-Signature: v=1; a=openssh-sha256; t=1713571393; l=2493; i=contact@jookia.org; h=from:subject:message-id; bh=457rH0d96TOrqmQY+dauVDpwDuZtEWz9ImEObwtqHfQ=; b=U1NIU0lHAAAAAQAAAEoAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgpGuA3uho2 8zVxm554DVLHyl4gq5/nBHglU5WIWN8/zYAAAAEc3NoOgAAAAZwYXRhdHQAAAAAAAAABnNoYTUx MgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABAGuY7oIiiGN9erz2t0WWHjKP AH8y3Cn65ilMHgv4X/I4YfCcZnddiecpieZz5Id7zvZNZ32rrFYb910YtvtP/CgUAAOpZ X-Developer-Key: i=contact@jookia.org; a=openssh; fpr=SHA256:6LBQmZH5u7i/edmEZXzCTwCrpSevs/ZshZxNmlD1thY X-Migadu-Flow: FLOW_OUT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean I don't have any hardware to implement HDMI support on, but it's still worth making the code compile for future work. Adding HDMI support shouldn't be too difficult, though beware: The H6 and H616 both have a different set of HDMI clock parents. Future code will most likely need to pick VIDEO0 or VIDEO1 to run the TCON and HDMI encoder based on the chip. Signed-off-by: John Watts --- drivers/video/sunxi/sunxi_dw_hdmi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/video/sunxi/sunxi_dw_hdmi.c b/drivers/video/sunxi/sunxi_dw_hdmi.c index 0324a050d0..34a6b8bab7 100644 --- a/drivers/video/sunxi/sunxi_dw_hdmi.c +++ b/drivers/video/sunxi/sunxi_dw_hdmi.c @@ -230,7 +230,12 @@ static void sunxi_dw_hdmi_pll_set(uint clk_khz, int *phy_div) *phy_div = best_div; +#if IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2) + panic("setting HDMI pll not implemented"); +#else clock_set_pll3_factors(best_m, best_n); +#endif + debug("dotclock: %dkHz = %dkHz: (24MHz * %d) / %d / %d\n", clk_khz, (clock_get_pll3() / 1000) / best_div, best_n, best_m, best_div); @@ -244,6 +249,9 @@ static void sunxi_dw_hdmi_lcdc_init(int mux, const struct display_timing *edid, int div = DIV_ROUND_UP(clock_get_pll3(), edid->pixelclock.typ); struct sunxi_lcdc_reg *lcdc; +#if IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2) + panic("initializing HDMI lcdc not implemented"); +#else if (mux == 0) { lcdc = (struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE; @@ -265,6 +273,7 @@ static void sunxi_dw_hdmi_lcdc_init(int mux, const struct display_timing *edid, writel(CCM_LCD1_CTRL_GATE | CCM_LCD1_CTRL_M(div), &ccm->lcd1_clk_cfg); } +#endif lcdc_init(lcdc); lcdc_tcon1_mode_set(lcdc, edid, false, false); @@ -338,6 +347,9 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev) if (priv->hvcc) regulator_set_enable(priv->hvcc, true); +#if IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2) + panic("initializing HDMI not implemented"); +#else /* Set pll3 to 297 MHz */ clock_set_pll3(297000000); @@ -347,6 +359,7 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev) /* This reset is referenced from the PHY devicetree node. */ setbits_le32(&ccm->ahb_reset1_cfg, 1 << AHB_RESET_OFFSET_HDMI2); +#endif ret = reset_deassert_bulk(&priv->resets); if (ret) From patchwork Sat Apr 20 00:02:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 1925782 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=wAlOFM3M; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLsGM6TVhz1yZn for ; Sat, 20 Apr 2024 10:05:15 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 215958873D; Sat, 20 Apr 2024 02:04:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org 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=jookia.org header.i=@jookia.org header.b="wAlOFM3M"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5CC998873B; Sat, 20 Apr 2024 02:04:45 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [IPv6:2001:41d0:1004:224b::ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 80CCB886D5 for ; Sat, 20 Apr 2024 02:04:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=contact@jookia.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1713571483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2xjVKrPeMbquo1dgnRKeSpKmm2iBIjuNaHQyIGeK3fs=; b=wAlOFM3MlJpeUdzr+uq7ylcnVLJnXq5Qx/qYEFhWsa2V+q9+WGzf0eIjz6M74WD8EhoPFs 02S1kIGScE3MzuGavk6un4lujguiKXdNmO8g+fOky8hyXUaRPA5U1rzoRBGIIKfzMu0mx1 vfzL78RxTTlSlDkEytZLFp9cOAuCGmbuf+lS6hnOc2CnNya+4ed+t41HGjJmhRvmVXkB3h 1+scbmwowShVxoRTBRVj34YZOhdaTe0yBNGjEWhBK/5/5w+vHdSbXpBONdrV0ajvXbTNCJ HI6xtL86HZAAXddXSE/75fD8khv5aCoKn/Z3dA/Po4FPL+u2q1ffgtrlgn3a7g== From: John Watts Date: Sat, 20 Apr 2024 10:02:41 +1000 Subject: [PATCH RFC 8/9] sunxi: Enable display engine on H6/D1 MIME-Version: 1.0 Message-Id: <20240420-d1_de2-v1-8-297efca674ba@jookia.org> References: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> In-Reply-To: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> To: Jagan Teki , Andre Przywara , Tom Rini , Anatolij Gustschin Cc: u-boot@lists.denx.de, John Watts X-Developer-Signature: v=1; a=openssh-sha256; t=1713571397; l=889; i=contact@jookia.org; h=from:subject:message-id; bh=UgGLkRZ2qHEDDsr0f43iyWQk9eOPj/f6+OFtx8zlemU=; b=U1NIU0lHAAAAAQAAAEoAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgpGuA3uho2 8zVxm554DVLHyl4gq5/nBHglU5WIWN8/zYAAAAEc3NoOgAAAAZwYXRhdHQAAAAAAAAABnNoYTUx MgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABAVOS/d7VxEz8MqYn2iWuPVPm ob25oGP2LhsQ2erFykg+HaoecXPbUlC1fZPS4qDojDTiduOa8n/NS2awek8JeAwUAAOpg X-Developer-Key: i=contact@jookia.org; a=openssh; fpr=SHA256:6LBQmZH5u7i/edmEZXzCTwCrpSevs/ZshZxNmlD1thY X-Migadu-Flow: FLOW_OUT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean Now that all the code is present and can compile, enable the DE2 so people can use it. Signed-off-by: John Watts --- arch/arm/mach-sunxi/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index ddf9414b08..9d76e429ef 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -202,6 +202,7 @@ config SUN50I_GEN_H6 select SPL_LOAD_FIT if SPL select MMC_SUNXI_HAS_NEW_MODE select SUPPORT_SPL + select SUNXI_DE2 ---help--- Select this for sunxi SoCs which have H6 like peripherals, clocks and memory map. @@ -210,6 +211,7 @@ config SUNXI_GEN_NCAT2 bool select MMC_SUNXI_HAS_NEW_MODE select SUPPORT_SPL + select SUNXI_DE2 ---help--- Select this for sunxi SoCs which have D1 like peripherals, clocks and memory map. From patchwork Sat Apr 20 00:02:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 1925783 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=SC0gDJRR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLsGY5ykpz1yZn for ; Sat, 20 Apr 2024 10:05:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D9287886DA; Sat, 20 Apr 2024 02:04:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org 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=jookia.org header.i=@jookia.org header.b="SC0gDJRR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BB472886DD; Sat, 20 Apr 2024 02:04:56 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [IPv6:2001:41d0:203:375::bd]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9C8BA886DA for ; Sat, 20 Apr 2024 02:04:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=jookia.org Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=contact@jookia.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1713571492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+FmKSBWq8tm+kONHBAyDjBZbhhY0vTJhdoI5+0m5oFg=; b=SC0gDJRRDJjeJzaf4U1g4l5SsT083Y9CYgO0a4I9WfpZnrUi2eodo4Zynr44Ijr7absIsc DQ8jZ4RHMJTvt3LFvSmOVF+drQY0DUT0dmlvc0GU7+izWBbm+LPvZYhM7Mz01J2xCo4rAX hCGyXo5UH9l8mbUEPHncUFdmybgR+D4np54GYUdWRNr8pN3pcuJW6gPGGjdVHkMBCWgqTS Ql3tp8IFtO0TqkJ54ppb92hVv1J/59puhVsrapxUI4I/kRaGSeE9Ccxn5A+aJNYespRWjR 6swh/wpbZxWZq0VAdLf3uPtHOi0wJawxaMXN8LvNiP0cFs6YbWYJf/RO0vbk/w== From: John Watts Date: Sat, 20 Apr 2024 10:02:42 +1000 Subject: [PATCH RFC 9/9] sunxi: video: support HDMI on H6/H616 MIME-Version: 1.0 Message-Id: <20240420-d1_de2-v1-9-297efca674ba@jookia.org> References: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> In-Reply-To: <20240420-d1_de2-v1-0-297efca674ba@jookia.org> To: Jagan Teki , Andre Przywara , Tom Rini , Anatolij Gustschin Cc: u-boot@lists.denx.de, John Watts X-Developer-Signature: v=1; a=openssh-sha256; t=1713571402; l=7020; i=contact@jookia.org; h=from:subject:message-id; bh=Cwtk2TMU3X+CFVhjXS9eEdl7tgJM+MqrXWLmZY7TSWg=; b=U1NIU0lHAAAAAQAAAEoAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAAAgpGuA3uho2 8zVxm554DVLHyl4gq5/nBHglU5WIWN8/zYAAAAEc3NoOgAAAAZwYXRhdHQAAAAAAAAABnNoYTUx MgAAAGcAAAAac2stc3NoLWVkMjU1MTlAb3BlbnNzaC5jb20AAABAu75TbZwfk4aKeIn/8OBYhCT 2ZONZ/hFYyfNf5re3QBNnVKVfcoUhZNsvxP46rWX+CwOpEPqD19yiS9w/9kv1CAUAAOpo X-Developer-Key: i=contact@jookia.org; a=openssh; fpr=SHA256:6LBQmZH5u7i/edmEZXzCTwCrpSevs/ZshZxNmlD1thY X-Migadu-Flow: FLOW_OUT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean The H6 and H616 support outputting HDMI through the Display Engine. Set up the clocks and resets appropriately for the HDMI controller. This turns out to be a little tricky as the HDMI clock requires a different parent on the H6 compared to the H616. So we have to end up choosing VIDEO1 on the H616 and VIDEO0 elsewhere. Signed-off-by: John Watts --- arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h | 9 +++ arch/arm/mach-sunxi/clock_sun50i_h6.c | 10 ++++ drivers/video/sunxi/sunxi_dw_hdmi.c | 70 ++++++++++++++++++++--- 3 files changed, 80 insertions(+), 9 deletions(-) diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h b/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h index dfe8d9315f..35bd3dd2d8 100644 --- a/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h +++ b/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h @@ -376,13 +376,21 @@ struct sunxi_ccm_reg { /* TCON0 clock bit field */ #define CCM_TCON0_CTRL_ENABLE (0x1 << 31) #define CCM_TCON0_CTRL_VIDEO0_4X (0x1 << 24) +#define CCM_TCON0_CTRL_VIDEO1_4X (0x3 << 24) #define CCM_TCON0_CTRL_M(m) ((((m) - 1) & 0xf) << 0) /* TCON1 clock bit field */ #define CCM_TCON1_CTRL_ENABLE (0x1 << 31) #define CCM_TCON1_CTRL_VIDEO0_4X (0x1 << 24) +#define CCM_TCON1_CTRL_VIDEO1_4X (0x3 << 24) #define CCM_TCON1_CTRL_M(m) ((((m) - 1) & 0xf) << 0) +/* HDMI clock bit field */ +#define CCM_HDMI_CTRL_ENABLE (0x1 << 31) +#define CCM_HDMI_CTRL_VIDEO1_4X_H6 (0x2 << 24) +#define CCM_HDMI_CTRL_VIDEO0_4X_H616 (0x1 << 24) +#define CCM_HDMI_CTRL_M(m) ((((m) - 1) & 0xf) << 0) + /* CCM bits common to all Display Engine 2.0 clock ctrl regs */ #define CCM_DE2_CTRL_M(n) ((((n) - 1) & 0xf) << 0) #define CCM_DE2_CTRL_PLL_MASK (3 << 24) @@ -399,6 +407,7 @@ void clock_set_pll3(unsigned int hz); void clock_set_video1(unsigned int hz); void clock_set_pll10(unsigned int hz); unsigned int clock_get_pll3(void); +unsigned int clock_get_video1(void); #endif #endif diff --git a/arch/arm/mach-sunxi/clock_sun50i_h6.c b/arch/arm/mach-sunxi/clock_sun50i_h6.c index 11e303f801..23b7c13e28 100644 --- a/arch/arm/mach-sunxi/clock_sun50i_h6.c +++ b/arch/arm/mach-sunxi/clock_sun50i_h6.c @@ -230,4 +230,14 @@ unsigned int clock_get_pll3(void) return 12000 * n * 1000; } +unsigned int clock_get_video1(void) +{ + struct sunxi_ccm_reg *const ccm = + (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; + u32 rval = readl(&ccm->pll_video1_cfg); + int n = ((rval & CCM_VIDEO1_CTRL_N_MASK) >> CCM_VIDEO1_CTRL_N_SHIFT) + 1; + + return 12000 * n * 1000; +} + #endif diff --git a/drivers/video/sunxi/sunxi_dw_hdmi.c b/drivers/video/sunxi/sunxi_dw_hdmi.c index 34a6b8bab7..475d61a888 100644 --- a/drivers/video/sunxi/sunxi_dw_hdmi.c +++ b/drivers/video/sunxi/sunxi_dw_hdmi.c @@ -198,6 +198,12 @@ static void sunxi_dw_hdmi_pll_set(uint clk_khz, int *phy_div) { int value, n, m, div, diff; int best_n = 0, best_m = 0, best_div = 0, best_diff = 0x0FFFFFFF; + int step = 24000, max_m = 16, pll_value = 0; + + if (IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2)) { + step = 12000; + max_m = 1; + } /* * Find the lowest divider resulting in a matching clock. If there @@ -212,11 +218,11 @@ static void sunxi_dw_hdmi_pll_set(uint clk_khz, int *phy_div) if (target > 912000) continue; - for (m = 1; m <= 16; m++) { - n = (m * target) / 24000; + for (m = 1; m <= max_m; m++) { + n = (m * target) / step; if (n >= 1 && n <= 128) { - value = (24000 * n) / m / div; + value = (step * n) / m / div; diff = clk_khz - value; if (diff < best_diff) { best_diff = diff; @@ -231,13 +237,20 @@ static void sunxi_dw_hdmi_pll_set(uint clk_khz, int *phy_div) *phy_div = best_div; #if IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2) - panic("setting HDMI pll not implemented"); + if (IS_ENABLED(CONFIG_MACH_SUN50I_H6)) { + clock_set_video1(step * best_n); + pll_value = clock_get_video1(); + } else { + clock_set_pll3(step * best_n); + pll_value = clock_get_pll3(); + } #else clock_set_pll3_factors(best_m, best_n); + pll_value = clock_get_pll3(); #endif debug("dotclock: %dkHz = %dkHz: (24MHz * %d) / %d / %d\n", - clk_khz, (clock_get_pll3() / 1000) / best_div, + clk_khz, (pll_value / 1000) / best_div, best_n, best_m, best_div); } @@ -246,12 +259,34 @@ static void sunxi_dw_hdmi_lcdc_init(int mux, const struct display_timing *edid, { struct sunxi_ccm_reg * const ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; - int div = DIV_ROUND_UP(clock_get_pll3(), edid->pixelclock.typ); + int div, pll_value; struct sunxi_lcdc_reg *lcdc; #if IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2) - panic("initializing HDMI lcdc not implemented"); + int tcon1_src; + + if (IS_ENABLED(CONFIG_MACH_SUN50I_H6)) { + tcon1_src = CCM_TCON1_CTRL_VIDEO1_4X; + pll_value = clock_get_video1(); + } else { + tcon1_src = CCM_TCON1_CTRL_VIDEO0_4X; + pll_value = clock_get_pll3(); + } + + div = DIV_ROUND_UP(pll_value, edid->pixelclock.typ); + + if (mux == 0) { + writel(tcon1_src | CCM_TCON1_CTRL_ENABLE | CCM_TCON1_CTRL_M(div), + &ccm->tcon_tv0_clk_cfg); + setbits_le32(&ccm->tcon_tv_gate_reset, BIT(RESET_SHIFT)); + setbits_le32(&ccm->tcon_tv_gate_reset, BIT(GATE_SHIFT)); + } else { + /* TODO: H616 supports a second TV encoder */ + panic("using HDMI lcdc mux 1 is not implemented"); + } #else + div = DIV_ROUND_UP(pll_value, edid->pixelclock.typ); + if (mux == 0) { lcdc = (struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE; @@ -300,7 +335,12 @@ static int sunxi_dw_hdmi_read_edid(struct udevice *dev, u8 *buf, int buf_size) static bool sunxi_dw_hdmi_mode_valid(struct udevice *dev, const struct display_timing *timing) { - return timing->pixelclock.typ <= 297000000; + int max_clock = 297000000; + + if(IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2)) + max_clock = 594000; + + return timing->pixelclock.typ <= max_clock; } static int sunxi_dw_hdmi_enable(struct udevice *dev, int panel_bpp, @@ -348,7 +388,19 @@ static int sunxi_dw_hdmi_probe(struct udevice *dev) regulator_set_enable(priv->hvcc, true); #if IS_ENABLED(CONFIG_SUN50I_GEN_H6) || IS_ENABLED(CONFIG_SUNXI_GEN_NCAT2) - panic("initializing HDMI not implemented"); + int hdmi_src = CCM_HDMI_CTRL_VIDEO0_4X_H616; + + /* Set HDMI PLL to 297 MHz */ + if (IS_ENABLED(CONFIG_MACH_SUN50I_H6)) { + hdmi_src = CCM_HDMI_CTRL_VIDEO1_4X_H6; + clock_set_video1(297000000); + } else { + clock_set_pll3(297000000); + } + + writel(hdmi_src | CCM_HDMI_CTRL_ENABLE, &ccm->hdmi_clk_cfg); + setbits_le32(&ccm->hdmi_gate_reset, BIT(RESET_SHIFT)); + setbits_le32(&ccm->hdmi_gate_reset, BIT(GATE_SHIFT)); #else /* Set pll3 to 297 MHz */ clock_set_pll3(297000000);