The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/i2c/i2cvar.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: i2cvar.h,v 1.1 2003/09/30 00:35:31 thorpej Exp $       */
    2 
    3 /*
    4  * Copyright (c) 2003 Wasabi Systems, Inc.
    5  * All rights reserved.
    6  *
    7  * Written by Steve C. Woodford and Jason R. Thorpe for Wasabi Systems, Inc.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice, this list of conditions and the following disclaimer.
   14  * 2. Redistributions in binary form must reproduce the above copyright
   15  *    notice, this list of conditions and the following disclaimer in the
   16  *    documentation and/or other materials provided with the distribution.
   17  * 3. All advertising materials mentioning features or use of this software
   18  *    must display the following acknowledgement:
   19  *      This product includes software developed for the NetBSD Project by
   20  *      Wasabi Systems, Inc.
   21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
   22  *    or promote products derived from this software without specific prior
   23  *    written permission.
   24  *
   25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
   26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
   29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   35  * POSSIBILITY OF SUCH DAMAGE.
   36  */
   37 
   38 #ifndef _DEV_I2C_I2CVAR_H_
   39 #define _DEV_I2C_I2CVAR_H_
   40 
   41 #include <dev/i2c/i2c_io.h>
   42 
   43 /* Flags passed to i2c routines. */
   44 #define I2C_F_WRITE             0x00    /* new transfer is a write */
   45 #define I2C_F_READ              0x01    /* new transfer is a read */
   46 #define I2C_F_LAST              0x02    /* last byte of read */
   47 #define I2C_F_STOP              0x04    /* send stop after byte */
   48 #define I2C_F_POLL              0x08    /* poll, don't sleep */
   49 
   50 /*
   51  * This structure provides the interface between the i2c framework
   52  * and the underlying i2c controller.
   53  *
   54  * Note that this structure is designed specifically to allow us
   55  * to either use the autoconfiguration framework or not.  This
   56  * allows a driver for a board with a private i2c bus use generic
   57  * i2c client drivers for chips that might be on that board.
   58  */
   59 typedef struct i2c_controller {
   60         void    *ic_cookie;             /* controller private */
   61 
   62         /*
   63          * These provide synchronization in the presence of
   64          * multiple users of the i2c bus.  When a device
   65          * driver wishes to perform transfers on the i2c
   66          * bus, the driver should acquire the bus.  When
   67          * the driver is finished, it should release the
   68          * bus.
   69          *
   70          * This is provided by the back-end since a single
   71          * controller may present e.g. i2c and smbus views
   72          * of the same set of i2c wires.
   73          */
   74         int     (*ic_acquire_bus)(void *, int);
   75         void    (*ic_release_bus)(void *, int);
   76 
   77         /*
   78          * The preferred API for clients of the i2c interface
   79          * is the scripted API.  This handles i2c controllers
   80          * that do not provide raw access to the i2c signals.
   81          */
   82         int     (*ic_exec)(void *, i2c_op_t, i2c_addr_t, const void *, size_t,
   83                     void *, size_t, int);
   84 
   85         int     (*ic_send_start)(void *, int);
   86         int     (*ic_send_stop)(void *, int);
   87         int     (*ic_initiate_xfer)(void *, i2c_addr_t, int);
   88         int     (*ic_read_byte)(void *, uint8_t *, int);
   89         int     (*ic_write_byte)(void *, uint8_t, int);
   90 } *i2c_tag_t;
   91 
   92 /* Used to attach the i2c framework to the controller. */
   93 struct i2cbus_attach_args {
   94         const char *iba_name;           /* bus name ("iic") */
   95         i2c_tag_t iba_tag;              /* the controller */
   96 };
   97 
   98 /* Used to attach devices on the i2c bus. */
   99 struct i2c_attach_args {
  100         i2c_tag_t       ia_tag;         /* our controller */
  101         i2c_addr_t      ia_addr;        /* address of device */
  102         int             ia_size;        /* size (for EEPROMs) */
  103 };
  104 
  105 /*
  106  * API presented to i2c controllers.
  107  */
  108 int     iicbus_print(void *, const char *);
  109 
  110 #ifdef _I2C_PRIVATE
  111 /*
  112  * Macros used internally by the i2c framework.
  113  */
  114 #define iic_send_start(ic, flags)                                       \
  115         (*(ic)->ic_send_start)((ic)->ic_cookie, (flags))
  116 #define iic_send_stop(ic, flags)                                        \
  117         (*(ic)->ic_send_stop)((ic)->ic_cookie, (flags))
  118 #define iic_initiate_xfer(ic, addr, flags)                              \
  119         (*(ic)->ic_initiate_xfer)((ic)->ic_cookie, (addr), (flags))
  120 
  121 #define iic_read_byte(ic, bytep, flags)                                 \
  122         (*(ic)->ic_read_byte)((ic)->ic_cookie, (bytep), (flags))
  123 #define iic_write_byte(ic, byte, flags)                                 \
  124         (*(ic)->ic_write_byte)((ic)->ic_cookie, (byte), (flags))
  125 #endif /* _I2C_PRIVATE */
  126 
  127 /*
  128  * Simplified API for clients of the i2c framework.  Definitions
  129  * in <dev/i2c/i2c_io.h>.
  130  */
  131 #define iic_acquire_bus(ic, flags)                                      \
  132         (*(ic)->ic_acquire_bus)((ic)->ic_cookie, (flags))
  133 #define iic_release_bus(ic, flags)                                      \
  134         (*(ic)->ic_release_bus)((ic)->ic_cookie, (flags))
  135 
  136 int     iic_exec(i2c_tag_t, i2c_op_t, i2c_addr_t, const void *,
  137             size_t, void *, size_t, int);
  138 
  139 int     iic_smbus_write_byte(i2c_tag_t, i2c_addr_t, uint8_t, uint8_t, int);
  140 int     iic_smbus_read_byte(i2c_tag_t, i2c_addr_t, uint8_t, uint8_t *, int);
  141 int     iic_smbus_receive_byte(i2c_tag_t, i2c_addr_t, uint8_t *, int);
  142 
  143 #endif /* _DEV_I2C_I2CVAR_H_ */

Cache object: a235407718203b7969ef5ec14f463133


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.