iomap.c 3.2 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * ppc64 "iomap" interface implementation.
 *
 * (C) Copyright 2004 Linus Torvalds
 */
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/mm.h>
#include <asm/io.h>

/*
 * Here comes the ppc64 implementation of the IOMAP 
 * interfaces.
 */
unsigned int fastcall ioread8(void __iomem *addr)
{
	return readb(addr);
}
unsigned int fastcall ioread16(void __iomem *addr)
{
	return readw(addr);
}
23 24 25 26
unsigned int fastcall ioread16be(void __iomem *addr)
{
	return in_be16(addr);
}
L
Linus Torvalds 已提交
27 28 29 30
unsigned int fastcall ioread32(void __iomem *addr)
{
	return readl(addr);
}
31 32 33 34
unsigned int fastcall ioread32be(void __iomem *addr)
{
	return in_be32(addr);
}
L
Linus Torvalds 已提交
35 36
EXPORT_SYMBOL(ioread8);
EXPORT_SYMBOL(ioread16);
37
EXPORT_SYMBOL(ioread16be);
L
Linus Torvalds 已提交
38
EXPORT_SYMBOL(ioread32);
39
EXPORT_SYMBOL(ioread32be);
L
Linus Torvalds 已提交
40 41 42 43 44 45 46 47 48

void fastcall iowrite8(u8 val, void __iomem *addr)
{
	writeb(val, addr);
}
void fastcall iowrite16(u16 val, void __iomem *addr)
{
	writew(val, addr);
}
49 50 51 52
void fastcall iowrite16be(u16 val, void __iomem *addr)
{
	out_be16(addr, val);
}
L
Linus Torvalds 已提交
53 54 55 56
void fastcall iowrite32(u32 val, void __iomem *addr)
{
	writel(val, addr);
}
57 58 59 60
void fastcall iowrite32be(u32 val, void __iomem *addr)
{
	out_be32(addr, val);
}
L
Linus Torvalds 已提交
61 62
EXPORT_SYMBOL(iowrite8);
EXPORT_SYMBOL(iowrite16);
63
EXPORT_SYMBOL(iowrite16be);
L
Linus Torvalds 已提交
64
EXPORT_SYMBOL(iowrite32);
65
EXPORT_SYMBOL(iowrite32be);
L
Linus Torvalds 已提交
66 67 68 69 70 71 72 73 74 75 76

/*
 * These are the "repeat read/write" functions. Note the
 * non-CPU byte order. We do things in "IO byteorder"
 * here.
 *
 * FIXME! We could make these do EEH handling if we really
 * wanted. Not clear if we do.
 */
void ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
{
77
	_insb((u8 __iomem *) addr, dst, count);
L
Linus Torvalds 已提交
78 79 80
}
void ioread16_rep(void __iomem *addr, void *dst, unsigned long count)
{
81
	_insw_ns((u16 __iomem *) addr, dst, count);
L
Linus Torvalds 已提交
82 83 84
}
void ioread32_rep(void __iomem *addr, void *dst, unsigned long count)
{
85
	_insl_ns((u32 __iomem *) addr, dst, count);
L
Linus Torvalds 已提交
86 87 88 89 90 91 92
}
EXPORT_SYMBOL(ioread8_rep);
EXPORT_SYMBOL(ioread16_rep);
EXPORT_SYMBOL(ioread32_rep);

void iowrite8_rep(void __iomem *addr, const void *src, unsigned long count)
{
93
	_outsb((u8 __iomem *) addr, src, count);
L
Linus Torvalds 已提交
94 95 96
}
void iowrite16_rep(void __iomem *addr, const void *src, unsigned long count)
{
97
	_outsw_ns((u16 __iomem *) addr, src, count);
L
Linus Torvalds 已提交
98 99 100
}
void iowrite32_rep(void __iomem *addr, const void *src, unsigned long count)
{
101
	_outsl_ns((u32 __iomem *) addr, src, count);
L
Linus Torvalds 已提交
102 103 104 105 106 107 108
}
EXPORT_SYMBOL(iowrite8_rep);
EXPORT_SYMBOL(iowrite16_rep);
EXPORT_SYMBOL(iowrite32_rep);

void __iomem *ioport_map(unsigned long port, unsigned int len)
{
109
	return (void __iomem *) (port + _IO_BASE);
L
Linus Torvalds 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
}

void ioport_unmap(void __iomem *addr)
{
	/* Nothing to do */
}
EXPORT_SYMBOL(ioport_map);
EXPORT_SYMBOL(ioport_unmap);

void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
{
	unsigned long start = pci_resource_start(dev, bar);
	unsigned long len = pci_resource_len(dev, bar);
	unsigned long flags = pci_resource_flags(dev, bar);

	if (!len)
		return NULL;
	if (max && len > max)
		len = max;
	if (flags & IORESOURCE_IO)
		return ioport_map(start, len);
	if (flags & IORESOURCE_MEM)
		return ioremap(start, len);
	/* What? */
	return NULL;
}

void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
{
	/* Nothing to do */
}
EXPORT_SYMBOL(pci_iomap);
EXPORT_SYMBOL(pci_iounmap);