mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: monstr@monstr.eu
To: linux-kernel@vger.kernel.org
Cc: john.williams@petalogix.com, Michal Simek <monstr@monstr.eu>
Subject: [PATCH 35/57] microblaze_v7: io.h IO operations
Date: Wed, 18 Mar 2009 21:31:02 +0100	[thread overview]
Message-ID: <fde2defbb60d9476df3aac0dc7d87241ed247d3e.1237407249.git.monstr@monstr.eu> (raw)
In-Reply-To: <592d2a1c72581b6abf73841e640e7b7306c3ec3b.1237407249.git.monstr@monstr.eu>
In-Reply-To: <0168f03c96e9479ede695a9859c8a0691baa8ef3.1237407249.git.monstr@monstr.eu>

From: Michal Simek <monstr@monstr.eu>


Signed-off-by: Michal Simek <monstr@monstr.eu>
---
 arch/microblaze/include/asm/io.h |  209 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 209 insertions(+), 0 deletions(-)
 create mode 100644 arch/microblaze/include/asm/io.h

diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h
new file mode 100644
index 0000000..4ff514e
--- /dev/null
+++ b/arch/microblaze/include/asm/io.h
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2006 Atmark Techno, Inc.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#ifndef _ASM_MICROBLAZE_IO_H
+#define _ASM_MICROBLAZE_IO_H
+
+#include <asm/byteorder.h>
+#include <asm/page.h>
+#include <linux/types.h>
+#include <asm/page.h>
+
+#define IO_SPACE_LIMIT ~(0UL)
+
+static inline unsigned char __raw_readb(const volatile void __iomem *addr)
+{
+	return *(volatile unsigned char __force *)addr;
+}
+static inline unsigned short __raw_readw(const volatile void __iomem *addr)
+{
+	return *(volatile unsigned short __force *)addr;
+}
+static inline unsigned int __raw_readl(const volatile void __iomem *addr)
+{
+	return *(volatile unsigned int __force *)addr;
+}
+static inline unsigned long __raw_readq(const volatile void __iomem *addr)
+{
+	return *(volatile unsigned long __force *)addr;
+}
+static inline void __raw_writeb(unsigned char v, volatile void __iomem *addr)
+{
+	*(volatile unsigned char __force *)addr = v;
+}
+static inline void __raw_writew(unsigned short v, volatile void __iomem *addr)
+{
+	*(volatile unsigned short __force *)addr = v;
+}
+static inline void __raw_writel(unsigned int v, volatile void __iomem *addr)
+{
+	*(volatile unsigned int __force *)addr = v;
+}
+static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
+{
+	*(volatile unsigned long __force *)addr = v;
+}
+
+/*
+ * read (readb, readw, readl, readq) and write (writeb, writew,
+ * writel, writeq) accessors are for PCI and thus littel endian.
+ * Linux 2.4 for Microblaze had this wrong.
+ */
+static inline unsigned char readb(const volatile void __iomem *addr)
+{
+	return *(volatile unsigned char __force *)addr;
+}
+static inline unsigned short readw(const volatile void __iomem *addr)
+{
+	return le16_to_cpu(*(volatile unsigned short __force *)addr);
+}
+static inline unsigned int readl(const volatile void __iomem *addr)
+{
+	return le32_to_cpu(*(volatile unsigned int __force *)addr);
+}
+static inline void writeb(unsigned char v, volatile void __iomem *addr)
+{
+	*(volatile unsigned char __force *)addr = v;
+}
+static inline void writew(unsigned short v, volatile void __iomem *addr)
+{
+	*(volatile unsigned short __force *)addr = cpu_to_le16(v);
+}
+static inline void writel(unsigned int v, volatile void __iomem *addr)
+{
+	*(volatile unsigned int __force *)addr = cpu_to_le32(v);
+}
+
+/* ioread and iowrite variants. thease are for now same as __raw_
+ * variants of accessors. we might check for endianess in the feature
+ */
+#define ioread8(addr)		__raw_readb((u8 *)(addr))
+#define ioread16(addr)		__raw_readw((u16 *)(addr))
+#define ioread32(addr)		__raw_readl((u32 *)(addr))
+#define iowrite8(v, addr)	__raw_writeb((u8)(v), (u8 *)(addr))
+#define iowrite16(v, addr)	__raw_writew((u16)(v), (u16 *)(addr))
+#define iowrite32(v, addr)	__raw_writel((u32)(v), (u32 *)(addr))
+
+/* These are the definitions for the x86 IO instructions
+ * inb/inw/inl/outb/outw/outl, the "string" versions
+ * insb/insw/insl/outsb/outsw/outsl, and the "pausing" versions
+ * inb_p/inw_p/...
+ * The macros don't do byte-swapping.
+ */
+#define inb(port)		readb((u8 *)((port)))
+#define outb(val, port)		writeb((val), (u8 *)((unsigned long)(port)))
+#define inw(port)		readw((u16 *)((port)))
+#define outw(val, port)		writew((val), (u16 *)((unsigned long)(port)))
+#define inl(port)		readl((u32 *)((port)))
+#define outl(val, port)		writel((val), (u32 *)((unsigned long)(port)))
+
+#define inb_p(port)		inb((port))
+#define outb_p(val, port)	outb((val), (port))
+#define inw_p(port)		inw((port))
+#define outw_p(val, port)	outw((val), (port))
+#define inl_p(port)		inl((port))
+#define outl_p(val, port)	outl((val), (port))
+
+#define memset_io(a, b, c)	memset((void *)(a), (b), (c))
+#define memcpy_fromio(a, b, c)	memcpy((a), (void *)(b), (c))
+#define memcpy_toio(a, b, c)	memcpy((void *)(a), (b), (c))
+
+/**
+ *	virt_to_phys - map virtual addresses to physical
+ *	@address: address to remap
+ *
+ *	The returned physical address is the physical (CPU) mapping for
+ *	the memory address given. It is only valid to use this function on
+ *	addresses directly mapped or allocated via kmalloc.
+ *
+ *	This function does not give bus mappings for DMA transfers. In
+ *	almost all conceivable cases a device driver should not be using
+ *	this function
+ */
+static inline unsigned long __iomem virt_to_phys(volatile void *address)
+{
+	return __pa((unsigned long)address);
+}
+
+#define virt_to_bus virt_to_phys
+
+/**
+ *	phys_to_virt - map physical address to virtual
+ *	@address: address to remap
+ *
+ *	The returned virtual address is a current CPU mapping for
+ *	the memory address given. It is only valid to use this function on
+ *	addresses that have a kernel mapping
+ *
+ *	This function does not handle bus mappings for DMA transfers. In
+ *	almost all conceivable cases a device driver should not be using
+ *	this function
+ */
+static inline void *phys_to_virt(unsigned long address)
+{
+	return (void *)__va(address);
+}
+
+#define bus_to_virt(a) phys_to_virt(a)
+
+static inline void __iomem *__ioremap(phys_addr_t address, unsigned long size,
+			unsigned long flags)
+{
+	return (void *)address;
+}
+
+#define ioremap(physaddr, size)	((void __iomem *)(unsigned long)(physaddr))
+#define iounmap(addr)		((void)0)
+#define ioremap_nocache(physaddr, size)	ioremap(physaddr, size)
+
+/*
+ * Convert a physical pointer to a virtual kernel pointer for /dev/mem
+ * access
+ */
+#define xlate_dev_mem_ptr(p)	__va(p)
+
+/*
+ * Convert a virtual cached pointer to an uncached pointer
+ */
+#define xlate_dev_kmem_ptr(p)	p
+
+/*
+ * Big Endian
+ */
+#define out_be32(a, v) __raw_writel((v), (void __iomem __force *)(a))
+#define out_be16(a, v) __raw_writew((v), (a))
+
+#define in_be32(a) __raw_readl((const void __iomem __force *)(a))
+#define in_be16(a) __raw_readw(a)
+
+/*
+ * Little endian
+ */
+
+#define out_le32(a, v) __raw_writel(__cpu_to_le32(v), (a));
+#define out_le16(a, v) __raw_writew(__cpu_to_le16(v), (a))
+
+#define in_le32(a) __le32_to_cpu(__raw_readl(a))
+#define in_le16(a) __le16_to_cpu(__raw_readw(a))
+
+/* Byte ops */
+#define out_8(a, v) __raw_writeb((v), (a))
+#define in_8(a) __raw_readb(a)
+
+/* FIXME */
+static inline void __iomem *ioport_map(unsigned long port, unsigned int len)
+{
+	return (void __iomem *) (port);
+}
+
+static inline void ioport_unmap(void __iomem *addr)
+{
+	/* Nothing to do */
+}
+
+#endif /* _ASM_MICROBLAZE_IO_H */
-- 
1.5.5.1


  reply	other threads:[~2009-03-18 21:53 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-18 20:30 Microblaze linux support monstr
2009-03-18 20:30 ` [PATCH 01/57] microblaze_v7: Kconfig patches monstr
2009-03-18 20:30   ` [PATCH 02/57] microblaze_v7: Makefiles for Microblaze cpu monstr
2009-03-18 20:30     ` [PATCH 03/57] microblaze_v7: Cpuinfo handling monstr
2009-03-18 20:30       ` [PATCH 04/57] microblaze_v7: Open firmware files monstr
2009-03-18 20:30         ` [PATCH 05/57] microblaze_v7: Platorm bus registration monstr
2009-03-18 20:30           ` [PATCH 06/57] microblaze_v7: exception handling monstr
2009-03-18 20:30             ` [PATCH 07/57] microblaze_v7: Signal support monstr
2009-03-18 20:30               ` [PATCH 08/57] microblaze_v7: Interrupt handling, timer support, selfmod code monstr
2009-03-18 20:30                 ` [PATCH 09/57] microblaze_v7: cache support monstr
2009-03-18 20:30                   ` [PATCH 10/57] microblaze_v7: Generic dts file for platforms monstr
2009-03-18 20:30                     ` [PATCH 11/57] microblaze_v7: kernel modules support monstr
2009-03-18 20:30                       ` [PATCH 12/57] microblaze_v7: lmb include file monstr
2009-03-18 20:30                         ` [PATCH 13/57] microblaze_v7: PVR support, cpuinfo support monstr
2009-03-18 20:30                           ` [PATCH 14/57] microblaze_v7: defconfig file monstr
2009-03-18 20:30                             ` [PATCH 15/57] microblaze_v7: assembler files head.S, entry-nommu.S, syscall_table.S monstr
2009-03-18 20:30                               ` [PATCH 16/57] microblaze_v7: vmlinux.lds.S - linker script monstr
2009-03-18 20:30                                 ` [PATCH 17/57] microblaze_v7: supported function for memory - kernel/lib monstr
2009-03-18 20:30                                   ` [PATCH 18/57] microblaze_v7: checksum support monstr
2009-03-18 20:30                                     ` [PATCH 19/57] microblaze_v7: early_printk support monstr
2009-03-18 20:30                                       ` [PATCH 20/57] microblaze_v7: uaccess files monstr
2009-03-18 20:30                                         ` [PATCH 21/57] microblaze_v7: heartbeat file monstr
2009-03-18 20:30                                           ` [PATCH 22/57] microblaze_v7: setup.c, setup.h - system setting monstr
2009-03-18 20:30                                             ` [PATCH 23/57] microblaze_v7: asm-offsets monstr
2009-03-18 20:30                                               ` [PATCH 24/57] microblaze_v7: process and init task function monstr
2009-03-18 20:30                                                 ` [PATCH 25/57] microblaze_v7: delay.h, timex.h monstr
2009-03-18 20:30                                                   ` [PATCH 26/57] microblaze_v7: ptrace support monstr
2009-03-18 20:30                                                     ` [PATCH 27/57] microblaze_v7: IPC support monstr
2009-03-18 20:30                                                       ` [PATCH 28/57] microblaze_v7: traps support monstr
2009-03-18 20:30                                                         ` [PATCH 29/57] microblaze_v7: memory inicialization, MMU, TLB monstr
2009-03-18 20:30                                                           ` [PATCH 30/57] microblaze_v7: page.h, segment.h, unaligned.h monstr
2009-03-18 20:30                                                             ` [PATCH 31/57] microblaze_v7: includes SHM*, msgbuf monstr
2009-03-18 20:30                                                               ` [PATCH 32/57] microblaze_v7: bug headers files monstr
2009-03-18 20:31                                                                 ` [PATCH 33/57] microblaze_v7: definitions of types monstr
2009-03-18 20:31                                                                   ` [PATCH 34/57] microblaze_v7: ioctl support monstr
2009-03-18 20:31                                                                     ` monstr [this message]
2009-03-18 20:31                                                                       ` [PATCH 36/57] microblaze_v7: headers for executables format FLAT, ELF monstr
2009-03-18 20:31                                                                         ` [PATCH 37/57] microblaze_v7: dma support monstr
2009-03-18 20:31                                                                           ` [PATCH 38/57] microblaze_v7: headers for irq monstr
2009-03-18 20:31                                                                             ` [PATCH 39/57] microblaze_v7: atomic.h bitops.h swab.h byteorder.h monstr
2009-03-18 20:31                                                                               ` [PATCH 40/57] microblaze_v7: headers pgalloc.h pgtable.h monstr
2009-03-18 20:31                                                                                 ` [PATCH 41/57] microblaze_v7: system.h processor.h monstr
2009-03-18 20:31                                                                                   ` [PATCH 42/57] microblaze_v7: clinkage.h linkage.h sections.h kmap_types.h monstr
2009-03-18 20:31                                                                                     ` [PATCH 43/57] microblaze_v7: stats headers monstr
2009-03-18 20:31                                                                                       ` [PATCH 44/57] microblaze_v7: termbits.h termios.h monstr
2009-03-18 20:31                                                                                         ` [PATCH 45/57] microblaze_v7: sigcontext.h siginfo.h monstr
2009-03-18 20:31                                                                                           ` [PATCH 46/57] microblaze_v7: headers simple files - empty or redirect to asm-generic monstr
2009-03-18 20:31                                                                                             ` [PATCH 47/57] microblaze_v7: namei.h monstr
2009-03-18 20:31                                                                                               ` [PATCH 48/57] microblaze_v7: headers files entry.h current.h mman.h registers.h sembuf.h monstr
2009-03-18 20:31                                                                                                 ` [PATCH 49/57] microblaze_v7: device.h param.h topology.h monstr
2009-03-18 20:31                                                                                                   ` [PATCH 50/57] microblaze_v7: pool.h socket.h monstr
2009-03-18 20:31                                                                                                     ` [PATCH 51/57] microblaze_v7: fcntl.h sockios.h ucontext.h monstr
2009-03-18 20:31                                                                                                       ` [PATCH 52/57] microblaze_v7: unistd.h monstr
2009-03-18 20:31                                                                                                         ` [PATCH 53/57] microblaze_v7: string.h thread_info.h monstr
2009-03-18 20:31                                                                                                           ` [PATCH 54/57] microblaze_v7: Kbuild file monstr
2009-03-18 20:31                                                                                                             ` [PATCH 55/57] microblaze_v7: pci headers monstr
2009-03-18 20:31                                                                                                               ` [PATCH 56/57] microblaze_v7: syscalls.h monstr
2009-03-18 20:31                                                                                                                 ` [PATCH 57/57] microblaze_v7: Uartlite for Microblaze monstr
2009-03-24 16:03                                                                                                                   ` Michal Simek
2009-03-24 16:22                                                                                                                     ` John Williams
2009-03-24 16:47                                                                                                                     ` Peter Korsgaard
2009-03-23 19:37                                                                                         ` [PATCH 44/57] microblaze_v7: termbits.h termios.h Arnd Bergmann
2009-03-24 11:20                                                                                           ` Michal Simek
2009-03-24 13:57                                                                                             ` Arnd Bergmann
2009-03-24 14:06                                                                                               ` John Williams
2009-03-24 14:44                                                                                               ` Michal Simek
2009-03-19 15:49                 ` [PATCH 08/57] microblaze_v7: Interrupt handling, timer support, selfmod code Thomas Gleixner
2009-03-19 20:28                   ` Michal Simek
2009-03-19 21:47                     ` Thomas Gleixner
2009-03-20  2:24                       ` John Stultz
2009-03-20  7:27                         ` Michal Simek
2009-03-20 20:40                           ` john stultz
2009-03-21 10:38                             ` Michal Simek
2009-03-21 11:14                               ` Thomas Gleixner
2009-03-21 11:57                                 ` Michal Simek
2009-03-21 12:05                                   ` Thomas Gleixner
2009-03-21 12:07                                     ` Michal Simek
2009-03-20  6:38                       ` Michal Simek
2009-03-20 10:07                         ` Thomas Gleixner
2009-03-20  9:26                       ` Michal Simek
2009-03-20  9:58                         ` Thomas Gleixner
2009-03-20 10:37                           ` Michal Simek
2009-03-20 10:49                             ` Thomas Gleixner
2009-03-20 11:28                               ` Michal Simek
2009-03-20 11:41                                 ` Thomas Gleixner
2009-03-20 11:59                                   ` Michal Simek
2009-03-20 14:08                       ` Michal Simek
2009-03-20 14:12                         ` Thomas Gleixner
2009-03-20 14:27                           ` Michal Simek
2009-03-23 19:35               ` [PATCH 07/57] microblaze_v7: Signal support Arnd Bergmann
2009-03-24 11:14                 ` Michal Simek
2009-03-23 18:51         ` [PATCH 04/57] microblaze_v7: Open firmware files Arnd Bergmann
2009-03-23 20:53           ` Anton Vorontsov
2009-03-26  0:01             ` Benjamin Herrenschmidt
2009-03-24 11:17           ` Michal Simek
2009-03-25 15:42   ` [PATCH 01/57] microblaze_v7: Kconfig patches Arnd Bergmann
2009-03-25 16:10     ` Michal Simek
2009-03-19  7:22 ` Microblaze linux support Ingo Molnar
2009-03-19  9:42   ` Michal Simek
2009-03-19 10:21     ` Ingo Molnar
2009-03-19 10:26       ` Michal Simek
2009-03-19 10:47         ` Jaswinder Singh Rajput
2009-03-19 11:10           ` Michal Simek
2009-03-19 10:50         ` Ingo Molnar
2009-03-19 10:52           ` Michal Simek
2009-03-19 11:00             ` Ingo Molnar
2009-03-19 11:04               ` Michal Simek
2009-03-19 20:35 ` Randy Dunlap
2009-03-19 20:41   ` Michal Simek
2009-03-24 15:26 ` Michal Simek
2009-03-24 15:33   ` John Linn
2009-03-24 15:42     ` Michal Simek
2009-03-24 17:46   ` [microblaze-uclinux] " Stephen Neuendorffer

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=fde2defbb60d9476df3aac0dc7d87241ed247d3e.1237407249.git.monstr@monstr.eu \
    --to=monstr@monstr.eu \
    --cc=john.williams@petalogix.com \
    --cc=linux-kernel@vger.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®