3 * Holger Brunck, Keymile GmbH Hannover, holger.brunck@keymile.com
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <linux/ctype.h>
28 #include "../common/common.h"
30 static void i2c_write_start_seq(void)
33 dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
34 udelay(DELAY_ABORT_SEQ);
35 out_8(&dev->cr, (I2C_CR_MEN | I2C_CR_MSTA));
36 udelay(DELAY_ABORT_SEQ);
37 out_8(&dev->cr, (I2C_CR_MEN));
40 int i2c_make_abort(void)
43 dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
49 /* wait after each operation to finsh with a delay */
50 out_8(&dev->cr, (I2C_CR_MSTA));
51 udelay(DELAY_ABORT_SEQ);
52 out_8(&dev->cr, (I2C_CR_MEN | I2C_CR_MSTA));
53 udelay(DELAY_ABORT_SEQ);
55 udelay(DELAY_ABORT_SEQ);
56 last = in_8(&dev->dr);
60 * do read until the last bit is 1, but stop if the full eeprom is
63 while (((last & 0x01) != 0x01) &&
64 (nbr_read < CONFIG_SYS_IVM_EEPROM_MAX_LEN)) {
65 udelay(DELAY_ABORT_SEQ);
66 last = in_8(&dev->dr);
69 if ((last & 0x01) != 0x01)
71 if ((last != 0xff) || (nbr_read > 1))
72 printf("[INFO] i2c abort after %d bytes (0x%02x)\n",
74 udelay(DELAY_ABORT_SEQ);
75 out_8(&dev->cr, (I2C_CR_MEN));
76 udelay(DELAY_ABORT_SEQ);
77 /* clear status reg */
80 for (i = 0; i < 5; i++)
81 i2c_write_start_seq();
83 printf("[ERROR] i2c abort failed after %d bytes (0x%02x)\n",