Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux/fpc-iii.git] / drivers / staging / vt6655 / upc.h
blob155e66439073f10407870c53b536b882ebbdcd29
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 * File: upc.h
21 * Purpose: Macros to access device
23 * Author: Tevin Chen
25 * Date: Mar 17, 1997
29 #ifndef __UPC_H__
30 #define __UPC_H__
32 #include "device.h"
33 #include "ttype.h"
35 /*--------------------- Export Definitions -------------------------*/
38 // For IO mapped
41 #ifdef IO_MAP
43 #define VNSvInPortB(dwIOAddress, pbyData) \
44 do { \
45 *(pbyData) = inb(dwIOAddress); \
46 } while (0)
48 #define VNSvInPortW(dwIOAddress, pwData) \
49 do { \
50 *(pwData) = inw(dwIOAddress); \
51 } while (0)
53 #define VNSvInPortD(dwIOAddress, pdwData) \
54 do { \
55 *(pdwData) = inl(dwIOAddress); \
56 } while (0)
58 #define VNSvOutPortB(dwIOAddress, byData) \
59 outb(byData, dwIOAddress)
61 #define VNSvOutPortW(dwIOAddress, wData) \
62 outw(wData, dwIOAddress)
64 #define VNSvOutPortD(dwIOAddress, dwData) \
65 outl(dwData, dwIOAddress)
67 #else
70 // For memory mapped IO
73 #define VNSvInPortB(dwIOAddress, pbyData) \
74 do { \
75 volatile unsigned char *pbyAddr = (unsigned char *)(dwIOAddress); \
76 *(pbyData) = readb(pbyAddr); \
77 } while (0)
79 #define VNSvInPortW(dwIOAddress, pwData) \
80 do { \
81 volatile unsigned short *pwAddr = (unsigned short *)(dwIOAddress); \
82 *(pwData) = readw(pwAddr); \
83 } while (0)
85 #define VNSvInPortD(dwIOAddress, pdwData) \
86 do { \
87 volatile unsigned long *pdwAddr = (unsigned long *)(dwIOAddress); \
88 *(pdwData) = readl(pdwAddr); \
89 } while (0)
91 #define VNSvOutPortB(dwIOAddress, byData) \
92 do { \
93 volatile unsigned char *pbyAddr = (unsigned char *)(dwIOAddress); \
94 writeb((unsigned char)byData, pbyAddr); \
95 } while (0)
97 #define VNSvOutPortW(dwIOAddress, wData) \
98 do { \
99 volatile unsigned short *pwAddr = ((unsigned short *)(dwIOAddress)); \
100 writew((unsigned short)wData, pwAddr); \
101 } while (0)
103 #define VNSvOutPortD(dwIOAddress, dwData) \
104 do { \
105 volatile unsigned long *pdwAddr = (unsigned long *)(dwIOAddress); \
106 writel((unsigned long)dwData, pdwAddr); \
107 } while (0)
109 #endif
112 // ALWAYS IO-Mapped IO when in 16-bit/32-bit environment
114 #define PCBvInPortB(dwIOAddress, pbyData) \
115 do { \
116 *(pbyData) = inb(dwIOAddress); \
117 } while (0)
119 #define PCBvInPortW(dwIOAddress, pwData) \
120 do { \
121 *(pwData) = inw(dwIOAddress); \
122 } while (0)
124 #define PCBvInPortD(dwIOAddress, pdwData) \
125 do { \
126 *(pdwData) = inl(dwIOAddress); \
127 } while (0)
129 #define PCBvOutPortB(dwIOAddress, byData) \
130 outb(byData, dwIOAddress)
132 #define PCBvOutPortW(dwIOAddress, wData) \
133 outw(wData, dwIOAddress)
135 #define PCBvOutPortD(dwIOAddress, dwData) \
136 outl(dwData, dwIOAddress)
138 #define PCAvDelayByIO(uDelayUnit) \
139 do { \
140 unsigned char byData; \
141 unsigned long ii; \
143 if (uDelayUnit <= 50) { \
144 udelay(uDelayUnit); \
145 } else { \
146 for (ii = 0; ii < (uDelayUnit); ii++) \
147 byData = inb(0x61); \
149 } while (0)
151 /*--------------------- Export Classes ----------------------------*/
153 /*--------------------- Export Variables --------------------------*/
155 /*--------------------- Export Functions --------------------------*/
157 #endif // __UPC_H__