Subversion Repositories Kolibri OS

Rev

Rev 1408 | Rev 1631 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1408 Rev 1430
Line 26... Line 26...
26
#ifndef _LINUX_I2C_H
26
#ifndef _LINUX_I2C_H
27
#define _LINUX_I2C_H
27
#define _LINUX_I2C_H
Line 28... Line 28...
28
 
28
 
29
#include 
29
#include 
-
 
30
#include 
-
 
31
#include 
Line 30... Line 32...
30
#include 
32
#include 
Line 31... Line 33...
31
 
33
 
Line 43... Line 45...
43
 */
45
 */
44
extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
46
extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
45
			int num);
47
			int num);
Line 46... Line 48...
46
 
48
 
-
 
49
/**
-
 
50
 * struct i2c_driver - represent an I2C device driver
-
 
51
 * @class: What kind of i2c device we instantiate (for detect)
-
 
52
 * @attach_adapter: Callback for bus addition (for legacy drivers)
-
 
53
 * @detach_adapter: Callback for bus removal (for legacy drivers)
-
 
54
 * @probe: Callback for device binding
-
 
55
 * @remove: Callback for device unbinding
-
 
56
 * @shutdown: Callback for device shutdown
-
 
57
 * @suspend: Callback for device suspend
-
 
58
 * @resume: Callback for device resume
-
 
59
 * @command: Callback for bus-wide signaling (optional)
-
 
60
 * @driver: Device driver model driver
-
 
61
 * @id_table: List of I2C devices supported by this driver
-
 
62
 * @detect: Callback for device detection
-
 
63
 * @address_list: The I2C addresses to probe (for detect)
-
 
64
 * @clients: List of detected clients we created (for i2c-core use only)
-
 
65
 *
-
 
66
 * The driver.owner field should be set to the module owner of this driver.
-
 
67
 * The driver.name field should be set to the name of this driver.
-
 
68
 *
-
 
69
 * For automatic device detection, both @detect and @address_data must
-
 
70
 * be defined. @class should also be set, otherwise only devices forced
-
 
71
 * with module parameters will be created. The detect function must
-
 
72
 * fill at least the name field of the i2c_board_info structure it is
-
 
73
 * handed upon successful detection, and possibly also the flags field.
-
 
74
 *
-
 
75
 * If @detect is missing, the driver will still work fine for enumerated
-
 
76
 * devices. Detected devices simply won't be supported. This is expected
-
 
77
 * for the many I2C/SMBus devices which can't be detected reliably, and
-
 
78
 * the ones which can always be enumerated in practice.
-
 
79
 *
-
 
80
 * The i2c_client structure which is handed to the @detect callback is
-
 
81
 * not a real i2c_client. It is initialized just enough so that you can
-
 
82
 * call i2c_smbus_read_byte_data and friends on it. Don't do anything
-
 
83
 * else with it. In particular, calling dev_dbg and friends on it is
-
 
84
 * not allowed.
-
 
85
 */
-
 
86
struct i2c_driver {
-
 
87
	unsigned int class;
-
 
88
 
-
 
89
	/* Notifies the driver that a new bus has appeared or is about to be
-
 
90
	 * removed. You should avoid using this if you can, it will probably
-
 
91
	 * be removed in a near future.
-
 
92
	 */
-
 
93
	int (*attach_adapter)(struct i2c_adapter *);
-
 
94
	int (*detach_adapter)(struct i2c_adapter *);
-
 
95
 
-
 
96
	/* Standard driver model interfaces */
-
 
97
	int (*probe)(struct i2c_client *, const struct i2c_device_id *);
-
 
98
	int (*remove)(struct i2c_client *);
-
 
99
 
-
 
100
	/* driver model interfaces that don't relate to enumeration  */
-
 
101
	void (*shutdown)(struct i2c_client *);
-
 
102
//	int (*suspend)(struct i2c_client *, pm_message_t mesg);
-
 
103
	int (*resume)(struct i2c_client *);
-
 
104
 
-
 
105
	/* Alert callback, for example for the SMBus alert protocol.
-
 
106
	 * The format and meaning of the data value depends on the protocol.
-
 
107
	 * For the SMBus alert protocol, there is a single bit of data passed
-
 
108
	 * as the alert response's low bit ("event flag").
-
 
109
	 */
-
 
110
	void (*alert)(struct i2c_client *, unsigned int data);
-
 
111
 
-
 
112
	/* a ioctl like command that can be used to perform specific functions
-
 
113
	 * with the device.
-
 
114
	 */
-
 
115
	int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
-
 
116
 
-
 
117
//	struct device_driver driver;
-
 
118
	const struct i2c_device_id *id_table;
-
 
119
 
-
 
120
	/* Device detection callback for automatic device creation */
-
 
121
//	int (*detect)(struct i2c_client *, struct i2c_board_info *);
-
 
122
	const unsigned short *address_list;
-
 
123
	struct list_head clients;
-
 
124
};
-
 
125
#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
-
 
126
 
47
/**
127
/**
48
 * struct i2c_client - represent an I2C slave device
128
 * struct i2c_client - represent an I2C slave device
49
 * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address;
129
 * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address;
50
 *	I2C_CLIENT_PEC indicates it uses SMBus Packet Error Checking
130
 *	I2C_CLIENT_PEC indicates it uses SMBus Packet Error Checking
51
 * @addr: Address used on the I2C bus connected to the parent adapter.
131
 * @addr: Address used on the I2C bus connected to the parent adapter.
Line 67... Line 147...
67
	unsigned short addr;		/* chip address - NOTE: 7bit	*/
147
	unsigned short addr;		/* chip address - NOTE: 7bit	*/
68
					/* addresses are stored in the	*/
148
					/* addresses are stored in the	*/
69
					/* _LOWER_ 7 bits		*/
149
					/* _LOWER_ 7 bits		*/
70
	char name[I2C_NAME_SIZE];
150
	char name[I2C_NAME_SIZE];
71
	struct i2c_adapter *adapter;	/* the adapter we sit on	*/
151
	struct i2c_adapter *adapter;	/* the adapter we sit on	*/
72
//        struct i2c_driver *driver;      /* and our access routines      */
152
    struct i2c_driver *driver;      /* and our access routines      */
73
//        struct device dev;              /* the device structure         */
153
//        struct device dev;              /* the device structure         */
74
        int irq;                        /* irq issued by device (or -1) */
154
    int irq;                        /* irq issued by device (or -1) */
75
	struct list_head detected;
155
	struct list_head detected;
76
};
156
};
77
#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
157
#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
Line -... Line 158...
-
 
158
 
Line 78... Line 159...
78
 
159
extern struct i2c_client *i2c_verify_client(struct device *dev);
79
 
160
 
80
/*
161
/*
81
 * The following structs are for those who like to implement new bus drivers:
162
 * The following structs are for those who like to implement new bus drivers:
Line 109... Line 190...
109
	unsigned int class;		  /* classes to allow probing for */
190
	unsigned int class;		  /* classes to allow probing for */
110
	const struct i2c_algorithm *algo; /* the algorithm to access the bus */
191
	const struct i2c_algorithm *algo; /* the algorithm to access the bus */
111
	void *algo_data;
192
	void *algo_data;
Line 112... Line 193...
112
 
193
 
113
        /* data fields that are valid for all devices   */
194
        /* data fields that are valid for all devices   */
Line 114... Line 195...
114
	u8 level; 			/* nesting level for lockdep */
195
//	struct rt_mutex bus_lock;
115
 
196
 
116
	int timeout;			/* in jiffies */
197
	int timeout;			/* in jiffies */
Line 117... Line 198...
117
    int retries;
198
    int retries;
118
 //  struct device dev;      /* the adapter device */
199
    struct device dev;      /* the adapter device */
119
 
200
 
120
    int nr;
201
    int nr;
Line -... Line 202...
-
 
202
    char name[48];
-
 
203
};
-
 
204
#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
-
 
205
 
-
 
206
static inline void *i2c_get_adapdata(const struct i2c_adapter *dev)
-
 
207
{
-
 
208
	return dev_get_drvdata(&dev->dev);
-
 
209
}
-
 
210
 
Line 121... Line 211...
121
    char name[48];
211
static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data)
122
};
212
{
123
#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
213
	dev_set_drvdata(&dev->dev, data);
124
 
214
}
Line 134... Line 224...
134
#define I2C_CLASS_TV_ANALOG	(1<<1)	/* bttv + friends */
224
#define I2C_CLASS_TV_ANALOG	(1<<1)	/* bttv + friends */
135
#define I2C_CLASS_TV_DIGITAL	(1<<2)	/* dvb cards */
225
#define I2C_CLASS_TV_DIGITAL	(1<<2)	/* dvb cards */
136
#define I2C_CLASS_DDC		(1<<3)	/* DDC bus on graphics adapters */
226
#define I2C_CLASS_DDC		(1<<3)	/* DDC bus on graphics adapters */
137
#define I2C_CLASS_SPD		(1<<7)	/* SPD EEPROMs and similar */
227
#define I2C_CLASS_SPD		(1<<7)	/* SPD EEPROMs and similar */
Line 138... Line -...
138
 
-
 
139
/* i2c_client_address_data is the struct for holding default client
-
 
140
 * addresses for a driver and for the parameters supplied on the
-
 
141
 * command line
-
 
142
 */
-
 
143
struct i2c_client_address_data {
-
 
144
	const unsigned short *normal_i2c;
-
 
145
	const unsigned short *probe;
-
 
146
	const unsigned short *ignore;
-
 
147
	const unsigned short * const *forces;
-
 
148
};
-
 
149
 
228
 
150
/* Internal numbers to terminate lists */
229
/* Internal numbers to terminate lists */
Line 151... Line 230...
151
#define I2C_CLIENT_END		0xfffeU
230
#define I2C_CLIENT_END		0xfffeU
152
 
231
 
Line 273... Line 352...
273
#define I2C_SMBUS_BLOCK_DATA	    5
352
#define I2C_SMBUS_BLOCK_DATA	    5
274
#define I2C_SMBUS_I2C_BLOCK_BROKEN  6
353
#define I2C_SMBUS_I2C_BLOCK_BROKEN  6
275
#define I2C_SMBUS_BLOCK_PROC_CALL   7		/* SMBus 2.0 */
354
#define I2C_SMBUS_BLOCK_PROC_CALL   7		/* SMBus 2.0 */
276
#define I2C_SMBUS_I2C_BLOCK_DATA    8
355
#define I2C_SMBUS_I2C_BLOCK_DATA    8
Line 277... Line -...
277
 
-
 
278
 
-
 
279
 
-
 
280
 
-
 
281
 
-
 
282
 
-
 
283
 
-
 
284
 
356
 
285
#endif /* _LINUX_I2C_H */
-
 
286
-
 
287
-
 
288
-
 
289
-
 
290
-
 
291
-
 
292
-
 
293
-
 
294
-
 
295
-
 
296
-
 
297
-
 
298
-