etraxi2c.h 980 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* $Id: etraxi2c.h,v 1.1 2001/01/18 15:49:57 bjornw Exp $ */
  2. #ifndef _LINUX_ETRAXI2C_H
  3. #define _LINUX_ETRAXI2C_H
  4. /* etraxi2c _IOC_TYPE, bits 8 to 15 in ioctl cmd */
  5. #define ETRAXI2C_IOCTYPE 44
  6. /* supported ioctl _IOC_NR's */
  7. /* in write operations, the argument contains both i2c
  8. * slave, register and value.
  9. */
  10. #define I2C_WRITEARG(slave, reg, value) (((slave) << 16) | ((reg) << 8) | (value))
  11. #define I2C_READARG(slave, reg) (((slave) << 16) | ((reg) << 8))
  12. #define I2C_ARGSLAVE(arg) ((arg) >> 16)
  13. #define I2C_ARGREG(arg) (((arg) >> 8) & 0xff)
  14. #define I2C_ARGVALUE(arg) ((arg) & 0xff)
  15. #define I2C_WRITEREG 0x1 /* write to an i2c register */
  16. #define I2C_READREG 0x2 /* read from an i2c register */
  17. /*
  18. EXAMPLE usage:
  19. i2c_arg = I2C_WRITEARG(STA013_WRITE_ADDR, reg, val);
  20. ioctl(fd, _IO(ETRAXI2C_IOCTYPE, I2C_WRITEREG), i2c_arg);
  21. i2c_arg = I2C_READARG(STA013_READ_ADDR, reg);
  22. val = ioctl(fd, _IO(ETRAXI2C_IOCTYPE, I2C_READREG), i2c_arg);
  23. */
  24. #endif