⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i2c-algo-gm.h

📁 基于GM8180,NSF2200F的I2C驱动,LINUX平台
💻 H
字号:
/* ------------------------------------------------------------------------- *//* i2c-algo-gm.h i2c driver algorithms for GM IIC adapters                   *//* ------------------------------------------------------------------------- *//*   Copyright (C) 1995-97 Simon G. Vogl                   1998-99 Hans Berglund    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                *//* ------------------------------------------------------------------------- *//* With some changes from Ky鰏ti M鋖kki <kmalkki@cc.hut.fi> and even   Frodo Looijaard <frodol@dds.nl> *//* Modifications by MontaVista Software, 2001   Changes made to support the ITE IIC peripheral *//* Modify By Ken.Hsieh */#ifndef I2C_ALGO_GM_H#define I2C_ALGO_GM_H 1#include <linux/i2c.h>#include <asm/arch/platform/spec.h>/* Example of a sequential read request:	struct i2c_iic_msg s_msg; 	s_msg.addr=device_address;	s_msg.len=length;	s_msg.buf=buffer;	s_msg.waddr=word_address;	ioctl(file,I2C_SREAD, &s_msg); */#define I2C_SREAD	0x780	/* SREAD ioctl command */struct i2c_iic_msg {	__u16 addr;	/* device address */	__u16 waddr;	/* word address */	short len;	/* msg length */	char *buf;	/* pointer to msg data */};struct i2c_GM_msg {	unsigned char addr;	/* device address */	unsigned char waddr;	/* word address */	short len;	/* msg length */	char *buf;	/* pointer to msg data */	int clockdiv;	/* for clock div */        int multiread_once ; /* decide to read multibyte once. if 0: read one byte by one; if 1: read multibyte once*/};struct GMi2c_info {    	struct i2c_adapter	    adap;	void *data;	/* private data for the adapter			*/			/* some data fields that are used by all types	*/			/* these data fields are readonly to the public	*/			/* and can be set via the i2c_ioctl call	*/	unsigned int flags;/* flags specifying div. data		*/	int client_count;    }; struct GMi2c_i2c_client {	unsigned int flags;		/* div., see below		*/	unsigned short addr;		/* chip address - NOTE: 7bit 	*/					/* addresses are stored in the	*/					/* _LOWER_ 7 bits		*/	struct GMi2c_info *adapter;     /* the adapter we sit on	*/	struct i2c_driver *driver;	/* and our access routines	*/	int usage_count;		/* How many accesses currently  */					/* to the client		*/	struct device dev;		/* the device structure		*/	struct list_head list;	char name[I2C_NAME_SIZE];	struct completion released;    };    struct i2c_algo_iic_data {	void *data;		/* private data for lolevel routines	*/	void (*setiic) (void *data, int ctl, int val);	int  (*getiic) (void *data, int ctl);	int  (*getown) (void *data);	int  (*getclock) (void *data);	void (*waitforpin) (void);     	/* local settings */	int udelay;	int mdelay;	int timeout;};int i2c_iic_add_bus(struct i2c_adapter *);int i2c_iic_del_bus(struct i2c_adapter *);int i2c_xfer(struct i2c_adapter *,struct i2c_msg msgs[],int num);/* EEPROM Configuration */#define CONFIG_START_ADDR           0x0#define I2C_ADDR                    I2C_FTI2C010_VA_BASE#define I2C_ALIEN                   0x2000  /* Arbitration lose */#define I2C_SAMIEN                  0x1000  /* slave address match */#define I2C_STOPIEN                 0x800   /* stop condition */#define I2C_BERRIEN                 0x400   /* non ACK response */#define I2C_DRIEN                   0x200   /* data receive */#define I2C_DTIEN                   0x100   /* data transmit */#define I2C_TBEN                    0x80    /* transfer byte enable */#define I2C_ACKNAK                  0x40    /* ack sent */#define I2C_STOP                    0x20    /* stop */#define I2C_START                   0x10    /* start */#define I2C_GCEN                    0x8     /* general call */#define I2C_SCLEN                   0x4     /* enable clock */#define I2C_I2CEN                   0x2     /* enable I2C */#define I2C_I2CRST                  0x1     /* reset I2C */#define I2C_ENABLE                  (I2C_ALIEN|I2C_SAMIEN|I2C_STOPIEN|I2C_BERRIEN|I2C_DRIEN|I2C_DTIEN|I2C_SCLEN|I2C_I2CEN)//controller#define EEPROM_ID_WRITE     0xa8#define EEPROM_ID_READ	    0xa9#endif /* I2C_ALGO_GM_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -