2 * Copyright (C) 1998 Itai Nahshon, Michael Schimek
11 typedef unsigned char I2CByte
;
12 typedef unsigned short I2CSlaveAddr
;
14 typedef struct _I2CBusRec
*I2CBusPtr
;
15 typedef struct _I2CDevRec
*I2CDevPtr
;
17 /* I2C masters have to register themselves */
19 typedef struct _I2CBusRec
{
23 void (*I2CUDelay
) (I2CBusPtr b
, int usec
);
25 void (*I2CPutBits
)(I2CBusPtr b
, int scl
, int sda
);
26 void (*I2CGetBits
)(I2CBusPtr b
, int *scl
, int *sda
);
28 /* Look at the generic routines to see how these functions should behave. */
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
);
36 DevUnion DriverPrivate
;
38 int HoldTime
; /* 1 / bus clock frequency, 5 or 2 usec */
40 int BitTimeout
; /* usec */
41 int ByteTimeout
; /* usec */
42 int AcknTimeout
; /* usec */
43 int StartTimeout
; /* usec */
44 int RiseFallTime
; /* usec */
48 Bool (*I2CWriteRead
)(I2CDevPtr d
, I2CByte
*WriteBuffer
, int nWrite
,
49 I2CByte
*ReadBuffer
, int nRead
);
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
);
59 /* I2C slave devices */
61 typedef struct _I2CDevRec
{
64 int BitTimeout
; /* usec */
65 int ByteTimeout
; /* usec */
66 int AcknTimeout
; /* usec */
67 int StartTimeout
; /* usec */
69 I2CSlaveAddr SlaveAddr
;
72 DevUnion DriverPrivate
;
75 I2CDevPtr
xf86CreateI2CDevRec(void);
76 void xf86DestroyI2CDevRec(I2CDevPtr pI2CDev
, Bool unalloc
);
77 Bool
xf86I2CDevInit(I2CDevPtr pI2CDev
);
78 I2CDevPtr
xf86I2CFindDev(I2CBusPtr
, I2CSlaveAddr
);
80 /* See descriptions of these functions in xf86i2c.c */
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
);
96 #endif /*_XF86I2C_H */