1 | /*
|
---|
2 | * Copyright (C) 1998 Itai Nahshon, Michael Schimek
|
---|
3 | */
|
---|
4 |
|
---|
5 | /* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h,v 1.10 2003/07/16 01:38:47 dawes Exp $ */
|
---|
6 |
|
---|
7 | #ifndef _XF86I2C_H
|
---|
8 | #define _XF86I2C_H
|
---|
9 |
|
---|
10 | #include "regionstr.h"
|
---|
11 |
|
---|
12 | typedef unsigned char I2CByte;
|
---|
13 | typedef unsigned short I2CSlaveAddr;
|
---|
14 |
|
---|
15 | typedef struct _I2CBusRec *I2CBusPtr;
|
---|
16 | typedef struct _I2CDevRec *I2CDevPtr;
|
---|
17 |
|
---|
18 | /* I2C masters have to register themselves */
|
---|
19 |
|
---|
20 | typedef struct _I2CBusRec {
|
---|
21 | char * BusName;
|
---|
22 | int scrnIndex;
|
---|
23 |
|
---|
24 | void (*I2CUDelay) (I2CBusPtr b, int usec);
|
---|
25 |
|
---|
26 | void (*I2CPutBits)(I2CBusPtr b, int scl, int sda);
|
---|
27 | void (*I2CGetBits)(I2CBusPtr b, int *scl, int *sda);
|
---|
28 |
|
---|
29 | /* Look at the generic routines to see how these functions should behave. */
|
---|
30 |
|
---|
31 | Bool (*I2CStart) (I2CBusPtr b, int timeout);
|
---|
32 | Bool (*I2CAddress)(I2CDevPtr d, I2CSlaveAddr);
|
---|
33 | void (*I2CStop) (I2CDevPtr d);
|
---|
34 | Bool (*I2CPutByte)(I2CDevPtr d, I2CByte data);
|
---|
35 | Bool (*I2CGetByte)(I2CDevPtr d, I2CByte *data, Bool);
|
---|
36 |
|
---|
37 | DevUnion DriverPrivate;
|
---|
38 |
|
---|
39 | int HoldTime; /* 1 / bus clock frequency, 5 or 2 usec */
|
---|
40 |
|
---|
41 | int BitTimeout; /* usec */
|
---|
42 | int ByteTimeout; /* usec */
|
---|
43 | int AcknTimeout; /* usec */
|
---|
44 | int StartTimeout; /* usec */
|
---|
45 | int RiseFallTime; /* usec */
|
---|
46 |
|
---|
47 | I2CDevPtr FirstDev;
|
---|
48 | I2CBusPtr NextBus;
|
---|
49 | Bool (*I2CWriteRead)(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite,
|
---|
50 | I2CByte *ReadBuffer, int nRead);
|
---|
51 | } I2CBusRec;
|
---|
52 |
|
---|
53 | I2CBusPtr xf86CreateI2CBusRec(void);
|
---|
54 | void xf86DestroyI2CBusRec(I2CBusPtr pI2CBus, Bool unalloc, Bool devs_too);
|
---|
55 | Bool xf86I2CBusInit(I2CBusPtr pI2CBus);
|
---|
56 | I2CBusPtr xf86I2CFindBus(int scrnIndex, char *name);
|
---|
57 | int xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr **pppI2CBus);
|
---|
58 |
|
---|
59 |
|
---|
60 | /* I2C slave devices */
|
---|
61 |
|
---|
62 | typedef struct _I2CDevRec {
|
---|
63 | char * DevName;
|
---|
64 |
|
---|
65 | int BitTimeout; /* usec */
|
---|
66 | int ByteTimeout; /* usec */
|
---|
67 | int AcknTimeout; /* usec */
|
---|
68 | int StartTimeout; /* usec */
|
---|
69 |
|
---|
70 | I2CSlaveAddr SlaveAddr;
|
---|
71 | I2CBusPtr pI2CBus;
|
---|
72 | I2CDevPtr NextDev;
|
---|
73 | DevUnion DriverPrivate;
|
---|
74 | } I2CDevRec;
|
---|
75 |
|
---|
76 | I2CDevPtr xf86CreateI2CDevRec(void);
|
---|
77 | void xf86DestroyI2CDevRec(I2CDevPtr pI2CDev, Bool unalloc);
|
---|
78 | Bool xf86I2CDevInit(I2CDevPtr pI2CDev);
|
---|
79 | I2CDevPtr xf86I2CFindDev(I2CBusPtr, I2CSlaveAddr);
|
---|
80 |
|
---|
81 | /* See descriptions of these functions in xf86i2c.c */
|
---|
82 |
|
---|
83 | Bool xf86I2CProbeAddress(I2CBusPtr pI2CBus, I2CSlaveAddr);
|
---|
84 | Bool xf86I2CWriteRead(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite,
|
---|
85 | I2CByte *ReadBuffer, int nRead);
|
---|
86 | #define xf86I2CRead(d, rb, nr) xf86I2CWriteRead(d, NULL, 0, rb, nr)
|
---|
87 | Bool xf86I2CReadStatus(I2CDevPtr d, I2CByte *pbyte);
|
---|
88 | Bool xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte);
|
---|
89 | Bool xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte, int n);
|
---|
90 | Bool xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr, unsigned short *pword);
|
---|
91 | #define xf86I2CWrite(d, wb, nw) xf86I2CWriteRead(d, wb, nw, NULL, 0)
|
---|
92 | Bool xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, I2CByte byte);
|
---|
93 | Bool xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *WriteBuffer, int nWrite);
|
---|
94 | Bool xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr, unsigned short word);
|
---|
95 | Bool xf86I2CWriteVec(I2CDevPtr d, I2CByte *vec, int nValues);
|
---|
96 |
|
---|
97 | #endif /*_XF86I2C_H */
|
---|