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

📄 i2c-aa.h

📁 Dragonball I2C驱动
💻 H
字号:
/******************************************************************************  	Copyright (C) 2002 Motorola GSG-China	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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.*******************************************************************************//************************************************************************ *   File Name : i2c-aa.h *   Description : *   	i2c Adapter/Algorithm Driver Globel Define	 *   Auther *   Data *   ID ************************************************************************/#ifndef _I2C_AA_H#define _I2C_AA_H#include <linux/module.h>#include <asm/arch/hardware.h>#include <linux/i2c.h>#ifdef _DEBUG_CSI#	define CSI_DB(fmt, args...) 	printk("\n[%s]:[line%d]----"fmt, __FILE__, __LINE__, ## args)#	define CSI_LOC			printk(KERN_ERR"\nCurrent Location [%s]:[%d]\n", __FILE__, __LINE__)#	define FUNC_START		printk(KERN_ERR"\n[%s]:start!\n", __FUNCTION__)#	define FUNC_END			printk(KERN_ERR"\n[%s]:end!\n", __FUNCTION__)#	define CLUE(arg)		printk(" %s\n",arg)#else#	define CSI_DB(fmt, args...)#	define CSI_LOC#	define FUNC_START#	define FUNC_END#endif/************************************************************************ * * Typedef *  ************************************************************************/#ifndef BOOLEANtypedef signed char BOOLEAN;typedef unsigned char UINT8;typedef signed char SINT8;typedef unsigned short UINT16;typedef signed short SINT16;typedef unsigned long UINT32;typedef signed long SINT32;typedef volatile BOOLEAN VBOOLEAN;typedef volatile UINT8 VUINT8;typedef volatile SINT8 VSINT8;typedef volatile UINT16 VUINT16;typedef volatile SINT16 VSINT16;typedef volatile UINT32 VUINT32;typedef volatile SINT32 VSINT32;#endif /* BOOLEAN *//************************************************************************ * * 		GPIO *  ************************************************************************/#define PTA_BASE_ADDR           0x0021C000              #define PTA_DDIR                PTA_BASE_ADDR                #define PTA_OCR1                (PTA_BASE_ADDR+0x04)                #define PTA_OCR2                (PTA_BASE_ADDR+0x08)                #define PTA_ICONFA1             (PTA_BASE_ADDR+0x0C)                #define PTA_ICONFA2             (PTA_BASE_ADDR+0x10)                #define PTA_ICONFB1             (PTA_BASE_ADDR+0x14)                #define PTA_ICONFB2             (PTA_BASE_ADDR+0x18)                #define PTA_DR                  (PTA_BASE_ADDR+0x1C)                #define PTA_GIUS                (PTA_BASE_ADDR+0x20)                #define PTA_SSR                 (PTA_BASE_ADDR+0x24)                #define PTA_ICR1                (PTA_BASE_ADDR+0x28)                #define PTA_ICR2                (PTA_BASE_ADDR+0x2C)                #define PTA_IMR                 (PTA_BASE_ADDR+0x30)                #define PTA_ISR                 (PTA_BASE_ADDR+0x34)                #define PTA_GPR                 (PTA_BASE_ADDR+0x38)                #define PTA_SWR                 (PTA_BASE_ADDR+0x3C)                #define PTA_PUEN                (PTA_BASE_ADDR+0x40) #define MX1_REG_PTA_DDIR                (*((volatile unsigned long *)(IO_ADDRESS(PTA_DDIR))))#define MX1_REG_PTA_OCR1                (*((volatile unsigned long *)(IO_ADDRESS(PTA_OCR1))))#define MX1_REG_PTA_OCR2                (*((volatile unsigned long *)(IO_ADDRESS(PTA_OCR2))))#define MX1_REG_PTA_ICONFA1             (*((volatile unsigned long *)(IO_ADDRESS(PTA_ICONFA1))))#define MX1_REG_PTA_ICONFA2             (*((volatile unsigned long *)(IO_ADDRESS(PTA_ICONFA2))))#define MX1_REG_PTA_ICONFB1             (*((volatile unsigned long *)(IO_ADDRESS(PTA_ICONFB1))))#define MX1_REG_PTA_ICONFB2             (*((volatile unsigned long *)(IO_ADDRESS(PTA_ICONFB2))))#define MX1_REG_PTA_DR                  (*((volatile unsigned long *)(IO_ADDRESS(PTA_DR))))#define MX1_REG_PTA_GIUS                (*((volatile unsigned long *)(IO_ADDRESS(PTA_GIUS))))#define MX1_REG_PTA_SSR                 (*((volatile unsigned long *)(IO_ADDRESS(PTA_SSR))))#define MX1_REG_PTA_ICR1                (*((volatile unsigned long *)(IO_ADDRESS(PTA_ICR1))))#define MX1_REG_PTA_ICR2                (*((volatile unsigned long *)(IO_ADDRESS(PTA_ICR2))))#define MX1_REG_PTA_IMR                 (*((volatile unsigned long *)(IO_ADDRESS(PTA_IMR))))#define MX1_REG_PTA_ISR                 (*((volatile unsigned long *)(IO_ADDRESS(PTA_ISR))))#define MX1_REG_PTA_GPR                 (*((volatile unsigned long *)(IO_ADDRESS(PTA_GPR))))#define MX1_REG_PTA_SWR                 (*((volatile unsigned long *)(IO_ADDRESS(PTA_SWR))))#define MX1_REG_PTA_PUEN                (*((volatile unsigned long *)(IO_ADDRESS(PTA_PUEN))))/************************************************************************ * * Define DBMX1 I2C AA hardware dependent information  *  ************************************************************************//* Bit algorithm adapter ID, maybe should define in 'linux/i2c-id.h' *///#define I2C_HW_B_DBMX1	0x12#define I2C_DRIVERID_I2CCSI	0x1001#define I2C_DRIVERID_I2CSSI	0x1002#define I2C_DRIVERID_KEYPAD     0x1003#define I2C_AA_REG_ADDR 	(0x00217000 + 0xF0000000)/* * I2C clock = system clock / 960  (exactly 100k for 96M BCLK) * defined in table 29-4(29.5.2) of DBMX1 user's manual */#define DEFAULT_FREQ 		0x17#define I2C_AA_IRQ 		0x27#define I2C_AA_INTR_MODE	0	//SA_SHIRQ | SA_INTERRUPT///* Slave address of SCM20014 *///#define I2C_CSI_SLAVE_WADD	0x66//#define I2C_CSI_SLAVE_RADD	0x67//#define I2C_ADDR_CMOS_SENSOR	0x66///* Define of Massage Flag *///#define EMBEDDED_REGISTER	0x01//#define I2C_M_READ		0x02//#define I2C_M_WT		0x04// support slave mode read/write, but in DBMX1, useless//#define I2C_S_READ		0x08//#define I2C_S_WRITE		0x10/* Option Code of I2C Adapter/Algorithm I/O control */#define I2C_IO_CHANGE_FREQ 	0xaa#define I2C_IO_GET_STATUS 	0xab#define IADR			0xf0217000#define IFDR			0xf0217004#define I2CR			0xf0217008#define I2SR			0xf021700c#define I2DR			0xf0217010/************************************************************************ * * Struct *  ************************************************************************/struct I2C_AA_REG {	VUINT32 iadr;	VUINT32	ifdr;	VUINT32	i2cr;	VUINT32	i2sr;	VUINT32	i2dr;};unsigned int READREG(unsigned int r){	volatile unsigned int * addr;	addr = (unsigned int *)r;	return *(volatile unsigned int *)addr;}void WRITEREG(unsigned int r, unsigned int val){	volatile unsigned int * addr;	addr = (unsigned int *)r;	*(volatile unsigned int *)addr = val;}/************************************************************************ * 		Functions  ************************************************************************/extern int i2c_smbus_aa_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data * data);extern int i2c_aa_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[ ], int num);extern int i2c_aa_iotcl(struct i2c_adapter * adapter, 			unsigned int cmd, unsigned long arg);#endif /* _I2C_AA_H */	

⌨️ 快捷键说明

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