1fa225cbcSrjs/**************************************************************************
2fa225cbcSrjs
3fa225cbcSrjsCopyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
4fa225cbcSrjsAll Rights Reserved.
5fa225cbcSrjs
6fa225cbcSrjsPermission is hereby granted, free of charge, to any person obtaining a
7fa225cbcSrjscopy of this software and associated documentation files (the
8fa225cbcSrjs"Software"), to deal in the Software without restriction, including
9fa225cbcSrjswithout limitation the rights to use, copy, modify, merge, publish,
10fa225cbcSrjsdistribute, sub license, and/or sell copies of the Software, and to
11fa225cbcSrjspermit persons to whom the Software is furnished to do so, subject to
12fa225cbcSrjsthe following conditions:
13fa225cbcSrjs
14fa225cbcSrjsThe above copyright notice and this permission notice (including the
15fa225cbcSrjsnext paragraph) shall be included in all copies or substantial portions
16fa225cbcSrjsof the Software.
17fa225cbcSrjs
18fa225cbcSrjsTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19fa225cbcSrjsOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20fa225cbcSrjsMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21fa225cbcSrjsIN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
22fa225cbcSrjsANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23fa225cbcSrjsTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24fa225cbcSrjsSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25fa225cbcSrjs
26fa225cbcSrjs**************************************************************************/
27fa225cbcSrjs
28fa225cbcSrjs#ifdef HAVE_CONFIG_H
29fa225cbcSrjs#include "config.h"
30fa225cbcSrjs#endif
31fa225cbcSrjs
32fa225cbcSrjs/*
33fa225cbcSrjs * Authors:
34fa225cbcSrjs *   Daryll Strauss <daryll@precisioninsight.com>
35fa225cbcSrjs *
36fa225cbcSrjs */
37fa225cbcSrjs
38fa225cbcSrjs#include "xf86.h"
39fa225cbcSrjs#include "xf86_OSproc.h"
40fa225cbcSrjs#include "compiler.h"
41fa225cbcSrjs
42fa225cbcSrjs#ifdef BUILD_FOR_I830
43fa225cbcSrjs#include "i830.h"
44fa225cbcSrjs#define pI810 pI830
45fa225cbcSrjs#define I810Ptr I830Ptr
46fa225cbcSrjs#define I810WriteControlPIO I830WriteControlPIO
47fa225cbcSrjs#define I810ReadControlPIO I830ReadControlPIO
48fa225cbcSrjs#define I810WriteStandardPIO I830WriteStandardPIO
49fa225cbcSrjs#define I810ReadStandardPIO I830ReadStandardPIO
50fa225cbcSrjs#define I810SetPIOAccess I830SetPIOAccess
51fa225cbcSrjs#define I810WriteControlMMIO I830WriteControlMMIO
52fa225cbcSrjs#define I810ReadControlMMIO I830ReadControlMMIO
53fa225cbcSrjs#define I810WriteStandardMMIO I830WriteStandardMMIO
54fa225cbcSrjs#define I810ReadStandardMMIO I830ReadStandardMMIO
55fa225cbcSrjs#define I810SetMMIOAccess I830SetMMIOAccess
56fa225cbcSrjs#else
57fa225cbcSrjs#include "i810.h"
58fa225cbcSrjs#endif
59fa225cbcSrjs
60fa225cbcSrjs#define minb(p) *(volatile uint8_t *)(pI810->MMIOBase + (p))
61fa225cbcSrjs#define moutb(p,v) *(volatile uint8_t *)(pI810->MMIOBase + (p)) = (v)
62fa225cbcSrjs
63fa225cbcSrjsstatic void
64fa225cbcSrjsI810WriteControlPIO(I810Ptr pI810, IOADDRESS addr, uint8_t index, uint8_t val)
65fa225cbcSrjs{
66fa225cbcSrjs   addr += pI810->ioBase;
67fa225cbcSrjs   outb(addr, index);
68fa225cbcSrjs   outb(addr + 1, val);
69fa225cbcSrjs}
70fa225cbcSrjs
71fa225cbcSrjsstatic uint8_t
72fa225cbcSrjsI810ReadControlPIO(I810Ptr pI810, IOADDRESS addr, uint8_t index)
73fa225cbcSrjs{
74fa225cbcSrjs   addr += pI810->ioBase;
75fa225cbcSrjs   outb(addr, index);
76fa225cbcSrjs   return inb(addr + 1);
77fa225cbcSrjs}
78fa225cbcSrjs
79fa225cbcSrjsstatic void
80fa225cbcSrjsI810WriteStandardPIO(I810Ptr pI810, IOADDRESS addr, uint8_t val)
81fa225cbcSrjs{
82fa225cbcSrjs   outb(pI810->ioBase + addr, val);
83fa225cbcSrjs}
84fa225cbcSrjs
85fa225cbcSrjsstatic uint8_t
86fa225cbcSrjsI810ReadStandardPIO(I810Ptr pI810, IOADDRESS addr)
87fa225cbcSrjs{
88fa225cbcSrjs   return inb(pI810->ioBase + addr);
89fa225cbcSrjs}
90fa225cbcSrjs
91fa225cbcSrjsvoid
92fa225cbcSrjsI810SetPIOAccess(I810Ptr pI810)
93fa225cbcSrjs{
94fa225cbcSrjs   pI810->writeControl = I810WriteControlPIO;
95fa225cbcSrjs   pI810->readControl = I810ReadControlPIO;
96fa225cbcSrjs   pI810->writeStandard = I810WriteStandardPIO;
97fa225cbcSrjs   pI810->readStandard = I810ReadStandardPIO;
98fa225cbcSrjs}
99fa225cbcSrjs
100fa225cbcSrjsstatic void
101fa225cbcSrjsI810WriteControlMMIO(I810Ptr pI810, IOADDRESS addr, uint8_t index, uint8_t val)
102fa225cbcSrjs{
103fa225cbcSrjs   moutb(addr, index);
104fa225cbcSrjs   moutb(addr + 1, val);
105fa225cbcSrjs}
106fa225cbcSrjs
107fa225cbcSrjsstatic uint8_t
108fa225cbcSrjsI810ReadControlMMIO(I810Ptr pI810, IOADDRESS addr, uint8_t index)
109fa225cbcSrjs{
110fa225cbcSrjs   moutb(addr, index);
111fa225cbcSrjs   return minb(addr + 1);
112fa225cbcSrjs}
113fa225cbcSrjs
114fa225cbcSrjsstatic void
115fa225cbcSrjsI810WriteStandardMMIO(I810Ptr pI810, IOADDRESS addr, uint8_t val)
116fa225cbcSrjs{
117fa225cbcSrjs   moutb(addr, val);
118fa225cbcSrjs}
119fa225cbcSrjs
120fa225cbcSrjsstatic uint8_t
121fa225cbcSrjsI810ReadStandardMMIO(I810Ptr pI810, IOADDRESS addr)
122fa225cbcSrjs{
123fa225cbcSrjs   return minb(addr);
124fa225cbcSrjs}
125fa225cbcSrjs
126fa225cbcSrjsvoid
127fa225cbcSrjsI810SetMMIOAccess(I810Ptr pI810)
128fa225cbcSrjs{
129fa225cbcSrjs   pI810->writeControl = I810WriteControlMMIO;
130fa225cbcSrjs   pI810->readControl = I810ReadControlMMIO;
131fa225cbcSrjs   pI810->writeStandard = I810WriteStandardMMIO;
132fa225cbcSrjs   pI810->readStandard = I810ReadStandardMMIO;
133fa225cbcSrjs}
134