From: DENX Support System Date: Thu, 2 Nov 2006 10:30:05 +0100 Subject: [U-Boot-Users] [DNX#2006110242000118] [PATCH 09/10 v3 ]: tsi108 i2c suppo [...] Message-ID: <1162459805.496160.731590926@castor.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello list, inside the automatic U-Boot patch tracking system a new ticket [DNX#2006110242000118] was created: > Tsi108 on chip i2c support. > The i2c Interface provides a master-only, serial interface that can be > used for initializing Tsi108/Tsi109 registers from an EEPROM after a > device reset. > > Signed-off-by: Alexandre Bounine > Signed-off-by: Roy Zang > --- > drivers/tsi108_i2c.c | 300 > ++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 300 insertions(+), 0 deletions(-) > > diff --git a/drivers/tsi108_i2c.c b/drivers/tsi108_i2c.c > new file mode 100644 > index 0000000..08e5e3b > --- /dev/null > +++ b/drivers/tsi108_i2c.c > @@ -0,0 +1,300 @@ > +/* > + * (C) Copyright 2004 Tundra Semiconductor Corp. > + * Author: Alex Bounine > + * > + * See file CREDITS for list of people who contributed to this > + * project. > + * > + * 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 > + * > + */ > + > +#include > + > +#ifdef CONFIG_TSI108_I2C > + > +#include > +#include > + > +#if (CONFIG_COMMANDS & CFG_CMD_I2C) > + > +#define I2C_DELAY 100000 > +#undef DEBUG_I2C > + > +#ifdef DEBUG_I2C > +#define DPRINT(x) printf(x) > +#else > +#define DPRINT(x) > +#endif > + > +/* All functions assume that Tsi108 I2C block is the only master on the > bus */ > +/* I2C read helper function */ > + > +static int i2c_read_byte( > + uint i2c_chan, /* I2C channel number: 0 - main, 1 - SDC SPD */ > + uchar chip_addr,/* I2C device address on the bus */ > + uint byte_addr, /* Byte address within I2C device */ > + uchar * buffer /* pointer to data buffer */ > + ) > +{ > + u32 temp; > + u32 to_count = I2C_DELAY; > + u32 op_status = TSI108_I2C_TIMEOUT_ERR; > + u32 chan_offset = TSI108_I2C_OFFSET; > + > + DPRINT(("I2C read_byte() %d 0x%02x 0x%02x\n", > + i2c_chan, chip_addr, byte_addr)); > + > + if (0 != i2c_chan) { > + chan_offset = TSI108_I2C_SDRAM_OFFSET; > + } > + > + /* Check if I2C operation is in progress */ > + temp = *(u32 *) (CFG_TSI108_CSR_BASE + chan_offset + I2C_CNTRL2); > + > + if (0 == (temp & (I2C_CNTRL2_RD_STATUS | I2C_CNTRL2_WR_STATUS | > + I2C_CNTRL2_START)) > + ) { > + /* Set device address and operation (read = 0) */ > + temp = (byte_addr << 16) | ((chip_addr & 0x07) << 8) | > + ((chip_addr >> 3) & 0x0F); > + *(u32 *) (CFG_TSI108_CSR_BASE + chan_offset + I2C_CNTRL1) = > + temp; > + > + /* Issue the read command > + * (at this moment all other parameters are 0 > + * (size = 1 byte, lane = 0) > + */ > + Your U-Boot support team