From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60C3B428841 for ; Thu, 30 Apr 2026 13:58:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777557529; cv=none; b=f1XLjP0/hKdg7P8E8PCc2NxmMlg2Xcpde5iVsssLssDFjYfmCdi5ox2bUz7gnKQHgJUusHfbgv0lHq7rVItj+qqWesK9THhUYvRLsIyqksv3sxirjSGcbqukzg7wQ8i+O/8sKl5iAUO/cbKGPBy+OL06YmNTHnP6K/T9WOCPmnU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777557529; c=relaxed/simple; bh=drWJpcSE0TJcdgZ7vlQSxAWArtbiJCMXBwRn1bvPmw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J/a+kp3fw1GRLQyxeCl5XbZ1tGWsUzU/DzMOMbWgOHx+19F8f7RbEwEQZaQAiAQvZCeLs5U8mCzMApy1x1JiY19TFuujcAwcWCXcCkOj7g+XfZHhUuupw0T81OQmNpai3aZXLFIj7XtiWv1LF8sxcRELKZfQQq5CYdk7YJvpvDY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=iKBHjy6J; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="iKBHjy6J" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 50BD632C5; Thu, 30 Apr 2026 06:58:41 -0700 (PDT) Received: from e142021.fritz.box (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A820E3F7B4; Thu, 30 Apr 2026 06:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1777557526; bh=drWJpcSE0TJcdgZ7vlQSxAWArtbiJCMXBwRn1bvPmw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iKBHjy6JZRmicJsCA62Twj3XuO1tTyKwIqbE4Z6vTZ/n2JfeI6P/Doa5znWhhXeGQ MxvcF2wX7aYyAaZiQxBX93gDpLpXjjEvRAAREle85SnVrqdYyqKHEGXsWDze8+/Xfi unBKwiimiweyqsyVlwqEl2Wc66EWofDHtiOwFPZ8= From: Andre Przywara To: Paul Kocialkowski , u-boot@lists.denx.de Cc: Jernej Skrabec , Chen-Yu Tsai , linux-sunxi@lists.linux.dev Subject: [PATCH v2 2/2] sunxi: A133: dram: Add NSI arbiter configuration support Date: Thu, 30 Apr 2026 15:58:38 +0200 Message-ID: <20260430135838.3438728-3-andre.przywara@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260430135838.3438728-1-andre.przywara@arm.com> References: <20260430135838.3438728-1-andre.przywara@arm.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Paul Kocialkowski The Allwinner DRAM controllers contains logic to assign priorities to various DRAM DMA masters. Configuring this DRAM port arbitration priority correctly is important to make sure that critical masters are not starved by other less important ones. This is especially the case with the display engine that needs to be able to fetch pixels in time for scanout and can easily be starved by CPU or GPU access. Add support for configuring the NSI arbiter in the A133 DRAM init code, using the recently refactored NSI code already used on the A523. The list and order of available ports are highly SoC-specific and the default config values are set to match the BSP's defaults. Signed-off-by: Paul Kocialkowski [Andre: using new generic NSI function] Signed-off-by: Andre Przywara Sponsored-by: MEC Electronics GmbH --- .../include/asm/arch-sunxi/cpu_sun50i_h6.h | 4 ++ .../include/asm/arch-sunxi/dram_sun50i_a133.h | 23 ++++++++++ arch/arm/mach-sunxi/Makefile | 2 +- arch/arm/mach-sunxi/dram_sun50i_a133.c | 43 ++++++++++++++++++- 4 files changed, 70 insertions(+), 2 deletions(-) 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 b0f2d3f4656..c31437f9acc 100644 --- a/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h +++ b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h @@ -17,6 +17,10 @@ #define SUNXI_GIC400_BASE 0x03020000 +#ifdef CONFIG_MACH_SUN50I_A133 +#define SUNXI_NSI_BASE 0x03100000 +#endif + #ifdef CONFIG_MACH_SUN50I_H6 #define SUNXI_DRAM_COM_BASE 0x04002000 #define SUNXI_DRAM_CTL0_BASE 0x04003000 diff --git a/arch/arm/include/asm/arch-sunxi/dram_sun50i_a133.h b/arch/arm/include/asm/arch-sunxi/dram_sun50i_a133.h index 01f2214cd15..1e8e0f7ab96 100644 --- a/arch/arm/include/asm/arch-sunxi/dram_sun50i_a133.h +++ b/arch/arm/include/asm/arch-sunxi/dram_sun50i_a133.h @@ -24,6 +24,29 @@ static inline int ns_to_t(int nanoseconds) return DIV_ROUND_UP(ctrl_freq * nanoseconds, 1000); } +enum sunxi_nsi_port { + SUNXI_NSI_PORT_CPU = 0, + SUNXI_NSI_PORT_GPU, + SUNXI_NSI_PORT_SD1, + SUNXI_NSI_PORT_MSTG, + SUNXI_NSI_PORT_GMAC0, + SUNXI_NSI_PORT_GMAC1, + SUNXI_NSI_PORT_USB0, + SUNXI_NSI_PORT_USB1, + SUNXI_NSI_PORT_NDFC, + SUNXI_NSI_PORT_DMAC, + SUNXI_NSI_PORT_CE, + SUNXI_NSI_PORT_DE0, + SUNXI_NSI_PORT_DE1, + SUNXI_NSI_PORT_VE, + SUNXI_NSI_PORT_CSI, + SUNXI_NSI_PORT_ISP, + SUNXI_NSI_PORT_G2D, + SUNXI_NSI_PORT_EINK, + SUNXI_NSI_PORT_IOMMU, + SUNXI_NSI_PORT_CPUS, +}; + /* MBUS part is largely the same as in H6, except for one special register */ #define MCTL_COM_UNK_008 0x008 /* NOTE: This register has the same importance as mctl_ctl->clken in H616 */ diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile index 3ef0113ea43..30cce7d1784 100644 --- a/arch/arm/mach-sunxi/Makefile +++ b/arch/arm/mach-sunxi/Makefile @@ -48,7 +48,7 @@ obj-$(CONFIG_DRAM_SUN50I_H6) += dram_sun50i_h6.o dram_dw_helpers.o obj-$(CONFIG_DRAM_SUN50I_H6) += dram_timings/ obj-$(CONFIG_DRAM_SUN50I_H616) += dram_sun50i_h616.o dram_dw_helpers.o obj-$(CONFIG_DRAM_SUN50I_H616) += dram_timings/ -obj-$(CONFIG_DRAM_SUN50I_A133) += dram_sun50i_a133.o +obj-$(CONFIG_DRAM_SUN50I_A133) += dram_sun50i_a133.o sunxi_nsi.o obj-$(CONFIG_DRAM_SUN50I_A133) += dram_timings/ obj-$(CONFIG_MACH_SUN55I_A523) += dram_sun55i_a523.o dram_dw_helpers.o sunxi_nsi.o obj-$(CONFIG_DRAM_SUN55I_A523) += dram_timings/ diff --git a/arch/arm/mach-sunxi/dram_sun50i_a133.c b/arch/arm/mach-sunxi/dram_sun50i_a133.c index ca3e2513c69..433044e1e2b 100644 --- a/arch/arm/mach-sunxi/dram_sun50i_a133.c +++ b/arch/arm/mach-sunxi/dram_sun50i_a133.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -69,6 +70,41 @@ static const u8 phy_init[] = { }; #endif +static void nsi_set_master_priority(void) +{ + struct { + unsigned int port; + u8 pri; + u8 qos_sel; + } ports[] = { + NSI_CONF(CPU, LOWEST, INPUT), + NSI_CONF(GPU, LOWEST, INPUT), + NSI_CONF(SD1, LOWEST, OUTPUT), + NSI_CONF(MSTG, LOWEST, OUTPUT), + NSI_CONF(GMAC0, LOWEST, OUTPUT), + NSI_CONF(GMAC1, LOWEST, OUTPUT), + NSI_CONF(USB0, LOWEST, OUTPUT), + NSI_CONF(USB1, LOWEST, OUTPUT), + NSI_CONF(NDFC, LOWEST, OUTPUT), + NSI_CONF(DMAC, LOWEST, OUTPUT), + NSI_CONF(CE, LOWEST, OUTPUT), + NSI_CONF(DE0, HIGH, INPUT), + NSI_CONF(DE1, HIGH, INPUT), + NSI_CONF(VE, LOWEST, INPUT), + NSI_CONF(CSI, HIGH, INPUT), + NSI_CONF(ISP, HIGH, INPUT), + NSI_CONF(G2D, LOWEST, INPUT), + NSI_CONF(EINK, LOWEST, OUTPUT), + NSI_CONF(IOMMU, HIGHEST, INPUT), + NSI_CONF(CPUS, LOWEST, OUTPUT), + }; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(ports); i++) + nsi_configure_port(ports[i].port, ports[i].pri, + ports[i].qos_sel); +} + static void mctl_clk_init(u32 clk) { void * const ccm = (void *)SUNXI_CCM_BASE; @@ -1205,6 +1241,7 @@ static const struct dram_para para = { unsigned long sunxi_dram_init(void) { struct dram_config config; + unsigned long size; /* Writing to undocumented SYS_CFG area, according to user manual. */ setbits_le32(0x03000160, BIT(8)); @@ -1221,5 +1258,9 @@ unsigned long sunxi_dram_init(void) 1U << config.bankgrps, 1U << config.ranks, 16U << config.bus_full_width); - return calculate_dram_size(&config); + size = calculate_dram_size(&config); + + nsi_set_master_priority(); + + return size; } -- 2.43.0