/* 2012-09-16: File added by Sony Corporation */
/*
 * icx_i2c.h
 *
 * Copyright 2011 Sony Corporation.
 *
 * 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
 *
 */

#ifndef __ICX_I2C_H__
#define __ICX_I2C_H__


/***************/
/* Definitions */
/***************/

/* control */
#define IIC_IICC0_LREL0			0x0040
#define IIC_IICC0_WREL0			0x0020
#define IIC_IICC0_WTIM0			0x0008
#define IIC_IICC0_ACKE0			0x0004
#define IIC_IICC0_STT0			0x0002
#define IIC_IICC0_SPT0			0x0001

/* polarity */
#define IIC_IICCL0_CLD_LOW		0x0000
#define IIC_IICCL0_CLD_HIGH 	0x0020

#define IIC_IICCL0_DAD_LOW		0x0000
#define IIC_IICCL0_DAD_HIGH 	0x0010

/* clock */
#define IIC_IICCL0_SMC_NRML		0x0034
#define IIC_IICCL0_SMC_FAST		0x003C

/* flags */
#define IIC_IICF0_STCEN_DIS		0x0000
#define IIC_IICF0_STCEN_EN		0x0002

#define IIC_IICF0_IICRSV_DIS	0x0000
#define IIC_IICF0_IICRSV_EN		0x0001


/*******************/
/* Type definition */
/*******************/

/* configuration */
typedef struct {
	unsigned short ctrl;
	unsigned char  slave_adr;
	unsigned short clock;
	unsigned short flag;
} i2c_config_t;


/**************/
/* Prototypes */
/**************/

int i2c_init(i2c_config_t *config);
int i2c_exit(void);
int i2c_write(i2c_config_t *config, unsigned char reg, unsigned char data);
int i2c_read(i2c_config_t *config, unsigned char reg, unsigned char *data, int num);


#endif /* __ICX_I2C_H__ */

