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