From: Stefan Wahren <stefan.wahren@i2se.com> To: Vinod Koul <vkoul@kernel.org>, Rob Herring <robh+dt@kernel.org>, Florian Fainelli <f.fainelli@gmail.com>, Nicolas Saenz Julienne <nsaenz@kernel.org> Cc: Ray Jui <rjui@broadcom.com>, Scott Branden <sbranden@broadcom.com>, bcm-kernel-feedback-list@broadcom.com, dmaengine@vger.kernel.org, Phil Elwell <phil@raspberrypi.com>, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lukas Wunner <lukas@wunner.de>, linux-rpi-kernel@lists.infradead.org, Stefan Wahren <stefan.wahren@i2se.com> Subject: [PATCH RFC 06/11] dmaengine: bcm2835: make address increment platform independent Date: Mon, 27 Dec 2021 13:05:40 +0100 [thread overview] Message-ID: <1640606743-10993-7-git-send-email-stefan.wahren@i2se.com> (raw) In-Reply-To: <1640606743-10993-1-git-send-email-stefan.wahren@i2se.com> Actually the criteria to increment source & destination address doesn't based on platform specific bits. It's just the DMA transfer direction which is translated into the info bits. So introduce two new helper functions and get the rid of these platform specifics. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> --- drivers/dma/bcm2835-dma.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 863792e..a7b9f88 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -253,6 +253,24 @@ static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, return result; } +static inline bool need_src_incr(enum dma_transfer_direction direction) +{ + return direction != DMA_DEV_TO_MEM; +} + +static inline bool need_dst_incr(enum dma_transfer_direction direction) +{ + switch (direction) { + case DMA_MEM_TO_MEM: + case DMA_DEV_TO_MEM: + return true; + default: + break; + } + + return false; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -337,10 +355,8 @@ static inline size_t bcm2835_dma_count_frames_for_sg( * @cyclic: it is a cyclic transfer * @info: the default info bits to apply per controlblock * @frames: number of controlblocks to allocate - * @src: the src address to assign (if the S_INC bit is set - * in @info, then it gets incremented) - * @dst: the dst address to assign (if the D_INC bit is set - * in @info, then it gets incremented) + * @src: the src address to assign + * @dst: the dst address to assign * @buf_len: the full buffer length (may also be 0) * @period_len: the period length when to apply @finalextrainfo * in addition to the last transfer @@ -409,9 +425,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( d->cb_list[frame - 1].cb->next = cb_entry->paddr; /* update src and dst and length */ - if (src && (info & BCM2835_DMA_S_INC)) + if (src && need_src_incr(direction)) src += control_block->length; - if (dst && (info & BCM2835_DMA_D_INC)) + if (dst && need_dst_incr(direction)) dst += control_block->length; /* Length of total transfer */ -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: Stefan Wahren <stefan.wahren@i2se.com> To: Vinod Koul <vkoul@kernel.org>, Rob Herring <robh+dt@kernel.org>, Florian Fainelli <f.fainelli@gmail.com>, Nicolas Saenz Julienne <nsaenz@kernel.org> Cc: Ray Jui <rjui@broadcom.com>, Scott Branden <sbranden@broadcom.com>, bcm-kernel-feedback-list@broadcom.com, dmaengine@vger.kernel.org, Phil Elwell <phil@raspberrypi.com>, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lukas Wunner <lukas@wunner.de>, linux-rpi-kernel@lists.infradead.org, Stefan Wahren <stefan.wahren@i2se.com> Subject: [PATCH RFC 06/11] dmaengine: bcm2835: make address increment platform independent Date: Mon, 27 Dec 2021 13:05:40 +0100 [thread overview] Message-ID: <1640606743-10993-7-git-send-email-stefan.wahren@i2se.com> (raw) In-Reply-To: <1640606743-10993-1-git-send-email-stefan.wahren@i2se.com> Actually the criteria to increment source & destination address doesn't based on platform specific bits. It's just the DMA transfer direction which is translated into the info bits. So introduce two new helper functions and get the rid of these platform specifics. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> --- drivers/dma/bcm2835-dma.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 863792e..a7b9f88 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -253,6 +253,24 @@ static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, return result; } +static inline bool need_src_incr(enum dma_transfer_direction direction) +{ + return direction != DMA_DEV_TO_MEM; +} + +static inline bool need_dst_incr(enum dma_transfer_direction direction) +{ + switch (direction) { + case DMA_MEM_TO_MEM: + case DMA_DEV_TO_MEM: + return true; + default: + break; + } + + return false; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -337,10 +355,8 @@ static inline size_t bcm2835_dma_count_frames_for_sg( * @cyclic: it is a cyclic transfer * @info: the default info bits to apply per controlblock * @frames: number of controlblocks to allocate - * @src: the src address to assign (if the S_INC bit is set - * in @info, then it gets incremented) - * @dst: the dst address to assign (if the D_INC bit is set - * in @info, then it gets incremented) + * @src: the src address to assign + * @dst: the dst address to assign * @buf_len: the full buffer length (may also be 0) * @period_len: the period length when to apply @finalextrainfo * in addition to the last transfer @@ -409,9 +425,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( d->cb_list[frame - 1].cb->next = cb_entry->paddr; /* update src and dst and length */ - if (src && (info & BCM2835_DMA_S_INC)) + if (src && need_src_incr(direction)) src += control_block->length; - if (dst && (info & BCM2835_DMA_D_INC)) + if (dst && need_dst_incr(direction)) dst += control_block->length; /* Length of total transfer */ -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-12-27 12:06 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-27 12:05 [PATCH RFC 00/11] dmaengine: bcm2835: add BCM2711 40-bit DMA support Stefan Wahren 2021-12-27 12:05 ` Stefan Wahren 2021-12-27 12:05 ` [PATCH RFC 01/11] ARM: dts: bcm283x: Update DMA node name per DT schema Stefan Wahren 2021-12-27 12:05 ` Stefan Wahren 2021-12-27 12:05 ` [PATCH RFC 02/11] dt-bindings: dma: Convert brcm,bcm2835-dma to json-schema Stefan Wahren 2021-12-27 12:05 ` [PATCH RFC 02/11] dt-bindings: dma: Convert brcm, bcm2835-dma " Stefan Wahren 2022-01-04 22:50 ` [PATCH RFC 02/11] dt-bindings: dma: Convert brcm,bcm2835-dma " Rob Herring 2022-01-04 22:50 ` Rob Herring 2021-12-27 12:05 ` [PATCH RFC 03/11] dmaengine: bcm2835: Support common dma-channel-mask Stefan Wahren 2021-12-27 12:05 ` Stefan Wahren 2021-12-27 12:05 ` [PATCH RFC 04/11] dmaengine: bcm2835: move CB info generation into separate function Stefan Wahren 2021-12-27 12:05 ` Stefan Wahren 2021-12-27 12:05 ` [PATCH RFC 05/11] dmaengine: bcm2835: move CB final extra info generation into function Stefan Wahren 2021-12-27 12:05 ` Stefan Wahren 2021-12-27 12:05 ` Stefan Wahren [this message] 2021-12-27 12:05 ` [PATCH RFC 06/11] dmaengine: bcm2835: make address increment platform independent Stefan Wahren 2021-12-27 12:05 ` [PATCH RFC 07/11] dmaengine: bcm2385: drop info parameters Stefan Wahren 2021-12-27 12:05 ` Stefan Wahren 2021-12-27 12:05 ` [PATCH RFC 08/11] dmaengine: bcm2835: pass dma_chan to generic functions Stefan Wahren 2021-12-27 12:05 ` Stefan Wahren 2021-12-27 12:05 ` [PATCH RFC 09/11] dmaengine: bcm2835: introduce multi platform support Stefan Wahren 2021-12-27 12:05 ` Stefan Wahren 2022-01-23 14:08 ` [PATCH RFC 00/11] dmaengine: bcm2835: add BCM2711 40-bit DMA support Stefan Wahren 2022-01-23 14:08 ` Stefan Wahren 2022-02-15 11:20 ` Vinod Koul 2022-02-15 11:20 ` Vinod Koul 2023-06-18 19:43 ` Shengyu Qu 2023-06-18 19:43 ` Shengyu Qu 2023-06-18 21:14 ` Stefan Wahren 2023-06-18 21:14 ` Stefan Wahren
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1640606743-10993-7-git-send-email-stefan.wahren@i2se.com \ --to=stefan.wahren@i2se.com \ --cc=bcm-kernel-feedback-list@broadcom.com \ --cc=devicetree@vger.kernel.org \ --cc=dmaengine@vger.kernel.org \ --cc=f.fainelli@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-rpi-kernel@lists.infradead.org \ --cc=lukas@wunner.de \ --cc=nsaenz@kernel.org \ --cc=phil@raspberrypi.com \ --cc=rjui@broadcom.com \ --cc=robh+dt@kernel.org \ --cc=sbranden@broadcom.com \ --cc=vkoul@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.