/*****************************************************************************/
/* Copyright (c) 2009 NXP B.V.                                               */
/*                                                                           */
/* 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, using version 2 of the License.             */
/*                                                                           */
/* 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_client.h

Description : Header file - TDHL5 I2C Client Driver

Date          Modification                              Name
----          ------------                              ----
01 Jun 2007   Created                                   Anastacio Cavalcante - Lucas Cordeiro
23 Jul 2007   Changing driver name to TDHL5				Lucas Cordeiro
******************************************************************************************/

#ifndef _I2C_CLIENT_H
#define _I2C_CLIENT_H

#include <linux/i2c.h>

/**********************************Structures**********************************/
/**
 * @brief struct that contains information device access connected 
 *        to the i2c bus.
 */
typedef struct{

	s32 id;
	struct module * owner;

} access_info;
/******************************************************************************/

/* External Interfaces */
/**************************** Init and Exit methods *****************************/
s32  sm_init(void);
void sm_exit(void);

/******************************** Lock Functions ********************************/
s32 sm_lock (access_info *access);
s32 sm_unlock(access_info *access);
/********************************************************************************/

/**************************** Communication Functions ***************************/
s32 sm_read_value (u8 reg,    s32 *data,      access_info *access);
s32 sm_write_value(u8 reg,    u8 value, access_info *access);
s32 sm_write_pll  (u8 length, u8 *data, access_info *access);
/********************************************************************************/

/************************************ Macros ************************************/
#define create_init_access_info(access_struct) access_info access_struct = {.id = 0,.owner = THIS_MODULE}

/**
 * @brief utility macro to send messages to the system log
 */
#ifdef DEBUG
#define debug(parms...) printk(parms)
#else
#define debug(parms...)
#endif
/******************************************************************************/

/* Internals */

/***********************************Constants**********************************/
#define DRIVER_NAME_LEN 32

/***************************Structures and variables***************************/
/**
 * @brief struct that contains information about the device connected 
 *	      to the i2c bus.
 */
struct driver_data{

	struct i2c_client *sm_client;
	u8 chip_detected;
	u8 lock;
	access_info access;
	struct semaphore sema;
};


/************************ Method for /proc File Creation ************************/
s32 sm_read_proc(char *param, char **start, off_t offset, s32 len, s32 *eof, void *data);

/******************************* Commom Functions *******************************/
s32 sm_attach_adapter(struct i2c_adapter *adapter);
s32 sm_detect_client(struct i2c_adapter *adapter, s32 address, s32 kind);
s32 sm_detach_client(struct i2c_client *client);

#endif /* _I2C_CLIENT_H */
