From nobody Wed Oct 8 09:08:32 2025 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF37B25B1C4 for ; Tue, 1 Jul 2025 05:38:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751348288; cv=none; b=MXnZEhB9u8jR1nfzETF00C+/8Iianl8phwqTqFPZp6arMxhyT5eOl3GN4Q1LezHTdwId8tHJpX4XABTPPiyl2STBYWhJXEROnuhFssI481rKbqmW07ME7NlFc1RMVhBjLAFHnsJ88Aq3krK/5tsRFZieZ0JvbsN/l1E4u/WxsVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751348288; c=relaxed/simple; bh=PVPZP+CgMQOSQFDrWY9YLaa+sOJ+Qf3rIysRroeBU2c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gmShqfERs086B/O1abstuFl90TUbT1V8oqOSVnWJcyO6xpzkZ0EVFXmxE2xJWMmEf2k5A3hR+fho+SS67stDcIvk3v8k4dUIUuNuCC6TimGREuvoEPyNHcmJhuSUgbBs1kPE+aeQARDRDDJY7M+14yN4JQ/qXYxXBQtPPYrP0sY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b=jlT/Fq2g; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b="jlT/Fq2g" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-23649faf69fso24617445ad.0 for ; Mon, 30 Jun 2025 22:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1751348286; x=1751953086; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wP+bs12WPQGGhABQZ+X8E9Vcd5L9CBDvEsXIkM7mq9I=; b=jlT/Fq2gBDZu72duv2bsydVUIpoTM7QlpJZeN2egGHsw1Q2rqi8FAHR2J0GvyPj04f Ywd/ZiUP8nxb3dsZhoqp42u8ZEXJH32ZUzxfMs/+PikIXoSn0N3LJKQwwcvRRMkBG+xp fGzBa/gMQQ9CTRgsuY1xX/CiY0YQUh4DJBHdEmyoMBqbsi6qu07AxlFB2S738cDVsop1 M9RTroJsdsoz6FQR60i5nX3JGrh3GlinDaWRuPHKFacUl0olFdeBmGyMFjUzaUf40yuD rG/F9mebcCP7mUXzAsnfjBvTvBqY8hYwUvVA5EjGUsJxza0GUOijEYBpwUv/uhZgCFB0 Eetw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751348286; x=1751953086; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wP+bs12WPQGGhABQZ+X8E9Vcd5L9CBDvEsXIkM7mq9I=; b=s8q3UH9EeuR9chMHCbi7g49B13c5OXeqR0jezWSDgNg1IpE27yxzvoyC1MESr2Cd3M gPKOBXmBa5P6R8PelrlMvkOM9tpWyGULjhcCLLk1odGft8lOFZJ/rAmyV5DLJQ3sqV5d yhtmF0gjzkzc1kl9GwFJVulNPggKsG3Ajyj87/wRSQ12nLwIWUrLQVlPCIruAkV/StNs cTyQtmKEx9MYAi9Y5wP2b6yZNOv1JqwJ+/KhKUTJwnSXaDFQ5NMP+ClXgzkHdT2X/+MM YDbKVnxXgkaXn1A+4J7k7US30IMjzgkbGaqWWNKie/dmxNGIROkgej5WYNrTWcldKtzb wOKg== X-Forwarded-Encrypted: i=1; AJvYcCV3bfPI0NFVDN5yJ+B5CEsGQQDRUwprLkmfvyqFJec9MWncU1V2A0QsBRoBh3MH6Jz1qmi1j0spnOzAbZE=@vger.kernel.org X-Gm-Message-State: AOJu0YzrFncogaYcckiN17u82sCs80AMxrzHFnZ2Igfqd9htfXWYRb/d rbzPgxmyRm1gKHqnpA1prdUuHaQrL4SlaJCrlzI7zQdd8YgHoUlyTL1ITBflaCnJsWJdqwvQt8R xAHGmLBGcdfh0 X-Gm-Gg: ASbGncvi40PY6hjfM16dzepVL8QS+PFKTLjl5HupG5u4Aj8D+5n7oLS0LhLAtFFfbn9 Xd3FZxRgqToMZOd3Ey3fCKo9DksfGnJcQHKoLixMT8uggHOS8BtRd9vVRy2IVrVMCXoHq4VYcWQ naTReZCrKZF7rQJvw3ZkbHZOB3aRSNTU93TtGOwqm9vJaGvjHNDsKOYpAPQmX9j1oXW6CIaSXX4 v5jUbfHEtnTrkOT1rKcoFhx+vXGW/uM+kriLe2uc5A0Zp0Fb4/nMG8vRWD4ivoYvf/Mc/9IX0lX KXhlHOJBpfbIfMEGSqZavdDn2X3SVyt51n7JHBw= X-Google-Smtp-Source: AGHT+IFe39WxG7MjcagikZuLoLSdffzZtEZTBFHBReoxkncYLGlt+gZhfeTycrw62ngjpKipmHBK+Q== X-Received: by 2002:a17:902:da84:b0:234:e0c3:8406 with SMTP id d9443c01a7336-23ac3dec308mr244800885ad.1.1751348286102; Mon, 30 Jun 2025 22:38:06 -0700 (PDT) Received: from [127.0.1.1] ([2403:2c80:6::3092]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23acb39bf5fsm101729865ad.115.2025.06.30.22.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jun 2025 22:38:05 -0700 (PDT) From: Guodong Xu Date: Tue, 01 Jul 2025 13:36:59 +0800 Subject: [PATCH v2 5/8] dmaengine: mmp_pdma: Add SpacemiT K1 PDMA support with 64-bit addressing Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250701-working_dma_0701_v2-v2-5-ab6ee9171d26@riscstar.com> References: <20250701-working_dma_0701_v2-v2-0-ab6ee9171d26@riscstar.com> In-Reply-To: <20250701-working_dma_0701_v2-v2-0-ab6ee9171d26@riscstar.com> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Yixun Lan , =?utf-8?q?Duje_Mihanovi=C4=87?= , Philipp Zabel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti Cc: Alex Elder , Vivian Wang , dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, Guodong Xu X-Mailer: b4 0.14.2 Add support for SpacemiT K1 PDMA controller which features 64-bit addressing capabilities. The SpacemiT K1 PDMA extends the descriptor format with additional 32-bit words for high address bits, enabling access to memory beyond 4GB boundaries. The new spacemit_k1_pdma_ops provides necessary 64-bit address handling functions and k1 specific controller configurations. Key changes: - Add ARCH_SPACEMIT dependency to Kconfig - Define new high 32-bit address registers (DDADRH, DSADRH, DTADRH) - Add DCSR_LPAEEN bit for Long Physical Address Extension Enable - Implement 64-bit operations for SpacemiT K1 PDMA Signed-off-by: Guodong Xu --- v2: New patch. - Implement 64-bit addrssing support to mmp_pdma - Add support for SpacemiT K1 PDMA - Extend the MMP_PDMA entry in Kconfig to depend on ARCH_SPACEMIT --- drivers/dma/Kconfig | 2 +- drivers/dma/mmp_pdma.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index db87dd2a07f7606e40dc26ea41d26fcdd1fad979..fff70f66c773934efb2fcafdc36= 28ba06c734640 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -451,7 +451,7 @@ config MILBEAUT_XDMAC =20 config MMP_PDMA tristate "MMP PDMA support" - depends on ARCH_MMP || ARCH_PXA || COMPILE_TEST + depends on ARCH_MMP || ARCH_PXA || ARCH_SPACEMIT || COMPILE_TEST select DMA_ENGINE help Support the MMP PDMA engine for PXA and MMP platform. diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c index 610df28f429783779c1c143a13b3a829e42cf003..28c03d05e0b2708fcb8faffeeb9= 7b97ed6fcbdc5 100644 --- a/drivers/dma/mmp_pdma.c +++ b/drivers/dma/mmp_pdma.c @@ -28,6 +28,9 @@ #define DDADR(n) (0x0200 + ((n) << 4)) #define DSADR(n) (0x0204 + ((n) << 4)) #define DTADR(n) (0x0208 + ((n) << 4)) +#define DDADRH(n) (0x0300 + ((n) << 4)) +#define DSADRH(n) (0x0304 + ((n) << 4)) +#define DTADRH(n) (0x0308 + ((n) << 4)) #define DCMD 0x020c =20 #define DCSR_RUN BIT(31) /* Run Bit (read / write) */ @@ -44,6 +47,7 @@ #define DCSR_EORSTOPEN BIT(26) /* STOP on an EOR */ #define DCSR_SETCMPST BIT(25) /* Set Descriptor Compare Status */ #define DCSR_CLRCMPST BIT(24) /* Clear Descriptor Compare Status */ +#define DCSR_LPAEEN BIT(21) /* Long Physical Address Extension Enable */ #define DCSR_CMPST BIT(10) /* The Descriptor Compare Status */ #define DCSR_EORINTR BIT(9) /* The end of Receive */ =20 @@ -76,6 +80,16 @@ struct mmp_pdma_desc_hw { u32 dsadr; /* DSADR value for the current transfer */ u32 dtadr; /* DTADR value for the current transfer */ u32 dcmd; /* DCMD value for the current transfer */ + /* + * The following 32-bit words are only used in the 64-bit, ie. + * LPAE (Long Physical Address Extension) mode. + * They are used to specify the high 32 bits of the descriptor's + * addresses. + */ + u32 ddadrh; /* High 32-bit of DDADR */ + u32 dsadrh; /* High 32-bit of DSADR */ + u32 dtadrh; /* High 32-bit of DTADR */ + u32 rsvd; /* reserved */ } __aligned(32); =20 struct mmp_pdma_desc_sw { @@ -222,6 +236,57 @@ static u64 get_desc_dst_addr_32(const struct mmp_pdma_= desc_hw *desc) return desc->dtadr; } =20 +/* For 64-bit PDMA */ +static void write_next_addr_64(struct mmp_pdma_phy *phy, dma_addr_t addr) +{ + writel(lower_32_bits(addr), phy->base + DDADR(phy->idx)); + writel(upper_32_bits(addr), phy->base + DDADRH(phy->idx)); +} + +static u64 read_src_addr_64(struct mmp_pdma_phy *phy) +{ + u32 low =3D readl(phy->base + DSADR(phy->idx)); + u32 high =3D readl(phy->base + DSADRH(phy->idx)); + + return ((u64)high << 32) | low; +} + +static u64 read_dst_addr_64(struct mmp_pdma_phy *phy) +{ + u32 low =3D readl(phy->base + DTADR(phy->idx)); + u32 high =3D readl(phy->base + DTADRH(phy->idx)); + + return ((u64)high << 32) | low; +} + +static void set_desc_next_addr_64(struct mmp_pdma_desc_hw *desc, dma_addr_= t addr) +{ + desc->ddadr =3D lower_32_bits(addr); + desc->ddadrh =3D upper_32_bits(addr); +} + +static void set_desc_src_addr_64(struct mmp_pdma_desc_hw *desc, dma_addr_t= addr) +{ + desc->dsadr =3D lower_32_bits(addr); + desc->dsadrh =3D upper_32_bits(addr); +} + +static void set_desc_dst_addr_64(struct mmp_pdma_desc_hw *desc, dma_addr_t= addr) +{ + desc->dtadr =3D lower_32_bits(addr); + desc->dtadrh =3D upper_32_bits(addr); +} + +static u64 get_desc_src_addr_64(const struct mmp_pdma_desc_hw *desc) +{ + return ((u64)desc->dsadrh << 32) | desc->dsadr; +} + +static u64 get_desc_dst_addr_64(const struct mmp_pdma_desc_hw *desc) +{ + return ((u64)desc->dtadrh << 32) | desc->dtadr; +} + static int mmp_pdma_config_write(struct dma_chan *dchan, struct dma_slave_config *cfg, enum dma_transfer_direction direction); @@ -1110,10 +1175,26 @@ static const struct mmp_pdma_ops marvell_pdma_v1_op= s =3D { .dma_mask =3D 0, /* let OF/platform set DMA mask */ }; =20 +static const struct mmp_pdma_ops spacemit_k1_pdma_ops =3D { + .write_next_addr =3D write_next_addr_64, + .read_src_addr =3D read_src_addr_64, + .read_dst_addr =3D read_dst_addr_64, + .set_desc_next_addr =3D set_desc_next_addr_64, + .set_desc_src_addr =3D set_desc_src_addr_64, + .set_desc_dst_addr =3D set_desc_dst_addr_64, + .get_desc_src_addr =3D get_desc_src_addr_64, + .get_desc_dst_addr =3D get_desc_dst_addr_64, + .run_bits =3D (DCSR_RUN | DCSR_LPAEEN), + .dma_mask =3D DMA_BIT_MASK(64), /* force 64-bit DMA addr capability */ +}; + static const struct of_device_id mmp_pdma_dt_ids[] =3D { { .compatible =3D "marvell,pdma-1.0", .data =3D &marvell_pdma_v1_ops + }, { + .compatible =3D "spacemit,k1-pdma", + .data =3D &spacemit_k1_pdma_ops }, { /* sentinel */ } --=20 2.43.0