summaryrefslogtreecommitdiff
path: root/target/linux/etrax/files-2.6.25/arch/cris/arch-v10/drivers/etraxi2c.h
diff options
context:
space:
mode:
authorclaudio <claudio@3c298f89-4303-0410-b956-a3cf2f4a3e73>2009-04-09 16:18:45 +0000
committerclaudio <claudio@3c298f89-4303-0410-b956-a3cf2f4a3e73>2009-04-09 16:18:45 +0000
commit409fb7adfc2c6de59b2e05311169eb19fd62093d (patch)
tree1c7d1b3c3379effbd4318114340fad01fb277f5c /target/linux/etrax/files-2.6.25/arch/cris/arch-v10/drivers/etraxi2c.h
parent43e3feff80d764f2805bcb49d31971c050016fa9 (diff)
move etrax generic files to specific kernel version
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@15173 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/etrax/files-2.6.25/arch/cris/arch-v10/drivers/etraxi2c.h')
-rw-r--r--target/linux/etrax/files-2.6.25/arch/cris/arch-v10/drivers/etraxi2c.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/target/linux/etrax/files-2.6.25/arch/cris/arch-v10/drivers/etraxi2c.h b/target/linux/etrax/files-2.6.25/arch/cris/arch-v10/drivers/etraxi2c.h
new file mode 100644
index 0000000000..4235086d5e
--- /dev/null
+++ b/target/linux/etrax/files-2.6.25/arch/cris/arch-v10/drivers/etraxi2c.h
@@ -0,0 +1,49 @@
+#ifndef _LINUX_ETRAXI2C_H
+#define _LINUX_ETRAXI2C_H
+
+/* etraxi2c _IOC_TYPE, bits 8 to 15 in ioctl cmd */
+
+#define ETRAXI2C_IOCTYPE 44
+
+/* supported ioctl _IOC_NR's */
+
+/* in write operations, the argument contains both i2c
+ * slave, register and value.
+ */
+
+#define I2C_WRITEARG(slave, reg, value) (((slave) << 16) | ((reg) << 8) | (value))
+#define I2C_READARG(slave, reg) (((slave) << 16) | ((reg) << 8))
+
+#define I2C_ARGSLAVE(arg) ((arg) >> 16)
+#define I2C_ARGREG(arg) (((arg) >> 8) & 0xff)
+#define I2C_ARGVALUE(arg) ((arg) & 0xff)
+
+#define I2C_WRITEREG 0x1 /* write to an I2C register */
+#define I2C_READREG 0x2 /* read from an I2C register */
+
+/*
+EXAMPLE usage:
+
+ i2c_arg = I2C_WRITEARG(STA013_WRITE_ADDR, reg, val);
+ ioctl(fd, _IO(ETRAXI2C_IOCTYPE, I2C_WRITEREG), i2c_arg);
+
+ i2c_arg = I2C_READARG(STA013_READ_ADDR, reg);
+ val = ioctl(fd, _IO(ETRAXI2C_IOCTYPE, I2C_READREG), i2c_arg);
+
+*/
+
+/* Extended part */
+#define I2C_READ 0x4 /* reads from I2C device */
+#define I2C_WRITE 0x3 /* writes to I2C device */
+#define I2C_WRITEREAD 0x5 /* writes to I2C device where to start reading */
+
+typedef struct _I2C_DATA
+{
+ unsigned char slave; /* I2C address (8-bit representation) of slave device */
+ unsigned char wbuf[256]; /* Write buffer (length = 256 bytes) */
+ unsigned int wlen; /* Number of bytes to write from wbuf[] */
+ unsigned char rbuf[256]; /* Read buffer (length = 256 bytes) */
+ unsigned int rlen; /* Number of bytes to read into rbuf[] */
+} I2C_DATA;
+
+#endif