Автор работы: Пользователь скрыл имя, 17 Января 2012 в 14:29, курсовая работа
В настоящее время только Philips производит более 150 наименований I2C-совместимых устройств, функционально предназначенных работы в электронном оборудовании различного назначения. В их числе ИС памяти, видеопроцессоров и модулей обработки аудио- и видео-сигналов, АЦП и ЦАП, драйверы ЖК-индикаторов, процессоры со встоенным аппаратным контроллером I2C шины и многое другое.
Введение 5
1 Шина управления I2C 10
2 Исследование драйвера 14
Заключение 15
Список использованных источников 16
244 struct list_head clients;
245 struct list_head list;
246 char name[I2C_NAME_SIZE];
247 struct completion dev_released;
248 struct completion class_dev_released;
249 };
250 #define dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
251 #define class_dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter,
252
253
254 static inline void *i2c_get_adapdata (struct i2c_adapter *dev)
255 {
256 return dev_get_drvdata (&dev->dev);
257 }
258
259 static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
260 {
261 dev_set_drvdata (&dev->dev, data);
262 }
263
264 /*flags for the driver struct: */
265 #define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */
266 #if 0
267 /* this flag is gone -- there is a (optional) driver->detach_adapter
268 * callback now which can be used instead */
269 # define I2C_DF_DUMMY 0x02
270 #endif
271
272 /*flags for the client struct: */
273 #define I2C_CLIENT_ALLOW_USE 0x01 /* Client allows access */
274 #define I2C_CLIENT_ALLOW_MULTIPLE_USE
275 locks */
276 /* on an i2c_client */
277 #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */
278 #define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address
279 */
280 /* Must equal I2C_M_TEN below */
281
282 /* i2c adapter classes (bitmask) */
283 #define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */
284 #define I2C_CLASS_TV_ANALOG (1<<1) /* bttv + friends */
285 #define I2C_CLASS_TV_DIGITAL (1<<2) /* dvb cards */
286 #define I2C_CLASS_DDC (1<<3) /* i2c-matroxfb ? */
287 #define I2C_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */
288 #define I2C_CLASS_CAM_DIGITAL (1<<5) /* most webcams */
289 #define I2C_CLASS_SOUND (1<<6) /* sound devices */
290 #define I2C_CLASS_ALL (UINT_MAX) /* all of the above */
291
292 /* i2c_client_address_data is the struct for holding default client
293 * addresses for a driver and for the parameters supplied on the
294 * command line
295 */
296 struct i2c_client_address_data {
297 unsigned short *normal_i2c;
298 unsigned short *probe;
299 unsigned short *ignore;
300 unsigned short **forces;
301 };
302
303 /* Internal numbers to terminate lists */
304 #define I2C_CLIENT_END 0xfffeU
305
306 /* The numbers to use to set I2C bus address */
307 #define ANY_I2C_BUS 0xffff
308 #define ANY_I2C_ISA_BUS 9191
309
310
311 /* ----- functions exported by i2c.o */
312
313 /* administration...
314 */
315 extern int i2c_add_adapter(struct i2c_adapter *);
316 extern int i2c_del_adapter(struct i2c_adapter *);
317
318 extern int i2c_add_driver(struct i2c_driver *);
319 extern int i2c_del_driver(struct i2c_driver *);
320
321 extern int i2c_attach_client(struct i2c_client *);
322 extern int i2c_detach_client(struct i2c_client *);
323
324 /* New function: This is to get an i2c_client-struct for controlling the
325 client either by using i2c_control-function or having the
326 client-module export functions that can be used with the i2c_client
327 -struct. */
328 extern struct i2c_client *i2c_get_client(int driver_id, int adapter_id,
329 struct i2c_client *prev);
330
331 /* Should be used with new function
332 extern struct i2c_client *i2c_get_client(int,int,struct i2c_client *);
333 to make sure that client-struct is valid and that it is okay to access
334 the i2c-client.
335 returns -EACCES if client doesn't allow use (default)
336 returns -EBUSY if client doesn't allow multiple use (default) and
337 usage_count >0 */
338 extern int i2c_use_client(struct i2c_client *);
339 extern int i2c_release_client(struct i2c_client *);
340
341 /* call the i2c_client->command() of all attached clients with
342 * the given arguments */
343 extern void i2c_clients_command(struct i2c_adapter *adap,
344 unsigned int cmd, void *arg);
345
346 /* returns -EBUSY if address has been taken, 0 if not. Note that the only
347 other place at which this is called is within i2c_attach_client; so
348 you can cheat by simply not registering. Not recommended, of course! */
349 extern int i2c_check_addr (struct i2c_adapter *adapter, int addr);
350
351 /* Detect function. It iterates over all possible addresses itself.
352 * It will only call found_proc if some client is connected at the
353 * specific address (unless a 'force' matched);
354 */
355 extern int i2c_probe(struct i2c_adapter *adapter,
356 struct i2c_client_address_data *address_data,
357 int (*found_proc) (struct i2c_adapter *, int, int));
358
359 /* An ioctl like call to set div. parameters of the adapter.
360 */
361 extern int i2c_control(struct i2c_client *,unsigned int, unsigned long);
362
363 extern struct i2c_adapter* i2c_get_adapter(int id);
364 extern void i2c_put_adapter(struct i2c_adapter *adap);
365
366
367 /* Return the functionality mask */
368 static inline u32 i2c_get_functionality(struct i2c_adapter *adap)
369 {
370 return adap->algo->functionality(adap
371 }
372
373 /* Return 1 if adapter supports everything we need, 0 if not. */
374 static inline int i2c_check_functionality(struct i2c_adapter *adap, u32
375
376 {
377 return (func & i2c_get_functionality(adap)) == func;
378 }
379
380 /* Return id number for a specific adapter */
381 static inline int i2c_adapter_id(struct i2c_adapter *adap)
382 {
383 return adap->nr;
384 }
385
386 /*
387 * I2C Message - used for pure i2c transaction, also from /dev interface
388 */
389 struct i2c_msg {
390 __u16 addr; /* slave address */
391 __u16 flags;
392 #define I2C_M_TEN 0x10 /* we have a ten bit chip address */
393 #define I2C_M_RD 0x01
Информация о работе Исследование драйвера ядра Linux для шины I2C