3 * Holger Brunck, Keymile GmbH Hannover, holger.brunck@keymile.com
5 * SPDX-License-Identifier: GPL-2.0+
11 #include <linux/ctype.h>
12 #include "../common/common.h"
14 static void i2c_write_start_seq(void)
17 dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
18 udelay(DELAY_ABORT_SEQ);
19 out_8(&dev->cr, (I2C_CR_MEN | I2C_CR_MSTA));
20 udelay(DELAY_ABORT_SEQ);
21 out_8(&dev->cr, (I2C_CR_MEN));
24 int i2c_make_abort(void)
27 dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
33 /* wait after each operation to finsh with a delay */
34 out_8(&dev->cr, (I2C_CR_MSTA));
35 udelay(DELAY_ABORT_SEQ);
36 out_8(&dev->cr, (I2C_CR_MEN | I2C_CR_MSTA));
37 udelay(DELAY_ABORT_SEQ);
39 udelay(DELAY_ABORT_SEQ);
40 last = in_8(&dev->dr);
44 * do read until the last bit is 1, but stop if the full eeprom is
47 while (((last & 0x01) != 0x01) &&
48 (nbr_read < CONFIG_SYS_IVM_EEPROM_MAX_LEN)) {
49 udelay(DELAY_ABORT_SEQ);
50 last = in_8(&dev->dr);
53 if ((last & 0x01) != 0x01)
55 if ((last != 0xff) || (nbr_read > 1))
56 printf("[INFO] i2c abort after %d bytes (0x%02x)\n",
58 udelay(DELAY_ABORT_SEQ);
59 out_8(&dev->cr, (I2C_CR_MEN));
60 udelay(DELAY_ABORT_SEQ);
61 /* clear status reg */
64 for (i = 0; i < 5; i++)
65 i2c_write_start_seq();
67 printf("[ERROR] i2c abort failed after %d bytes (0x%02x)\n",