Changeset 6048
- Timestamp:
- 04/26/12 12:10:22 (13 months ago)
- Location:
- i2c-tools/trunk
- Files:
-
- 15 modified
-
CHANGES (modified) (1 diff)
-
eepromer/24cXX.c (modified) (2 diffs)
-
eepromer/24cXX.h (modified) (1 diff)
-
eepromer/eeprom.c (modified) (2 diffs)
-
eepromer/eepromer.c (modified) (2 diffs)
-
include/Module.mk (modified) (3 diffs)
-
include/linux/i2c-dev.h (modified) (2 diffs)
-
py-smbus/Module.mk (modified) (1 diff)
-
py-smbus/smbusmodule.c (modified) (1 diff)
-
tools/Module.mk (modified) (2 diffs)
-
tools/i2cbusses.c (modified) (3 diffs)
-
tools/i2cdetect.c (modified) (3 diffs)
-
tools/i2cdump.c (modified) (3 diffs)
-
tools/i2cget.c (modified) (3 diffs)
-
tools/i2cset.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
i2c-tools/trunk/CHANGES
r6047 r6048 6 6 Decode bus width extension of DDR3 SDRAM 7 7 i2c-dev.h: Minimize differences with kernel flavor 8 Move SMBus helper functions to include/i2c/smbus.h 8 9 i2c-stub-from-dump: Be more tolerant on input dump format 9 10 -
i2c-tools/trunk/eepromer/24cXX.c
r4230 r6048 19 19 #include <stdlib.h> 20 20 #include <linux/fs.h> 21 #include <linux/i2c.h> 22 #include <linux/i2c-dev.h> 21 23 #include <sys/types.h> 22 24 #include <sys/ioctl.h> … … 24 26 #include <assert.h> 25 27 #include <string.h> 28 #include <i2c/smbus.h> 26 29 #include "24cXX.h" 27 30 -
i2c-tools/trunk/eepromer/24cXX.h
r4495 r6048 16 16 #ifndef _24CXX_H_ 17 17 #define _24CXX_H_ 18 #include <linux/ i2c-dev.h>18 #include <linux/types.h> 19 19 20 20 #define EEPROM_TYPE_UNKNOWN 0 -
i2c-tools/trunk/eepromer/eeprom.c
r5538 r6048 3 3 Of course the program is provided without warranty of any kind. 4 4 */ 5 #include <sys/ioctl.h> 5 6 #include <errno.h> 6 7 #include <stdio.h> … … 10 11 #include <string.h> 11 12 #include <time.h> 13 #include <linux/i2c.h> 12 14 #include <linux/i2c-dev.h> 13 15 -
i2c-tools/trunk/eepromer/eepromer.c
r5746 r6048 1 #include <sys/ioctl.h> 1 2 #include <errno.h> 2 3 #include <string.h> … … 6 7 #include <fcntl.h> 7 8 #include <time.h> 9 #include <linux/i2c.h> 8 10 #include <linux/i2c-dev.h> 9 11 -
i2c-tools/trunk/include/Module.mk
r5594 r6048 1 1 # Linux I2C header files 2 2 # 3 # Copyright (C) 2007 Jean Delvare <khali@linux-fr.org>3 # Copyright (C) 2007, 2012 Jean Delvare <khali@linux-fr.org> 4 4 # 5 5 # This program is free software; you can redistribute it and/or modify … … 10 10 INCLUDE_DIR := include 11 11 12 INCLUDE_TARGETS := linux/i2c-dev.h12 INCLUDE_TARGETS := i2c/smbus.h 13 13 14 14 # … … 17 17 18 18 install-include: $(addprefix $(INCLUDE_DIR)/,$(INCLUDE_TARGETS)) 19 $(INSTALL_DIR) $(DESTDIR)$(incdir)/ linux19 $(INSTALL_DIR) $(DESTDIR)$(incdir)/i2c 20 20 for file in $(INCLUDE_TARGETS) ; do \ 21 21 $(INSTALL_DATA) $(INCLUDE_DIR)/$$file $(DESTDIR)$(incdir)/$$file ; done -
i2c-tools/trunk/include/linux/i2c-dev.h
r6047 r6048 25 25 26 26 #include <linux/types.h> 27 #include <sys/ioctl.h>28 29 30 /* -- i2c.h -- */31 32 33 /*34 * I2C Message - used for pure i2c transaction, also from /dev interface35 */36 struct i2c_msg {37 __u16 addr; /* slave address */38 unsigned short flags;39 #define I2C_M_TEN 0x10 /* we have a ten bit chip address */40 #define I2C_M_RD 0x0141 #define I2C_M_NOSTART 0x400042 #define I2C_M_REV_DIR_ADDR 0x200043 #define I2C_M_IGNORE_NAK 0x100044 #define I2C_M_NO_RD_ACK 0x080045 short len; /* msg length */46 char *buf; /* pointer to msg data */47 };48 49 /* To determine what functionality is present */50 51 #define I2C_FUNC_I2C 0x0000000152 #define I2C_FUNC_10BIT_ADDR 0x0000000253 #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */54 #define I2C_FUNC_SMBUS_PEC 0x0000000855 #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */56 #define I2C_FUNC_SMBUS_QUICK 0x0001000057 #define I2C_FUNC_SMBUS_READ_BYTE 0x0002000058 #define I2C_FUNC_SMBUS_WRITE_BYTE 0x0004000059 #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x0008000060 #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x0010000061 #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x0020000062 #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x0040000063 #define I2C_FUNC_SMBUS_PROC_CALL 0x0080000064 #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x0100000065 #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x0200000066 #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */67 #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */68 69 #define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \70 I2C_FUNC_SMBUS_WRITE_BYTE)71 #define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \72 I2C_FUNC_SMBUS_WRITE_BYTE_DATA)73 #define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \74 I2C_FUNC_SMBUS_WRITE_WORD_DATA)75 #define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \76 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)77 #define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \78 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)79 80 /* Old name, for compatibility */81 #define I2C_FUNC_SMBUS_HWPEC_CALC I2C_FUNC_SMBUS_PEC82 83 /*84 * Data for SMBus Messages85 */86 #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */87 #define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */88 union i2c_smbus_data {89 __u8 byte;90 __u16 word;91 __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */92 /* and one more for PEC */93 };94 95 /* smbus_access read or write markers */96 #define I2C_SMBUS_READ 197 #define I2C_SMBUS_WRITE 098 99 /* SMBus transaction types (size parameter in the above functions)100 Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */101 #define I2C_SMBUS_QUICK 0102 #define I2C_SMBUS_BYTE 1103 #define I2C_SMBUS_BYTE_DATA 2104 #define I2C_SMBUS_WORD_DATA 3105 #define I2C_SMBUS_PROC_CALL 4106 #define I2C_SMBUS_BLOCK_DATA 5107 #define I2C_SMBUS_I2C_BLOCK_BROKEN 6108 #define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */109 #define I2C_SMBUS_I2C_BLOCK_DATA 8110 27 111 28 … … 153 70 154 71 155 static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,156 int size, union i2c_smbus_data *data)157 {158 struct i2c_smbus_ioctl_data args;159 160 args.read_write = read_write;161 args.command = command;162 args.size = size;163 args.data = data;164 return ioctl(file,I2C_SMBUS,&args);165 }166 167 168 static inline __s32 i2c_smbus_write_quick(int file, __u8 value)169 {170 return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL);171 }172 173 static inline __s32 i2c_smbus_read_byte(int file)174 {175 union i2c_smbus_data data;176 if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data))177 return -1;178 else179 return 0x0FF & data.byte;180 }181 182 static inline __s32 i2c_smbus_write_byte(int file, __u8 value)183 {184 return i2c_smbus_access(file,I2C_SMBUS_WRITE,value,185 I2C_SMBUS_BYTE,NULL);186 }187 188 static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)189 {190 union i2c_smbus_data data;191 if (i2c_smbus_access(file,I2C_SMBUS_READ,command,192 I2C_SMBUS_BYTE_DATA,&data))193 return -1;194 else195 return 0x0FF & data.byte;196 }197 198 static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,199 __u8 value)200 {201 union i2c_smbus_data data;202 data.byte = value;203 return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,204 I2C_SMBUS_BYTE_DATA, &data);205 }206 207 static inline __s32 i2c_smbus_read_word_data(int file, __u8 command)208 {209 union i2c_smbus_data data;210 if (i2c_smbus_access(file,I2C_SMBUS_READ,command,211 I2C_SMBUS_WORD_DATA,&data))212 return -1;213 else214 return 0x0FFFF & data.word;215 }216 217 static inline __s32 i2c_smbus_write_word_data(int file, __u8 command,218 __u16 value)219 {220 union i2c_smbus_data data;221 data.word = value;222 return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,223 I2C_SMBUS_WORD_DATA, &data);224 }225 226 static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)227 {228 union i2c_smbus_data data;229 data.word = value;230 if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,231 I2C_SMBUS_PROC_CALL,&data))232 return -1;233 else234 return 0x0FFFF & data.word;235 }236 237 238 /* Returns the number of read bytes */239 static inline __s32 i2c_smbus_read_block_data(int file, __u8 command,240 __u8 *values)241 {242 union i2c_smbus_data data;243 int i;244 if (i2c_smbus_access(file,I2C_SMBUS_READ,command,245 I2C_SMBUS_BLOCK_DATA,&data))246 return -1;247 else {248 for (i = 1; i <= data.block[0]; i++)249 values[i-1] = data.block[i];250 return data.block[0];251 }252 }253 254 static inline __s32 i2c_smbus_write_block_data(int file, __u8 command,255 __u8 length, const __u8 *values)256 {257 union i2c_smbus_data data;258 int i;259 if (length > 32)260 length = 32;261 for (i = 1; i <= length; i++)262 data.block[i] = values[i-1];263 data.block[0] = length;264 return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,265 I2C_SMBUS_BLOCK_DATA, &data);266 }267 268 /* Returns the number of read bytes */269 /* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you270 ask for less than 32 bytes, your code will only work with kernels271 2.6.23 and later. */272 static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command,273 __u8 length, __u8 *values)274 {275 union i2c_smbus_data data;276 int i;277 278 if (length > 32)279 length = 32;280 data.block[0] = length;281 if (i2c_smbus_access(file,I2C_SMBUS_READ,command,282 length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :283 I2C_SMBUS_I2C_BLOCK_DATA,&data))284 return -1;285 else {286 for (i = 1; i <= data.block[0]; i++)287 values[i-1] = data.block[i];288 return data.block[0];289 }290 }291 292 static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,293 __u8 length,294 const __u8 *values)295 {296 union i2c_smbus_data data;297 int i;298 if (length > 32)299 length = 32;300 for (i = 1; i <= length; i++)301 data.block[i] = values[i-1];302 data.block[0] = length;303 return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,304 I2C_SMBUS_I2C_BLOCK_BROKEN, &data);305 }306 307 /* Returns the number of read bytes */308 static inline __s32 i2c_smbus_block_process_call(int file, __u8 command,309 __u8 length, __u8 *values)310 {311 union i2c_smbus_data data;312 int i;313 if (length > 32)314 length = 32;315 for (i = 1; i <= length; i++)316 data.block[i] = values[i-1];317 data.block[0] = length;318 if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,319 I2C_SMBUS_BLOCK_PROC_CALL,&data))320 return -1;321 else {322 for (i = 1; i <= data.block[0]; i++)323 values[i-1] = data.block[i];324 return data.block[0];325 }326 }327 328 329 72 #endif /* _LINUX_I2C_DEV_H */ -
i2c-tools/trunk/py-smbus/Module.mk
r5611 r6048 15 15 CPPFLAGS="$(CPPFLAGS) -I../include" $(PYTHON) setup.py 16 16 17 all-python: $(INCLUDE_DIR)/ linux/i2c-dev.h17 all-python: $(INCLUDE_DIR)/i2c/smbus.h 18 18 $(DISTUTILS) build 19 19 -
i2c-tools/trunk/py-smbus/smbusmodule.c
r5619 r6048 19 19 #include <Python.h> 20 20 #include "structmember.h" 21 #include <sys/ioctl.h> 21 22 #include <stdlib.h> 22 23 #include <stdio.h> 23 24 #include <fcntl.h> 25 #include <linux/i2c.h> 24 26 #include <linux/i2c-dev.h> 27 #include <i2c/smbus.h> 25 28 26 29 /* -
i2c-tools/trunk/tools/Module.mk
r5610 r6048 1 1 # I2C tools for Linux 2 2 # 3 # Copyright (C) 2007 Jean Delvare <khali@linux-fr.org>3 # Copyright (C) 2007, 2012 Jean Delvare <khali@linux-fr.org> 4 4 # 5 5 # This program is free software; you can redistribute it and/or modify … … 36 36 # 37 37 38 $(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/ linux/i2c-dev.h38 $(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/i2c/smbus.h 39 39 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 40 40 41 $(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/ linux/i2c-dev.h41 $(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.h 42 42 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 43 43 44 $(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/ linux/i2c-dev.h44 $(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.h 45 45 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 46 46 47 $(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/ linux/i2c-dev.h47 $(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.h 48 48 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 49 49 50 $(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/linux/i2c-dev.h50 $(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h 51 51 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 52 52 -
i2c-tools/trunk/tools/i2cbusses.c
r5885 r6048 5 5 Copyright (c) 1999-2003 Frodo Looijaard <frodol@dds.nl> and 6 6 Mark D. Studebaker <mdsxyz123@yahoo.com> 7 Copyright (C) 2008-201 0Jean Delvare <khali@linux-fr.org>7 Copyright (C) 2008-2012 Jean Delvare <khali@linux-fr.org> 8 8 9 9 This program is free software; you can redistribute it and/or modify … … 29 29 #include <sys/stat.h> 30 30 #include <sys/param.h> /* for NAME_MAX */ 31 #include <sys/ioctl.h> 31 32 #include <string.h> 32 33 #include <strings.h> /* for strcasecmp() */ … … 39 40 #include <errno.h> 40 41 #include "i2cbusses.h" 42 #include <linux/i2c.h> 41 43 #include <linux/i2c-dev.h> 42 44 -
i2c-tools/trunk/tools/i2cdetect.c
r5885 r6048 3 3 Copyright (C) 1999-2004 Frodo Looijaard <frodol@dds.nl>, and 4 4 Mark D. Studebaker <mdsxyz123@yahoo.com> 5 Copyright (C) 2004-201 0Jean Delvare <khali@linux-fr.org>5 Copyright (C) 2004-2012 Jean Delvare <khali@linux-fr.org> 6 6 7 7 This program is free software; you can redistribute it and/or modify … … 21 21 */ 22 22 23 #include <sys/ioctl.h> 23 24 #include <errno.h> 24 25 #include <string.h> … … 26 27 #include <stdlib.h> 27 28 #include <unistd.h> 29 #include <linux/i2c.h> 28 30 #include <linux/i2c-dev.h> 31 #include <i2c/smbus.h> 29 32 #include "i2cbusses.h" 30 33 #include "../version.h" -
i2c-tools/trunk/tools/i2cdump.c
r5885 r6048 3 3 Copyright (C) 2002-2003 Frodo Looijaard <frodol@dds.nl>, and 4 4 Mark D. Studebaker <mdsxyz123@yahoo.com> 5 Copyright (C) 2004-201 0Jean Delvare <khali@linux-fr.org>5 Copyright (C) 2004-2012 Jean Delvare <khali@linux-fr.org> 6 6 7 7 This program is free software; you can redistribute it and/or modify … … 21 21 */ 22 22 23 #include <sys/ioctl.h> 23 24 #include <errno.h> 24 25 #include <string.h> … … 26 27 #include <stdlib.h> 27 28 #include <unistd.h> 29 #include <linux/i2c.h> 28 30 #include <linux/i2c-dev.h> 31 #include <i2c/smbus.h> 29 32 #include "i2cbusses.h" 30 33 #include "util.h" -
i2c-tools/trunk/tools/i2cget.c
r5885 r6048 1 1 /* 2 2 i2cget.c - A user-space program to read an I2C register. 3 Copyright (C) 2005-201 0Jean Delvare <khali@linux-fr.org>3 Copyright (C) 2005-2012 Jean Delvare <khali@linux-fr.org> 4 4 5 5 Based on i2cset.c: … … 24 24 */ 25 25 26 #include <sys/ioctl.h> 26 27 #include <errno.h> 27 28 #include <string.h> … … 29 30 #include <stdlib.h> 30 31 #include <unistd.h> 32 #include <linux/i2c.h> 31 33 #include <linux/i2c-dev.h> 34 #include <i2c/smbus.h> 32 35 #include "i2cbusses.h" 33 36 #include "util.h" -
i2c-tools/trunk/tools/i2cset.c
r5927 r6048 3 3 Copyright (C) 2001-2003 Frodo Looijaard <frodol@dds.nl>, and 4 4 Mark D. Studebaker <mdsxyz123@yahoo.com> 5 Copyright (C) 2004-201 0Jean Delvare <khali@linux-fr.org>5 Copyright (C) 2004-2012 Jean Delvare <khali@linux-fr.org> 6 6 7 7 This program is free software; you can redistribute it and/or modify … … 21 21 */ 22 22 23 #include <sys/ioctl.h> 23 24 #include <errno.h> 24 25 #include <string.h> … … 26 27 #include <stdlib.h> 27 28 #include <unistd.h> 29 #include <linux/i2c.h> 28 30 #include <linux/i2c-dev.h> 31 #include <i2c/smbus.h> 29 32 #include "i2cbusses.h" 30 33 #include "util.h"
