x86: Hypervisor detection and get tsc_freq from hypervisor
[linux-2.6/mini2440.git] / arch / sh / kernel / io_generic.c
blob5a7f554d9ca15c64cfb135b81d921ac3b4bd2b3f
1 /*
2 * arch/sh/kernel/io_generic.c
4 * Copyright (C) 2000 Niibe Yutaka
5 * Copyright (C) 2005 - 2007 Paul Mundt
7 * Generic I/O routine. These can be used where a machine specific version
8 * is not required.
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
14 #include <linux/module.h>
15 #include <linux/io.h>
16 #include <asm/machvec.h>
18 #ifdef CONFIG_CPU_SH3
19 /* SH3 has a PCMCIA bug that needs a dummy read from area 6 for a
20 * workaround. */
21 /* I'm not sure SH7709 has this kind of bug */
22 #define dummy_read() __raw_readb(0xba000000)
23 #else
24 #define dummy_read()
25 #endif
27 unsigned long generic_io_base;
29 u8 generic_inb(unsigned long port)
31 return __raw_readb(__ioport_map(port, 1));
34 u16 generic_inw(unsigned long port)
36 return __raw_readw(__ioport_map(port, 2));
39 u32 generic_inl(unsigned long port)
41 return __raw_readl(__ioport_map(port, 4));
44 u8 generic_inb_p(unsigned long port)
46 unsigned long v = generic_inb(port);
48 ctrl_delay();
49 return v;
52 u16 generic_inw_p(unsigned long port)
54 unsigned long v = generic_inw(port);
56 ctrl_delay();
57 return v;
60 u32 generic_inl_p(unsigned long port)
62 unsigned long v = generic_inl(port);
64 ctrl_delay();
65 return v;
69 * insb/w/l all read a series of bytes/words/longs from a fixed port
70 * address. However as the port address doesn't change we only need to
71 * convert the port address to real address once.
74 void generic_insb(unsigned long port, void *dst, unsigned long count)
76 volatile u8 *port_addr;
77 u8 *buf = dst;
79 port_addr = (volatile u8 __force *)__ioport_map(port, 1);
80 while (count--)
81 *buf++ = *port_addr;
84 void generic_insw(unsigned long port, void *dst, unsigned long count)
86 volatile u16 *port_addr;
87 u16 *buf = dst;
89 port_addr = (volatile u16 __force *)__ioport_map(port, 2);
90 while (count--)
91 *buf++ = *port_addr;
93 dummy_read();
96 void generic_insl(unsigned long port, void *dst, unsigned long count)
98 volatile u32 *port_addr;
99 u32 *buf = dst;
101 port_addr = (volatile u32 __force *)__ioport_map(port, 4);
102 while (count--)
103 *buf++ = *port_addr;
105 dummy_read();
108 void generic_outb(u8 b, unsigned long port)
110 __raw_writeb(b, __ioport_map(port, 1));
113 void generic_outw(u16 b, unsigned long port)
115 __raw_writew(b, __ioport_map(port, 2));
118 void generic_outl(u32 b, unsigned long port)
120 __raw_writel(b, __ioport_map(port, 4));
123 void generic_outb_p(u8 b, unsigned long port)
125 generic_outb(b, port);
126 ctrl_delay();
129 void generic_outw_p(u16 b, unsigned long port)
131 generic_outw(b, port);
132 ctrl_delay();
135 void generic_outl_p(u32 b, unsigned long port)
137 generic_outl(b, port);
138 ctrl_delay();
142 * outsb/w/l all write a series of bytes/words/longs to a fixed port
143 * address. However as the port address doesn't change we only need to
144 * convert the port address to real address once.
146 void generic_outsb(unsigned long port, const void *src, unsigned long count)
148 volatile u8 *port_addr;
149 const u8 *buf = src;
151 port_addr = (volatile u8 __force *)__ioport_map(port, 1);
153 while (count--)
154 *port_addr = *buf++;
157 void generic_outsw(unsigned long port, const void *src, unsigned long count)
159 volatile u16 *port_addr;
160 const u16 *buf = src;
162 port_addr = (volatile u16 __force *)__ioport_map(port, 2);
164 while (count--)
165 *port_addr = *buf++;
167 dummy_read();
170 void generic_outsl(unsigned long port, const void *src, unsigned long count)
172 volatile u32 *port_addr;
173 const u32 *buf = src;
175 port_addr = (volatile u32 __force *)__ioport_map(port, 4);
176 while (count--)
177 *port_addr = *buf++;
179 dummy_read();
182 void __iomem *generic_ioport_map(unsigned long addr, unsigned int size)
184 return (void __iomem *)(addr + generic_io_base);
187 void generic_ioport_unmap(void __iomem *addr)