Исследование драйвера ядра Linux для шины I2C

Автор работы: Пользователь скрыл имя, 17 Января 2012 в 14:29, курсовая работа

Краткое описание

В настоящее время только Philips производит более 150 наименований I2C-совместимых устройств, функционально предназначенных работы в электронном оборудовании различного назначения. В их числе ИС памяти, видеопроцессоров и модулей обработки аудио- и видео-сигналов, АЦП и ЦАП, драйверы ЖК-индикаторов, процессоры со встоенным аппаратным контроллером I2C шины и многое другое.

Содержание работы

Введение 5
1 Шина управления I2C 10
2 Исследование драйвера 14
Заключение 15
Список использованных источников 16

Содержимое работы - 1 файл

kyrsovik.doc

— 337.00 Кб (Скачать файл)

   99                                      u8 command, u8 value);

  100 extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command);

  101 extern s32 i2c_smbus_write_word_data(struct i2c_client * client,

  102                                      u8 command, u16 value);

  103 extern s32 i2c_smbus_write_block_data(struct i2c_client * client,

  104                       u8 command, u8 length,

  105                       u8 *values);

  106 /* Returns the number of read bytes */

  107 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,

  108                      u8 command, u8 *values);

  109

  110 /*

  111 * A driver is capable of handling one or more physical devices present on

  112 * I2C adapters. This information is used to inform the driver of adapter

  113 * events.

  114 */

  115

  116 struct i2c_driver {

  117     struct module *owner;

  118     char name[32];

  119     int id;

  120     unsigned int class;

  121     unsigned int flags;     /* div., see below      */

  122

  123     /* Notifies the driver that a new bus has appeared. This routine

  124      * can be used by the driver to test if the bus meets its conditions

  125      * & seek for the presence of the chip(s) it supports. If found, it

  126      * registers the client(s) that are on the bus to the i2c admin. via

  127      * i2c_attach_client.

  128      */

  129     int (*attach_adapter)(struct i2c_adapter *);

  130     int (*detach_adapter)(struct i2c_adapter *);

  131

  132     /* tells the driver that a client is about to be deleted & gives it

  133      * the chance to remove its private data. Also, if the client struct

  134      * has been dynamically allocated by the driver in the function above,

  135      * it must be freed here.

  136      */

  137     int (*detach_client)(struct i2c_client *);

  138

  139     /* a ioctl like command that can be used to perform specific functions

  140      * with the device.

  141      */

  142     int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);

  143

  144     struct device_driver driver;

  145     struct list_head list;

  146 };

  147 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)

  148

  149 #define I2C_NAME_SIZE   50

  150

  151 /*

  152 * i2c_client identifies a single device (i.e. chip) that is connected to

  153                                           an

  154 * i2c bus. The behaviour is defined by the routines of the driver. This

  155 * function is mainly used for lookup & other admin. functions.

  156 */

  157 struct i2c_client {

  158     unsigned int flags;     /* div., see below      */

  159     unsigned short addr;        /* chip address - NOTE: 7bit    */

  160                     /* addresses are stored in the  */

  161                     /* _LOWER_ 7 bits       */

  162     struct i2c_adapter *adapter;    /* the adapter we sit on    */

  163     struct i2c_driver *driver;  /* and our access routines  */

  164     int usage_count;        /* How many accesses currently  */

  165                     /* to the client        */

  166     struct device dev;      /* the device structure     */

  167     struct list_head list;

  168     char name[I2C_NAME_SIZE];

  169     struct completion released;

  170 };

  171 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)

  172

  173 static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)

  174 {

  175     return to_i2c_client(container_of(kobj, struct device, kobj));

  176 }

  177

  178 static inline void *i2c_get_clientdata (struct i2c_client *dev)

  179 {

  180     return dev_get_drvdata (&dev->dev);

  181 }

  182

  183 static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)

  184 {

  185     dev_set_drvdata (&dev->dev, data);

  186 }

  187

  188 /*

  189 * The following structs are for those who like to implement new bus

  190 drivers:

  191 * i2c_algorithm is the interface to a class of hardware solutions which

  192 can

  193 * be addressed using the same bus algorithms - i.e. bit-banging or the

  194 PCF8584

  195 * to name two of the most common.

  196 */

  197 struct i2c_algorithm {

  198     /* If an adapter algorithm can't do I2C-level access, set master_xfer

  199        to NULL. If an adapter algorithm can do SMBus access, set

  200        smbus_xfer. If set to NULL, the SMBus protocol is simulated

  201        using common I2C messages */

  202     int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs,

  203                        int num);

  204     int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,

  205                        unsigned short flags, char read_write,

  206                        u8 command, int size, union i2c_smbus_data * data);

  207

  208     /* --- these optional/future use for some adapter types.*/

  209     int (*slave_send)(struct i2c_adapter *,char*,int);

  210     int (*slave_recv)(struct i2c_adapter *,char*,int);

  211

  212     /* --- ioctl like call to set div. parameters. */

  213     int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long);

  214

  215    /* To determine what the adapter supports */

  216     u32 (*functionality) (struct i2c_adapter *);

  217 };

  218

  219 /*

  220 * i2c_adapter is the structure used to identify a physical i2c bus along

  221 * with the access algorithms necessary to access it.

  222 */

  223 struct i2c_adapter {

  224     struct module *owner;

  225     unsigned int id;

  226     unsigned int class;

  227     struct i2c_algorithm *algo;/* the algorithm to access the bus   */

  228     void *algo_data;

  229

  230    /* --- administration stuff. */

  231     int (*client_register)(struct i2c_client *);

  232     int (*client_unregister)(struct i2c_client *);

  233

  234     /* data fields that are valid for all devices   */

  235     struct semaphore bus_lock;

  236     struct semaphore clist_lock;

  237

  238     int timeout;

  239     int retries;

  240     struct device dev;      /* the adapter device */

  241     struct class_device class_dev;  /* the class device */

  242

  243     int nr;

Информация о работе Исследование драйвера ядра Linux для шины I2C