00001 /* clib/include/bus/iic.h 00002 * 00003 * ABLE i2c bus access 00004 * 00005 * Copyright 2003 Simtec Electronics 00006 * 00007 * Permission is hereby granted, free of charge, to any person 00008 * obtaining a copy of this software and associated documentation 00009 * files (the "Software"), to deal in the Software without 00010 * restriction, including without limitation the rights to use, copy, 00011 * modify, merge, publish, distribute, sublicense, and/or sell copies 00012 * of the Software, and to permit persons to whom the Software is 00013 * furnished to do so, subject to the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be 00016 * included in all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00019 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00020 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00021 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00022 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00023 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00024 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00025 * SOFTWARE. 00026 * 00027 */ 00028 00029 #ifndef _ABLE_CLIB_BUS_IIC_H 00030 #define _ABLE_CLIB_BUS_IIC_H __FILE__ 00031 00032 enum i2cdev_regaddr_scheme { 00033 I2C_REGADDR_NONE, /* device has no sub-addressing scheme */ 00034 I2C_REGADDR_BYTE, /* byte scheme */ 00035 I2C_REGADDR_CHRONTEL, /* as chrontel */ 00036 I2C_REGADDR_DOUBLEBYTE /* double-byte address, as in 24cxx eeproms */ 00037 }; 00038 00039 #define I2C_ERR_NOACK (-2) 00040 #define I2C_ERR_ARB (-3) 00041 #define I2C_ERR_TIMEOUT (-4) 00042 00043 #define I2C_FLG_DELAY (1) /* use delay field between bytes */ 00044 00045 typedef enum i2cdev_regaddr_scheme i2cdev_regaddr_scheme_t; 00046 00047 00048 struct i2cdev_defn { 00049 struct dev_type type; 00050 unsigned int addr; /* i2c device address */ 00051 i2cdev_regaddr_scheme_t addrscheme; /* default scheme */ 00052 unsigned int flags; 00053 unsigned int delay; /* inter-byte delay */ 00054 }; 00055 00056 struct busop_arg_i2c { 00057 struct i2cdev_defn defn; 00058 io_reg_t reg; 00059 int size; 00060 void *ptr; 00061 }; 00062 00063 #endif /* _ABLE_CLIB_BUS_IIC_H */