neo_i2c.c revision 692f60a7
1/********************************************************************** 2Copyright 1998, 1999 by Precision Insight, Inc., Cedar Park, Texas. 3 4 All Rights Reserved 5 6Permission to use, copy, modify, distribute, and sell this software and 7its documentation for any purpose is hereby granted without fee, 8provided that the above copyright notice appear in all copies and that 9both that copyright notice and this permission notice appear in 10supporting documentation, and that the name of Precision Insight not be 11used in advertising or publicity pertaining to distribution of the 12software without specific, written prior permission. Precision Insight 13and its suppliers make no representations about the suitability of this 14software for any purpose. It is provided "as is" without express or 15implied warranty. 16 17PRECISION INSIGHT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 18INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 19EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY 20SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 21RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 22CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 23CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 24**********************************************************************/ 25/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_i2c.c,v 1.4 2002/09/16 18:05:58 eich Exp $ */ 26 27/* 28 * The original Precision Insight driver for 29 * XFree86 v.3.3 has been sponsored by Red Hat. 30 * 31 * Authors: 32 * Jens Owen (jens@tungstengraphics.com) 33 * Kevin E. Martin (kevin@precisioninsight.com) 34 * 35 * Port to Xfree86 v.4.0 36 * 1998, 1999 by Egbert Eich (Egbert.Eich@Physik.TU-Darmstadt.DE) 37 */ 38 39#ifdef HAVE_CONFIG_H 40#include "config.h" 41#endif 42 43#include "xf86.h" 44#include "xf86_OSproc.h" 45#include "compiler.h" 46 47#include "xf86Pci.h" 48#include "xf86PciInfo.h" 49 50#include "vgaHW.h" 51 52#include "neo.h" 53 54static void 55neo_I2CPutBits(I2CBusPtr b, int clock, int data) { 56 vgaHWPtr hwp = VGAHWPTR(xf86Screens[b->scrnIndex]); 57 unsigned int reg = 0xF0; 58 59 VGAwCR(0x21,0x00); 60 VGAwCR(0x1D,0x01); 61 62 if(clock) reg |= 1; 63 if(data) reg |= 0x4; 64 VGAwGR(0xA1,reg); 65 /*ErrorF("neo_I2CPutBits: %d %d\n", clock, data); */ 66} 67 68static void 69neo_I2CGetBits(I2CBusPtr b, int *clock, int *data) { 70 unsigned int reg; 71 vgaHWPtr hwp = VGAHWPTR(xf86Screens[b->scrnIndex]); 72 73 reg = VGArGR(0xA1); 74 *clock = 1 /* (reg & 0x?? ) */; 75 *data = (reg & 0x8) != 0; 76 /*ErrorF("neo_I2CGetBits: %d %d\n", *clock, *data);*/ 77} 78 79Bool 80neo_I2CInit(ScrnInfoPtr pScrn) 81{ 82 NEOPtr pNeo = NEOPTR(pScrn); 83 I2CBusPtr I2CPtr; 84 85 I2CPtr = xf86CreateI2CBusRec(); 86 87 if(!I2CPtr) return FALSE; 88 89 pNeo->I2C = I2CPtr; 90 91 I2CPtr->BusName = "I2C bus"; 92 I2CPtr->scrnIndex = pScrn->scrnIndex; 93 I2CPtr->I2CPutBits = neo_I2CPutBits; 94 I2CPtr->I2CGetBits = neo_I2CGetBits; 95 /* increase these as the defaults are too low */ 96 I2CPtr->RiseFallTime = 2; 97 I2CPtr->HoldTime = 40; 98 99 if (!xf86I2CBusInit(I2CPtr)) 100 return FALSE; 101 102 return TRUE; 103} 104 105 106 107