Add i2c driver (to etrax) improved by Geert Vancompernolle
SVN-Revision: 14462
This commit is contained in:
parent
e5c9f00637
commit
8708c1f092
|
@ -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
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef _I2C_ERRNO_H
|
||||
#define _I2C_ERRNO_H
|
||||
|
||||
#define EI2CNOERRORS 0 /* All fine */
|
||||
#define EI2CBUSNFREE 1 /* I2C bus not free */
|
||||
#define EI2CWADDRESS 2 /* Address write failed */
|
||||
#define EI2CRADDRESS 3 /* Address read failed */
|
||||
#define EI2CSENDDATA 4 /* Sending data failed */
|
||||
#define EI2CRECVDATA 5 /* Receiving data failed */
|
||||
#define EI2CSTRTCOND 6 /* Start condition failed */
|
||||
#define EI2CRSTACOND 7 /* Repeated start condition failed */
|
||||
#define EI2CSTOPCOND 8 /* Stop condition failed */
|
||||
#define EI2CNOSNDBYT 9 /* Number of send bytes is 0, while there's a send buffer defined */
|
||||
#define EI2CNOSNDBUF 10 /* No send buffer defined, while number of send bytes is not 0 */
|
||||
#define EI2CNORCVBYT 11 /* Number of receive bytes is 0, while there's a receive buffer defined */
|
||||
#define EI2CNORCVBUF 12 /* No receive buffer defined, while number of receive bytes is not 0 */
|
||||
#define EI2CNOACKNLD 13 /* No acknowledge received from slave */
|
||||
#define EI2CNOMNUMBR 14 /* No MAJOR number received from kernel while registering the device */
|
||||
|
||||
#endif /* _I2C_ERRNO_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
|||
/* $Id: i2c.h,v 1.3 2004/05/28 09:26:59 starvik Exp $ */
|
||||
#ifndef _I2C_H
|
||||
#define _I2C_H
|
||||
|
||||
int i2c_init(void);
|
||||
|
||||
/* High level I2C actions */
|
||||
int i2c_writereg(unsigned char theSlave, unsigned char theReg, unsigned char theValue);
|
||||
unsigned char i2c_readreg(unsigned char theSlave, unsigned char theReg);
|
||||
|
||||
/* Low level I2C */
|
||||
int i2c_start(void);
|
||||
int i2c_stop(void);
|
||||
int i2c_outbyte(unsigned char x);
|
||||
unsigned char i2c_inbyte(void);
|
||||
int i2c_getack(void);
|
||||
void i2c_sendack(void);
|
||||
void i2c_sendnack(void);
|
||||
|
||||
/**GVC**/
|
||||
/* New low level I2C functions */
|
||||
int i2c_read( unsigned char slave, unsigned char* rbuf, unsigned char rlen );
|
||||
int i2c_write( unsigned char slave, unsigned char* wbuf, unsigned char wlen );
|
||||
int i2c_writeread( unsigned char slave
|
||||
, unsigned char* wbuf
|
||||
, unsigned char wlen
|
||||
, unsigned char* rbuf
|
||||
, unsigned char rlen
|
||||
);
|
||||
/**END GVC**/
|
||||
#endif /* _I2C_H */
|
|
@ -0,0 +1,45 @@
|
|||
Index: linux-2.6.25.20/arch/cris/arch-v10/drivers/Kconfig
|
||||
===================================================================
|
||||
--- linux-2.6.25.20.orig/arch/cris/arch-v10/drivers/Kconfig 2009-02-09 09:30:40.000000000 +0100
|
||||
+++ linux-2.6.25.20/arch/cris/arch-v10/drivers/Kconfig 2009-02-09 21:23:12.000000000 +0100
|
||||
@@ -450,11 +450,18 @@
|
||||
i2c_arg = I2C_READARG(STA013_READ_ADDR, reg);
|
||||
val = ioctl(fd, _IO(ETRAXI2C_IOCTYPE, I2C_READREG), i2c_arg);
|
||||
|
||||
+config ETRAX_I2C_GVC
|
||||
+ bool "I2C GVC support"
|
||||
+ depends on ETRAX_ARCH_V10 && !ETRAX_I2C
|
||||
+ select ETRAX_I2C_USES_PB_NOT_PB_I2C
|
||||
+ help
|
||||
+ Enables an I2C driver with Geert Vancompernolle improvement.
|
||||
+
|
||||
# this is true for most products since PB-I2C seems to be somewhat
|
||||
# flawed..
|
||||
config ETRAX_I2C_USES_PB_NOT_PB_I2C
|
||||
bool "I2C uses PB not PB-I2C"
|
||||
- depends on ETRAX_I2C
|
||||
+ depends on ETRAX_I2C || ETRAX_I2C_GVC
|
||||
help
|
||||
Select whether to use the special I2C mode in the PB I/O register or
|
||||
not. This option needs to be selected in order to use some drivers
|
||||
@@ -478,7 +485,7 @@
|
||||
|
||||
config ETRAX_I2C_EEPROM
|
||||
bool "I2C EEPROM (non-volatile RAM) support"
|
||||
- depends on ETRAX_I2C
|
||||
+ depends on ETRAX_I2C || ETRAX_I2C_GVC
|
||||
help
|
||||
Enables I2C EEPROM (non-volatile RAM) on PB0 and PB1 using the I2C
|
||||
driver. Select size option: Probed, 2k, 8k, 16k.
|
||||
Index: linux-2.6.25.20/arch/cris/arch-v10/drivers/Makefile
|
||||
===================================================================
|
||||
--- linux-2.6.25.20.orig/arch/cris/arch-v10/drivers/Makefile 2009-02-09 09:30:41.000000000 +0100
|
||||
+++ linux-2.6.25.20/arch/cris/arch-v10/drivers/Makefile 2009-02-09 09:35:39.000000000 +0100
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
obj-$(CONFIG_ETRAX_AXISFLASHMAP) += axisflashmap.o
|
||||
obj-$(CONFIG_ETRAX_I2C) += i2c.o
|
||||
+obj-$(CONFIG_ETRAX_I2C_GVC) += i2c_gvc.o
|
||||
obj-$(CONFIG_ETRAX_I2C_EEPROM) += eeprom.o
|
||||
obj-$(CONFIG_ETRAX_GPIO) += gpio.o
|
||||
obj-$(CONFIG_ETRAX_DS1302) += ds1302.o
|
Loading…
Reference in New Issue