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 | I2CBusPtr xf86CreateI2CBusRec(void);
|
---|
53 | void xf86DestroyI2CBusRec(I2CBusPtr pI2CBus, Bool unalloc, Bool devs_too);
|
---|
54 | Bool xf86I2CBusInit(I2CBusPtr pI2CBus);
|
---|
55 | I2CBusPtr xf86I2CFindBus(int scrnIndex, char *name);
|
---|
56 | int xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr **pppI2CBus);
|
---|
57 |
|
---|
58 |
|
---|
59 | /* I2C slave devices */
|
---|
60 |
|
---|
61 | typedef struct _I2CDevRec {
|
---|
62 | char * DevName;
|
---|
63 |
|
---|
64 | int BitTimeout; /* usec */
|
---|
65 | int ByteTimeout; /* usec */
|
---|
66 | int AcknTimeout; /* usec */
|
---|
67 | int StartTimeout; /* usec */
|
---|
68 |
|
---|
69 | I2CSlaveAddr SlaveAddr;
|
---|
70 | I2CBusPtr pI2CBus;
|
---|
71 | I2CDevPtr NextDev;
|
---|
72 | DevUnion DriverPrivate;
|
---|
73 | } I2CDevRec;
|
---|
74 |
|
---|
75 | I2CDevPtr xf86CreateI2CDevRec(void);
|
---|
76 | void xf86DestroyI2CDevRec(I2CDevPtr pI2CDev, Bool unalloc);
|
---|
77 | Bool xf86I2CDevInit(I2CDevPtr pI2CDev);
|
---|
78 | I2CDevPtr xf86I2CFindDev(I2CBusPtr, I2CSlaveAddr);
|
---|
79 |
|
---|
80 | /* See descriptions of these functions in xf86i2c.c */
|
---|
81 |
|
---|
82 | Bool xf86I2CProbeAddress(I2CBusPtr pI2CBus, I2CSlaveAddr);
|
---|
83 | Bool xf86I2CWriteRead(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite,
|
---|
84 | I2CByte *ReadBuffer, int nRead);
|
---|
85 | #define xf86I2CRead(d, rb, nr) xf86I2CWriteRead(d, NULL, 0, rb, nr)
|
---|
86 | Bool xf86I2CReadStatus(I2CDevPtr d, I2CByte *pbyte);
|
---|
87 | Bool xf86I2CReadByte(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte);
|
---|
88 | Bool xf86I2CReadBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *pbyte, int n);
|
---|
89 | Bool xf86I2CReadWord(I2CDevPtr d, I2CByte subaddr, unsigned short *pword);
|
---|
90 | #define xf86I2CWrite(d, wb, nw) xf86I2CWriteRead(d, wb, nw, NULL, 0)
|
---|
91 | Bool xf86I2CWriteByte(I2CDevPtr d, I2CByte subaddr, I2CByte byte);
|
---|
92 | Bool xf86I2CWriteBytes(I2CDevPtr d, I2CByte subaddr, I2CByte *WriteBuffer, int nWrite);
|
---|
93 | Bool xf86I2CWriteWord(I2CDevPtr d, I2CByte subaddr, unsigned short word);
|
---|
94 | Bool xf86I2CWriteVec(I2CDevPtr d, I2CByte *vec, int nValues);
|
---|
95 |
|
---|
96 | #endif /*_XF86I2C_H */
|
---|