1/*
2 * bus_ops.h 1.12 2001/08/24 12:16:12
3 *
4 * The contents of this file are subject to the Mozilla Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License
7 * at http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 * the License for the specific language governing rights and
12 * limitations under the License.
13 *
14 * The initial developer of the original code is David A. Hinds
15 * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
16 * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
17 *
18 * Alternatively, the contents of this file may be used under the
19 * terms of the GNU General Public License version 2 (the "GPL"), in
20 * which case the provisions of the GPL are applicable instead of the
21 * above.  If you wish to allow the use of your version of this file
22 * only under the terms of the GPL and not to allow others to use
23 * your version of this file under the MPL, indicate your decision by
24 * deleting the provisions above and replace them with the notice and
25 * other provisions required by the GPL.  If you do not delete the
26 * provisions above, a recipient may use your version of this file
27 * under either the MPL or the GPL.
28 */
29
30#ifndef _LINUX_BUS_OPS_H
31#define _LINUX_BUS_OPS_H
32
33#include <linux/config.h>
34
35#ifdef CONFIG_VIRTUAL_BUS
36
37typedef struct bus_operations {
38    void	*priv;
39    u32		(*b_in)(void *bus, u32 port, s32 sz);
40    void	(*b_ins)(void *bus, u32 port, void *buf,
41			 u32 count, s32 sz);
42    void	(*b_out)(void *bus, u32 val, u32 port, s32 sz);
43    void	(*b_outs)(void *bus, u32 port, void *buf,
44			  u32 count, s32 sz);
45    void	*(*b_ioremap)(void *bus, u_long ofs, u_long sz);
46    void	(*b_iounmap)(void *bus, void *addr);
47    u32		(*b_read)(void *bus, void *addr, s32 sz);
48    void	(*b_write)(void *bus, u32 val, void *addr, s32 sz);
49    void	(*b_copy_from)(void *bus, void *d, void *s, u32 count);
50    void	(*b_copy_to)(void *bus, void *d, void *s, u32 count);
51    int		(*b_request_irq)(void *bus, u_int irq,
52				 void (*handler)(int, void *,
53						 struct pt_regs *),
54				 u_long flags, const char *device,
55				 void *dev_id);
56    void	(*b_free_irq)(void *bus, u_int irq, void *dev_id);
57} bus_operations;
58
59#define bus_inb(b,p)		(b)->b_in((b),(p),0)
60#define bus_inw(b,p)		(b)->b_in((b),(p),1)
61#define bus_inl(b,p)		(b)->b_in((b),(p),2)
62#define bus_inw_ns(b,p)		(b)->b_in((b),(p),-1)
63#define bus_inl_ns(b,p)		(b)->b_in((b),(p),-2)
64
65#define bus_insb(b,p,a,c)	(b)->b_ins((b),(p),(a),(c),0)
66#define bus_insw(b,p,a,c)	(b)->b_ins((b),(p),(a),(c),1)
67#define bus_insl(b,p,a,c)	(b)->b_ins((b),(p),(a),(c),2)
68#define bus_insw_ns(b,p,a,c)	(b)->b_ins((b),(p),(a),(c),-1)
69#define bus_insl_ns(b,p,a,c)	(b)->b_ins((b),(p),(a),(c),-2)
70
71#define bus_outb(b,v,p)		(b)->b_out((b),(v),(p),0)
72#define bus_outw(b,v,p)		(b)->b_out((b),(v),(p),1)
73#define bus_outl(b,v,p)		(b)->b_out((b),(v),(p),2)
74#define bus_outw_ns(b,v,p)	(b)->b_out((b),(v),(p),-1)
75#define bus_outl_ns(b,v,p)	(b)->b_out((b),(v),(p),-2)
76
77#define bus_outsb(b,p,a,c)	(b)->b_outs((b),(p),(a),(c),0)
78#define bus_outsw(b,p,a,c)	(b)->b_outs((b),(p),(a),(c),1)
79#define bus_outsl(b,p,a,c)	(b)->b_outs((b),(p),(a),(c),2)
80#define bus_outsw_ns(b,p,a,c)	(b)->b_outs((b),(p),(a),(c),-1)
81#define bus_outsl_ns(b,p,a,c)	(b)->b_outs((b),(p),(a),(c),-2)
82
83#define bus_readb(b,a)		(b)->b_read((b),(a),0)
84#define bus_readw(b,a)		(b)->b_read((b),(a),1)
85#define bus_readl(b,a)		(b)->b_read((b),(a),2)
86#define bus_readw_ns(b,a)	(b)->b_read((b),(a),-1)
87#define bus_readl_ns(b,a)	(b)->b_read((b),(a),-2)
88
89#define bus_writeb(b,v,a)	(b)->b_write((b),(v),(a),0)
90#define bus_writew(b,v,a)	(b)->b_write((b),(v),(a),1)
91#define bus_writel(b,v,a)	(b)->b_write((b),(v),(a),2)
92#define bus_writew_ns(b,v,a)	(b)->b_write((b),(v),(a),-1)
93#define bus_writel_ns(b,v,a)	(b)->b_write((b),(v),(a),-2)
94
95#define bus_ioremap(b,s,n)	(b)->b_ioremap((b),(s),(n))
96#define bus_iounmap(b,a)	(b)->b_iounmap((b),(a))
97#define bus_memcpy_fromio(b,d,s,n) (b)->b_copy_from((b),(d),(s),(n))
98#define bus_memcpy_toio(b,d,s,n) (b)->b_copy_to((b),(d),(s),(n))
99
100#define bus_request_irq(b,i,h,f,n,d) \
101				(b)->b_request_irq((b),(i),(h),(f),(n),(d))
102#define bus_free_irq(b,i,d)	(b)->b_free_irq((b),(i),(d))
103
104#else
105
106#define bus_inb(b,p)		inb(p)
107#define bus_inw(b,p)		inw(p)
108#define bus_inl(b,p)		inl(p)
109#define bus_inw_ns(b,p)		inw_ns(p)
110#define bus_inl_ns(b,p)		inl_ns(p)
111
112#define bus_insb(b,p,a,c)	insb(p,a,c)
113#define bus_insw(b,p,a,c)	insw(p,a,c)
114#define bus_insl(b,p,a,c)	insl(p,a,c)
115#define bus_insw_ns(b,p,a,c)	insw_ns(p,a,c)
116#define bus_insl_ns(b,p,a,c)	insl_ns(p,a,c)
117
118#define bus_outb(b,v,p)		outb(b,v,p)
119#define bus_outw(b,v,p)		outw(b,v,p)
120#define bus_outl(b,v,p)		outl(b,v,p)
121#define bus_outw_ns(b,v,p)	outw_ns(b,v,p)
122#define bus_outl_ns(b,v,p)	outl_ns(b,v,p)
123
124#define bus_outsb(b,p,a,c)	outsb(p,a,c)
125#define bus_outsw(b,p,a,c)	outsw(p,a,c)
126#define bus_outsl(b,p,a,c)	outsl(p,a,c)
127#define bus_outsw_ns(b,p,a,c)	outsw_ns(p,a,c)
128#define bus_outsl_ns(b,p,a,c)	outsl_ns(p,a,c)
129
130#define bus_readb(b,a)		readb(a)
131#define bus_readw(b,a)		readw(a)
132#define bus_readl(b,a)		readl(a)
133#define bus_readw_ns(b,a)	readw_ns(a)
134#define bus_readl_ns(b,a)	readl_ns(a)
135
136#define bus_writeb(b,v,a)	writeb(v,a)
137#define bus_writew(b,v,a)	writew(v,a)
138#define bus_writel(b,v,a)	writel(v,a)
139#define bus_writew_ns(b,v,a)	writew_ns(v,a)
140#define bus_writel_ns(b,v,a)	writel_ns(v,a)
141
142#define bus_ioremap(b,s,n)	ioremap(s,n)
143#define bus_iounmap(b,a)	iounmap(a)
144#define bus_memcpy_fromio(b,d,s,n) memcpy_fromio(d,s,n)
145#define bus_memcpy_toio(b,d,s,n) memcpy_toio(d,s,n)
146
147#ifdef CONFIG_8xx
148#define bus_request_irq(b,i,h,f,n,d) request_8xxirq((i),(h),(f),(n),(d))
149#else
150#define bus_request_irq(b,i,h,f,n,d) request_irq((i),(h),(f),(n),(d))
151#endif
152
153#define bus_free_irq(b,i,d)	free_irq((i),(d))
154
155#endif /* CONFIG_VIRTUAL_BUS */
156
157#endif /* _LINUX_BUS_OPS_H */
158