[BACK]Return to i2c_io.h CVS log [TXT][DIR] Up to [local] / sys / dev / i2c

Annotation of sys/dev/i2c/i2c_io.h, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: i2c_io.h,v 1.1 2004/05/23 17:33:43 grange Exp $       */
        !             2: /*     $NetBSD: i2c_io.h,v 1.1 2003/09/30 00:35:31 thorpej Exp $       */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 2003 Wasabi Systems, Inc.
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
        !             9:  *
        !            10:  * Redistribution and use in source and binary forms, with or without
        !            11:  * modification, are permitted provided that the following conditions
        !            12:  * are met:
        !            13:  * 1. Redistributions of source code must retain the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer.
        !            15:  * 2. Redistributions in binary form must reproduce the above copyright
        !            16:  *    notice, this list of conditions and the following disclaimer in the
        !            17:  *    documentation and/or other materials provided with the distribution.
        !            18:  * 3. All advertising materials mentioning features or use of this software
        !            19:  *    must display the following acknowledgement:
        !            20:  *      This product includes software developed for the NetBSD Project by
        !            21:  *      Wasabi Systems, Inc.
        !            22:  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
        !            23:  *    or promote products derived from this software without specific prior
        !            24:  *    written permission.
        !            25:  *
        !            26:  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
        !            27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            28:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            29:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
        !            30:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            31:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            32:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            33:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            34:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            35:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            36:  * POSSIBILITY OF SUCH DAMAGE.
        !            37:  */
        !            38:
        !            39: #ifndef _DEV_I2C_I2C_IO_H_
        !            40: #define        _DEV_I2C_I2C_IO_H_
        !            41:
        !            42: #include <sys/ioccom.h>
        !            43:
        !            44: /* I2C bus address. */
        !            45: typedef uint16_t i2c_addr_t;
        !            46:
        !            47: /* High-level I2C operations. */
        !            48: typedef enum {
        !            49:        I2C_OP_READ             = 0,
        !            50:        I2C_OP_READ_WITH_STOP   = 1,
        !            51:        I2C_OP_WRITE            = 2,
        !            52:        I2C_OP_WRITE_WITH_STOP  = 3,
        !            53: } i2c_op_t;
        !            54:
        !            55: #define        I2C_OP_READ_P(x)        (((int)(x) & 2) == 0)
        !            56: #define        I2C_OP_WRITE_P(x)       (! I2C_OP_READ_P(x))
        !            57: #define        I2C_OP_STOP_P(x)        (((int)(x) & 1) != 0)
        !            58:
        !            59: /*
        !            60:  * This structure describes a single I2C control script fragment.
        !            61:  *
        !            62:  * Note that use of this scripted API allows for support of automated
        !            63:  * SMBus controllers.  The following table maps SMBus operations to
        !            64:  * script fragment configuration:
        !            65:  *
        !            66:  *     SMBus "write byte":             I2C_OP_WRITE_WITH_STOP
        !            67:  *                                     cmdlen = 1
        !            68:  *
        !            69:  *     SMBus "read byte":              I2C_OP_READ_WITH_STOP
        !            70:  *                                     cmdlen = 1
        !            71:  *
        !            72:  *     SMBus "receive byte":           I2C_OP_READ_WITH_STOP
        !            73:  *                                     cmdlen = 0
        !            74:  *
        !            75:  * Note that while each of these 3 SMBus operations implies a STOP
        !            76:  * (which an automated controller will likely perform automatically),
        !            77:  * non-SMBus clients may continue to function even if they issue
        !            78:  * I2C_OP_WRITE and I2C_OP_READ.
        !            79:  */
        !            80:
        !            81: #ifdef notyet
        !            82: /*
        !            83:  * I2C_IOCTL_EXEC:
        !            84:  *
        !            85:  *     User ioctl to execute an i2c operation.
        !            86:  */
        !            87: typedef struct i2c_ioctl_exec {
        !            88:        i2c_op_t iie_op;                /* operation to perform */
        !            89:        i2c_addr_t iie_addr;            /* address of device */
        !            90:        const void *iie_cmd;            /* pointer to command */
        !            91:        size_t iie_cmdlen;              /* length of command */
        !            92:        void *iie_buf;                  /* pointer to data buffer */
        !            93:        size_t iie_buflen;              /* length of data buffer */
        !            94: } i2c_ioctl_exec_t;
        !            95: #define        I2C_EXEC_MAX_CMDLEN     32
        !            96: #define        I2C_EXEC_MAX_BUFLEN     32
        !            97:
        !            98: #define        I2C_IOCTL_EXEC           _IOW('I', 0, i2c_ioctl_exec_t)
        !            99: #endif
        !           100:
        !           101: #endif /* _DEV_I2C_I2C_IO_H_ */

CVSweb