lkml.org 
[lkml]   [2012]   [Aug]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v2 13/31] arm64: Device specific operations
    On Tue, Aug 14, 2012 at 06:52:14PM +0100, Catalin Marinas wrote:
    > This patch adds several definitions for device communication, including
    > I/O accessors and ioremap(). The __raw_* accessors are implemented as
    > inline asm to avoid compiler generation of post-indexed accesses (less
    > efficient to emulate in a virtualised environment).
    >
    > Signed-off-by: Will Deacon <will.deacon@arm.com>
    > Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    > ---
    > arch/arm64/include/asm/device.h | 26 ++++
    > arch/arm64/include/asm/fb.h | 34 +++++
    > arch/arm64/include/asm/io.h | 263 +++++++++++++++++++++++++++++++++++++++
    > arch/arm64/kernel/io.c | 64 ++++++++++
    > arch/arm64/mm/ioremap.c | 84 +++++++++++++
    > 5 files changed, 471 insertions(+), 0 deletions(-)
    > create mode 100644 arch/arm64/include/asm/device.h
    > create mode 100644 arch/arm64/include/asm/fb.h
    > create mode 100644 arch/arm64/include/asm/io.h
    > create mode 100644 arch/arm64/kernel/io.c
    > create mode 100644 arch/arm64/mm/ioremap.c
    >
    > diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
    > new file mode 100644
    > index 0000000..48fa83f
    > --- /dev/null
    > +++ b/arch/arm64/include/asm/io.h

    [...]

    > +/*
    > + * I/O port access primitives.
    > + */
    > +#define IO_SPACE_LIMIT 0xffff
    > +
    > +/*
    > + * We currently don't have any platform with PCI support, so just leave this
    > + * defined to 0 until needed.
    > + */
    > +#define PCI_IOBASE ((void __iomem *)0)

    You could just leave out the PCI / I/O code alltogether instead.

    > diff --git a/arch/arm64/kernel/io.c b/arch/arm64/kernel/io.c
    > new file mode 100644
    > index 0000000..7d37ead
    > --- /dev/null
    > +++ b/arch/arm64/kernel/io.c
    > @@ -0,0 +1,64 @@
    > +/*
    > + * Based on arch/arm/kernel/io.c
    > + *
    > + * Copyright (C) 2012 ARM Ltd.
    > + *
    > + * This program is free software; you can redistribute it and/or modify
    > + * it under the terms of the GNU General Public License version 2 as
    > + * published by the Free Software Foundation.
    > + *
    > + * This program is distributed in the hope that it will be useful,
    > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    > + * GNU General Public License for more details.
    > + *
    > + * You should have received a copy of the GNU General Public License
    > + * along with this program. If not, see <http://www.gnu.org/licenses/>.
    > + */
    > +
    > +#include <linux/export.h>
    > +#include <linux/types.h>
    > +#include <linux/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)
    > +{
    > + unsigned char *t = to;
    > + while (count) {
    > + count--;
    > + *t = readb(from);
    > + t++;
    > + from++;
    > + }
    > +}
    > +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)
    > +{
    > + const unsigned char *f = from;
    > + while (count) {
    > + count--;
    > + writeb(*f, to);
    > + f++;
    > + to++;
    > + }
    > +}
    > +EXPORT_SYMBOL(__memcpy_toio);
    > +
    > +/*
    > + * "memset" on IO memory space.
    > + */
    > +void __memset_io(volatile void __iomem *dst, int c, size_t count)
    > +{
    > + while (count) {
    > + count--;
    > + writeb(c, dst);
    > + dst++;
    > + }
    > +}
    > +EXPORT_SYMBOL(__memset_io);

    Doing all of the above a byte at a time is horribly inefficient. Feel
    free to borrow the implementations from arch/powerpc/kernel/io.c instead
    of from ARM.


    -Olof


    \
     
     \ /
      Last update: 2012-08-15 03:23    [W:4.100 / U:0.044 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site