/***************************************************************************
                          w747_i2c_function.h  -  description
                             -------------------
    begin                : 11¤ë 23 ¤é2004
    copyright            : (C) 2004 by root
    email                : 
 ***************************************************************************/

#ifndef _INCLUDE_W747_I2C_FUNCTION
#define _INCLUDE_W747_I2C_FUNCTION
//----------------------------------------------------------------------
#include <asm/web777.h>

//----------------------------------------------------------------------
#define W747_I2C_REG_BASE		(WEB_SIU3_MMAP_BASE + 0x10E80)

#define W747_I2C_CONFIG_REG		(W747_I2C_REG_BASE + 0x0)
#define W747_I2C_CLKDIV_REG		(W747_I2C_REG_BASE + 0x4)
#define W747_I2C_DEVADR_REG		(W747_I2C_REG_BASE + 0x8)
#define W747_I2C_ADR_REG		(W747_I2C_REG_BASE + 0xC)
#define W747_I2C_DATAOUT_REG    (W747_I2C_REG_BASE + 0x10)
#define W747_I2C_DATAIN_REG		(W747_I2C_REG_BASE + 0x14)
#define W747_I2C_STATUS_REG		(W747_I2C_REG_BASE + 0x18)
#define W747_I2C_SDEN_REG		(W747_I2C_REG_BASE + 0x1C)
#define W747_I2C_BYTCNT_REG		(W747_I2C_REG_BASE + 0x20)

#define WR_DELAY                	0x40000
#define I2C_STATUS_TIMEOUT      	0x40000

#define TYPE_EEPROM                     0x00
#define TYPE_THERMAL                    0x01

#define THERMAL_CFG                     0x01    //read write 8 bit ,but no write function for it ,because use default
//----------------------------------------------------------------------
void w747_init_i2c(unsigned int config, unsigned int clkdiv);
int w747_set_i2c_dev_adr(unsigned char addr);
void w747_i2c_wr_delay(unsigned int delay);
int w747_status_poll(unsigned int expected_value, unsigned int index, unsigned int time_out);
int w747_i2c_write_single(unsigned int addr, unsigned int data, unsigned int dev_type);
int w747_i2c_read_single(unsigned int addr, unsigned int *val, unsigned int dev_type);

//----------------------------------------------------------------------
#endif // _INCLUDE_W747_I2C_FUNCTION



