2011-07-03 15:22:09 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2012-12-29 00:32:59 +00:00
|
|
|
* Copyright (C) 2011 by Amaury Pouly
|
2011-07-03 15:22:09 +00:00
|
|
|
*
|
|
|
|
* 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef __I2C_IMX233_H__
|
|
|
|
#define __I2C_IMX233_H__
|
|
|
|
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "system-target.h"
|
|
|
|
#include "i2c.h"
|
|
|
|
|
2013-06-16 13:58:36 +00:00
|
|
|
#include "regs/regs-i2c.h"
|
2011-07-03 15:22:09 +00:00
|
|
|
|
2013-06-16 13:58:36 +00:00
|
|
|
#define BM_I2C_CTRL1_ALL_IRQ \
|
|
|
|
BM_OR8(I2C_CTRL1, SLAVE_IRQ, SLAVE_STOP_IRQ, MASTER_LOSS_IRQ, EARLY_TERM_IRQ, \
|
|
|
|
OVERSIZE_XFER_TERM_IRQ, NO_SLAVE_ACK_IRQ, DATA_ENGINE_CMPLT_IRQ, BUS_FREE_IRQ)
|
2011-07-03 15:22:09 +00:00
|
|
|
|
|
|
|
enum imx233_i2c_error_t
|
|
|
|
{
|
|
|
|
I2C_SUCCESS = 0,
|
|
|
|
I2C_ERROR = -1,
|
|
|
|
I2C_TIMEOUT = -2,
|
|
|
|
I2C_MASTER_LOSS = -3,
|
|
|
|
I2C_NO_SLAVE_ACK = -4,
|
2012-08-18 13:38:43 +00:00
|
|
|
I2C_SLAVE_NAK = -5,
|
|
|
|
I2C_BUFFER_FULL = -6,
|
2011-07-03 15:22:09 +00:00
|
|
|
};
|
|
|
|
|
2012-03-15 13:59:20 +00:00
|
|
|
void imx233_i2c_init(void);
|
2011-07-03 15:22:09 +00:00
|
|
|
/* start building a transfer, will acquire an exclusive lock */
|
|
|
|
void imx233_i2c_begin(void);
|
|
|
|
/* add stage */
|
|
|
|
enum imx233_i2c_error_t imx233_i2c_add(bool start, bool transmit, void *buffer, unsigned size, bool stop);
|
|
|
|
/* end building a transfer and start the transfer */
|
|
|
|
enum imx233_i2c_error_t imx233_i2c_end(unsigned timeout);
|
|
|
|
|
2012-07-19 21:07:32 +00:00
|
|
|
#endif // __I2C_IMX233_H__
|