Path: blob/master/arch/arm/mach-ixp2000/include/mach/io.h
10820 views
/*1* arch/arm/mach-ixp2000/include/mach/io.h2*3* Original Author: Naeem M Afzal <[email protected]>4* Maintainer: Deepak Saxena <[email protected]>5*6* Copyright (C) 2002 Intel Corp.7* Copyrgiht (C) 2003-2004 MontaVista Software, Inc.8*9* This program is free software; you can redistribute it and/or modify10* it under the terms of the GNU General Public License version 2 as11* published by the Free Software Foundation.12*/1314#ifndef __ASM_ARM_ARCH_IO_H15#define __ASM_ARM_ARCH_IO_H1617#include <mach/hardware.h>1819#define IO_SPACE_LIMIT 0xffffffff20#define __mem_pci(a) (a)2122/*23* The A? revisions of the IXP2000s assert byte lanes for PCI I/O24* transactions the other way round (MEM transactions don't have this25* issue), so if we want to support those models, we need to override26* the standard I/O functions.27*28* B0 and later have a bit that can be set to 1 to get the proper29* behavior for I/O transactions, which then allows us to use the30* standard I/O functions. This is what we do if the user does not31* explicitly ask for support for pre-B0.32*/33#ifdef CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO34#define ___io(p) ((void __iomem *)((p)+IXP2000_PCI_IO_VIRT_BASE))3536#define alignb(addr) (void __iomem *)((unsigned long)(addr) ^ 3)37#define alignw(addr) (void __iomem *)((unsigned long)(addr) ^ 2)3839#define outb(v,p) __raw_writeb((v),alignb(___io(p)))40#define outw(v,p) __raw_writew((v),alignw(___io(p)))41#define outl(v,p) __raw_writel((v),___io(p))4243#define inb(p) ({ unsigned int __v = __raw_readb(alignb(___io(p))); __v; })44#define inw(p) \45({ unsigned int __v = (__raw_readw(alignw(___io(p)))); __v; })46#define inl(p) \47({ unsigned int __v = (__raw_readl(___io(p))); __v; })4849#define outsb(p,d,l) __raw_writesb(alignb(___io(p)),d,l)50#define outsw(p,d,l) __raw_writesw(alignw(___io(p)),d,l)51#define outsl(p,d,l) __raw_writesl(___io(p),d,l)5253#define insb(p,d,l) __raw_readsb(alignb(___io(p)),d,l)54#define insw(p,d,l) __raw_readsw(alignw(___io(p)),d,l)55#define insl(p,d,l) __raw_readsl(___io(p),d,l)5657#define __is_io_address(p) ((((unsigned long)(p)) & ~(IXP2000_PCI_IO_SIZE - 1)) == IXP2000_PCI_IO_VIRT_BASE)5859#define ioread8(p) \60({ \61unsigned int __v; \62\63if (__is_io_address(p)) { \64__v = __raw_readb(alignb(p)); \65} else { \66__v = __raw_readb(p); \67} \68\69__v; \70}) \7172#define ioread16(p) \73({ \74unsigned int __v; \75\76if (__is_io_address(p)) { \77__v = __raw_readw(alignw(p)); \78} else { \79__v = le16_to_cpu(__raw_readw(p)); \80} \81\82__v; \83})8485#define ioread32(p) \86({ \87unsigned int __v; \88\89if (__is_io_address(p)) { \90__v = __raw_readl(p); \91} else { \92__v = le32_to_cpu(__raw_readl(p)); \93} \94\95__v; \96})9798#define iowrite8(v,p) \99({ \100if (__is_io_address(p)) { \101__raw_writeb((v), alignb(p)); \102} else { \103__raw_writeb((v), p); \104} \105})106107#define iowrite16(v,p) \108({ \109if (__is_io_address(p)) { \110__raw_writew((v), alignw(p)); \111} else { \112__raw_writew(cpu_to_le16(v), p); \113} \114})115116#define iowrite32(v,p) \117({ \118if (__is_io_address(p)) { \119__raw_writel((v), p); \120} else { \121__raw_writel(cpu_to_le32(v), p); \122} \123})124125#define ioport_map(port, nr) ___io(port)126127#define ioport_unmap(addr)128#else129#define __io(p) ((void __iomem *)((p)+IXP2000_PCI_IO_VIRT_BASE))130#endif131132133#endif134135136