From: Renaud Barbier <renaud.barbier@abaco.com> To: barebox@lists.infradead.org Cc: Renaud Barbier <renaud.barbier@abaco.com> Subject: [PATCH 2/4] arm: 64-bit device specific operation Date: Wed, 28 Jul 2021 13:47:06 +0100 Message-ID: <1627476428-16318-3-git-send-email-renaud.barbier@abaco.com> (raw) In-Reply-To: <1627476428-16318-1-git-send-email-renaud.barbier@abaco.com> In preparation for the introduction of the NXP FSL IFC nand driver, add memcpy_ directional I/O operation. Code based on NXP Linux support: git://source.codeaurora.org/external/qoriq/qoriq-components/linux Signed-off-by: Renaud Barbier <renaud.barbier@abaco.com> --- arch/arm/lib64/Makefile | 2 +- arch/arm/lib64/io.c | 98 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 arch/arm/lib64/io.c diff --git a/arch/arm/lib64/Makefile b/arch/arm/lib64/Makefile index 69cb3d8ea1..591727c160 100644 --- a/arch/arm/lib64/Makefile +++ b/arch/arm/lib64/Makefile @@ -1,4 +1,4 @@ -obj-y += stacktrace.o +obj-y += stacktrace.o io.o obj-$(CONFIG_ARM_LINUX) += armlinux.o obj-y += div0.o obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS) += memcpy.o diff --git a/arch/arm/lib64/io.c b/arch/arm/lib64/io.c new file mode 100644 index 0000000000..693cda42b0 --- /dev/null +++ b/arch/arm/lib64/io.c @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Based on arch/arm/kernel/io.c + * + * Copyright (C) 2012 ARM Ltd. + */ + +#include <module.h> +#include <linux/kernel.h> +#include <linux/types.h> +#include <io.h> + +/* + * Copy data from IO memory space to "real" memory space. + */ +void memcpy_fromio(void *to, const volatile void __iomem *from, size_t count) +{ + while (count && !IS_ALIGNED((unsigned long)from, 8)) { + *(u8 *)to = __raw_readb(from); + from++; + to++; + count--; + } + + while (count >= 8) { + *(u64 *)to = __raw_readq(from); + from += 8; + to += 8; + count -= 8; + } + + while (count) { + *(u8 *)to = __raw_readb(from); + from++; + to++; + count--; + } +} +EXPORT_SYMBOL(memcpy_fromio); + +/* + * Copy data from "real" memory space to IO memory space. + */ +void memcpy_toio(volatile void __iomem *to, const void *from, size_t count) +{ + while (count && !IS_ALIGNED((unsigned long)to, 8)) { + __raw_writeb(*(u8 *)from, to); + from++; + to++; + count--; + } + + while (count >= 8) { + __raw_writeq(*(u64 *)from, to); + from += 8; + to += 8; + count -= 8; + } + + while (count) { + __raw_writeb(*(u8 *)from, to); + from++; + to++; + count--; + } +} +EXPORT_SYMBOL(memcpy_toio); + +/* + * "memset" on IO memory space. + */ +void memset_io(volatile void __iomem *dst, int c, size_t count) +{ + u64 qc = (u8)c; + + qc |= qc << 8; + qc |= qc << 16; + qc |= qc << 32; + + while (count && !IS_ALIGNED((unsigned long)dst, 8)) { + __raw_writeb(c, dst); + dst++; + count--; + } + + while (count >= 8) { + __raw_writeq(qc, dst); + dst += 8; + count -= 8; + } + + while (count) { + __raw_writeb(c, dst); + dst++; + count--; + } +} +EXPORT_SYMBOL(memset_io); -- 2.27.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-07-28 12:49 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-28 12:47 [PATCH 0/4] NXP IFC nand driver Renaud Barbier 2021-07-28 12:47 ` [PATCH 1/4] ARM: atomic.h: add 64-bit counter support Renaud Barbier 2021-07-29 9:58 ` Ahmad Fatoum 2021-07-28 12:47 ` Renaud Barbier [this message] 2021-07-29 10:00 ` [PATCH 2/4] arm: 64-bit device specific operation Ahmad Fatoum 2021-07-28 12:47 ` [PATCH 3/4] nand: add NXP IFC nand driver Renaud Barbier 2021-07-29 10:11 ` Ahmad Fatoum 2021-07-28 12:47 ` [PATCH 4/4] ls1046ardb: enable IFC NAND Renaud Barbier 2021-07-29 10:13 ` Ahmad Fatoum 2021-07-29 18:19 ` Barbier, Renaud
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=1627476428-16318-3-git-send-email-renaud.barbier@abaco.com \ --to=renaud.barbier@abaco.com \ --cc=barebox@lists.infradead.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: link
mail archive of the barebox mailing list This inbox may be cloned and mirrored by anyone: git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \ barebox@lists.infradead.org barebox@lists.infradead.org public-inbox-index barebox Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git