Commit 26a33504a55e4882520f2e9da96ba6c22badb353

Authored by Richard Retanubun
Committed by Heiko Schocher
1 parent 2a72e9ed18

fsl_i2c: Added a callpoint for i2c_board_late_init

This patch adds a callpoint in i2c_init that allows board specific
i2c board initialization (typically for i2c bus reset) that is called
after i2c_init operations, allowing the i2c_board_late_init function
to use the pre-configured i2c bus speed and slave address.

Showing 3 changed files with 27 additions and 3 deletions Side-by-side Diff

... ... @@ -1509,6 +1509,17 @@
1509 1509 custom i2c_init_board() routine in boards/xxx/board.c
1510 1510 is run early in the boot sequence.
1511 1511  
  1512 + CONFIG_SYS_I2C_BOARD_LATE_INIT
  1513 +
  1514 + An alternative to CONFIG_SYS_I2C_INIT_BOARD. If this option is
  1515 + defined a custom i2c_board_late_init() routine in
  1516 + boards/xxx/board.c is run AFTER the operations in i2c_init()
  1517 + is completed. This callpoint can be used to unreset i2c bus
  1518 + using CPU i2c controller register accesses for CPUs whose i2c
  1519 + controller provide such a method. It is called at the end of
  1520 + i2c_init() to allow i2c_init operations to setup the i2c bus
  1521 + controller on the CPU (e.g. setting bus speed & slave address).
  1522 +
1512 1523 CONFIG_I2CFAST (PPC405GP|PPC405EP only)
1513 1524  
1514 1525 This option enables configuration of bi_iic_fast[] flags
drivers/i2c/fsl_i2c.c
... ... @@ -221,9 +221,10 @@
221 221 unsigned int temp;
222 222  
223 223 #ifdef CONFIG_SYS_I2C_INIT_BOARD
224   - /* call board specific i2c bus reset routine before accessing the */
225   - /* environment, which might be in a chip on that bus. For details */
226   - /* about this problem see doc/I2C_Edge_Conditions. */
  224 + /* Call board specific i2c bus reset routine before accessing the
  225 + * environment, which might be in a chip on that bus. For details
  226 + * about this problem see doc/I2C_Edge_Conditions.
  227 + */
227 228 i2c_init_board();
228 229 #endif
229 230 dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
... ... @@ -248,6 +249,15 @@
248 249 writeb(slaveadd << 1, &dev->adr); /* write slave address */
249 250 writeb(0x0, &dev->sr); /* clear status register */
250 251 writeb(I2C_CR_MEN, &dev->cr); /* start I2C controller */
  252 +#endif
  253 +
  254 +#ifdef CONFIG_SYS_I2C_BOARD_LATE_INIT
  255 + /* Call board specific i2c bus reset routine AFTER the bus has been
  256 + * initialized. Use either this callpoint or i2c_init_board;
  257 + * which is called before i2c_init operations.
  258 + * For details about this problem see doc/I2C_Edge_Conditions.
  259 + */
  260 + i2c_board_late_init();
251 261 #endif
252 262 }
253 263  
... ... @@ -111,6 +111,9 @@
111 111 #ifdef CONFIG_SYS_I2C_INIT_BOARD
112 112 void i2c_init_board(void);
113 113 #endif
  114 +#ifdef CONFIG_SYS_I2C_BOARD_LATE_INIT
  115 +void i2c_board_late_init(void);
  116 +#endif
114 117  
115 118 #if defined(CONFIG_I2C_MUX)
116 119