diff options
author | Chin Liang See <clsee@altera.com> | 2014-02-04 11:56:23 -0600 |
---|---|---|
committer | Heiko Schocher <hs@denx.de> | 2014-02-20 06:46:56 +0100 |
commit | 070cbaf821e07531db6e55946932f4172dd72045 (patch) | |
tree | 334a56e307b9b29f47e9d4a856933bfd516fc991 /drivers/i2c | |
parent | 9e50c406c8eede1105bd8ad1c1b74e0ef64af233 (diff) | |
download | u-boot-imx-070cbaf821e07531db6e55946932f4172dd72045.zip u-boot-imx-070cbaf821e07531db6e55946932f4172dd72045.tar.gz u-boot-imx-070cbaf821e07531db6e55946932f4172dd72045.tar.bz2 |
designware_i2c: Enhance DesignWare I2C driver address support
Enhance the DesignWare I2C driver to support address length more
than 1 byte. This enhancement is required as some I2C slave
device such as EEPROM chip might have 16 bit address byte.
Signed-off-by: Chin Liang See <clsee@altera.com>
Acked-by: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
Cc: Tom Rini <trini@ti.com>
cc: Armando Visconti <armando.visconti@st.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Cc: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/designware_i2c.c | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index 9ed9295..deea4f8 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -197,35 +197,18 @@ static int i2c_wait_for_bb(void) return 0; } -/* check parameters for i2c_read and i2c_write */ -static int check_params(uint addr, int alen, uchar *buffer, int len) -{ - if (buffer == NULL) { - printf("Buffer is invalid\n"); - return 1; - } - - if (alen > 1) { - printf("addr len %d not supported\n", alen); - return 1; - } - - if (addr + len > 256) { - printf("address out of range\n"); - return 1; - } - - return 0; -} - -static int i2c_xfer_init(uchar chip, uint addr) +static int i2c_xfer_init(uchar chip, uint addr, int alen) { if (i2c_wait_for_bb()) return 1; i2c_setaddress(chip); - writel(addr, &i2c_regs_p->ic_cmd_data); - + while (alen) { + alen--; + /* high byte address going out first */ + writel((addr >> (alen * 8)) & 0xff, + &i2c_regs_p->ic_cmd_data); + } return 0; } @@ -285,10 +268,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) addr); #endif - if (check_params(addr, alen, buffer, len)) - return 1; - - if (i2c_xfer_init(chip, addr)) + if (i2c_xfer_init(chip, addr, alen)) return 1; start_time_rx = get_timer(0); @@ -345,10 +325,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) addr); #endif - if (check_params(addr, alen, buffer, len)) - return 1; - - if (i2c_xfer_init(chip, addr)) + if (i2c_xfer_init(chip, addr, alen)) return 1; start_time_tx = get_timer(0); |