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