Merge 3.9-rc5 into staging-next
[deliverable/linux.git] / drivers / staging / vt6655 / upc.h
CommitLineData
5449c685
FB
1/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
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.
9 *
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.
14 *
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.
18 *
19 * File: upc.h
20 *
21 * Purpose: Macros to access device
22 *
23 * Author: Tevin Chen
24 *
25 * Date: Mar 17, 1997
26 *
27 */
28
5449c685
FB
29#ifndef __UPC_H__
30#define __UPC_H__
31
5449c685 32#include "device.h"
5449c685 33#include "ttype.h"
5449c685
FB
34
35/*--------------------- Export Definitions -------------------------*/
36
5449c685
FB
37//
38// For IO mapped
39//
40
41#ifdef IO_MAP
42
bda2a44e
JP
43#define VNSvInPortB(dwIOAddress, pbyData) \
44do { \
45 *(pbyData) = inb(dwIOAddress); \
46} while (0)
5449c685 47
bda2a44e
JP
48#define VNSvInPortW(dwIOAddress, pwData) \
49do { \
50 *(pwData) = inw(dwIOAddress); \
51} while (0)
5449c685 52
bda2a44e
JP
53#define VNSvInPortD(dwIOAddress, pdwData) \
54do { \
55 *(pdwData) = inl(dwIOAddress); \
56} while (0)
5449c685 57
bda2a44e
JP
58#define VNSvOutPortB(dwIOAddress, byData) \
59 outb(byData, dwIOAddress)
5449c685 60
bda2a44e
JP
61#define VNSvOutPortW(dwIOAddress, wData) \
62 outw(wData, dwIOAddress)
5449c685 63
bda2a44e
JP
64#define VNSvOutPortD(dwIOAddress, dwData) \
65 outl(dwData, dwIOAddress)
5449c685
FB
66
67#else
68
69//
70// For memory mapped IO
71//
72
bda2a44e
JP
73#define VNSvInPortB(dwIOAddress, pbyData) \
74do { \
75 volatile unsigned char *pbyAddr = (unsigned char *)(dwIOAddress); \
76 *(pbyData) = readb(pbyAddr); \
77} while (0)
5449c685 78
bda2a44e
JP
79#define VNSvInPortW(dwIOAddress, pwData) \
80do { \
81 volatile unsigned short *pwAddr = (unsigned short *)(dwIOAddress); \
82 *(pwData) = readw(pwAddr); \
83} while (0)
5449c685 84
bda2a44e
JP
85#define VNSvInPortD(dwIOAddress, pdwData) \
86do { \
87 volatile unsigned long *pdwAddr = (unsigned long *)(dwIOAddress); \
88 *(pdwData) = readl(pdwAddr); \
89} while (0)
5449c685 90
bda2a44e
JP
91#define VNSvOutPortB(dwIOAddress, byData) \
92do { \
93 volatile unsigned char *pbyAddr = (unsigned char *)(dwIOAddress); \
94 writeb((unsigned char)byData, pbyAddr); \
95} while (0)
5449c685 96
bda2a44e
JP
97#define VNSvOutPortW(dwIOAddress, wData) \
98do { \
99 volatile unsigned short *pwAddr = ((unsigned short *)(dwIOAddress)); \
100 writew((unsigned short)wData, pwAddr); \
101} while (0)
5449c685 102
bda2a44e
JP
103#define VNSvOutPortD(dwIOAddress, dwData) \
104do { \
105 volatile unsigned long *pdwAddr = (unsigned long *)(dwIOAddress); \
106 writel((unsigned long)dwData, pdwAddr); \
107} while (0)
5449c685
FB
108
109#endif
110
5449c685
FB
111//
112// ALWAYS IO-Mapped IO when in 16-bit/32-bit environment
113//
bda2a44e
JP
114#define PCBvInPortB(dwIOAddress, pbyData) \
115do { \
116 *(pbyData) = inb(dwIOAddress); \
117} while (0)
118
119#define PCBvInPortW(dwIOAddress, pwData) \
120do { \
121 *(pwData) = inw(dwIOAddress); \
122} while (0)
123
124#define PCBvInPortD(dwIOAddress, pdwData) \
125do { \
126 *(pdwData) = inl(dwIOAddress); \
127} while (0)
128
129#define PCBvOutPortB(dwIOAddress, byData) \
130 outb(byData, dwIOAddress)
131
132#define PCBvOutPortW(dwIOAddress, wData) \
133 outw(wData, dwIOAddress)
134
135#define PCBvOutPortD(dwIOAddress, dwData) \
136 outl(dwData, dwIOAddress)
137
138#define PCAvDelayByIO(uDelayUnit) \
139do { \
140 unsigned char byData; \
141 unsigned long ii; \
031d3996 142 \
bda2a44e
JP
143 if (uDelayUnit <= 50) { \
144 udelay(uDelayUnit); \
145 } else { \
146 for (ii = 0; ii < (uDelayUnit); ii++) \
147 byData = inb(0x61); \
148 } \
149} while (0)
5449c685 150
5449c685
FB
151/*--------------------- Export Classes ----------------------------*/
152
153/*--------------------- Export Variables --------------------------*/
154
155/*--------------------- Export Functions --------------------------*/
156
5449c685 157#endif // __UPC_H__
This page took 0.993618 seconds and 5 git commands to generate.