|
95 | 95 | #define I2CR_IIEN 0x40
|
96 | 96 | #define I2CR_IEN 0x80
|
97 | 97 |
|
| 98 | +/* register bits different operating codes definition: |
| 99 | + * 1) I2SR: Interrupt flags clear operation differ between SoCs: |
| 100 | + * - write zero to clear(w0c) INT flag on i.MX, |
| 101 | + * - but write one to clear(w1c) INT flag on Vybrid. |
| 102 | + * 2) I2CR: I2C module enable operation also differ between SoCs: |
| 103 | + * - set I2CR_IEN bit enable the module on i.MX, |
| 104 | + * - but clear I2CR_IEN bit enable the module on Vybrid. |
| 105 | + */ |
| 106 | +#define I2SR_CLR_OPCODE_W0C 0x0 |
| 107 | +#define I2SR_CLR_OPCODE_W1C (I2SR_IAL | I2SR_IIF) |
| 108 | +#define I2CR_IEN_OPCODE_0 0x0 |
| 109 | +#define I2CR_IEN_OPCODE_1 I2CR_IEN |
| 110 | + |
| 111 | +#define IMX_I2SR_CLR_OPCODE I2SR_CLR_OPCODE_W0C |
| 112 | +#define IMX_I2CR_IEN_OPCODE I2CR_IEN_OPCODE_1 |
| 113 | + |
98 | 114 | /** Variables ******************************************************************
|
99 | 115 | *******************************************************************************/
|
100 | 116 |
|
@@ -242,8 +258,8 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
|
242 | 258 | clk_prepare_enable(i2c_imx->clk);
|
243 | 259 | imx_i2c_write_reg(i2c_imx->ifdr, i2c_imx, IMX_I2C_IFDR);
|
244 | 260 | /* Enable I2C controller */
|
245 |
| - imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2SR); |
246 |
| - imx_i2c_write_reg(I2CR_IEN, i2c_imx, IMX_I2C_I2CR); |
| 261 | + imx_i2c_write_reg(IMX_I2SR_CLR_OPCODE, i2c_imx, IMX_I2C_I2SR); |
| 262 | + imx_i2c_write_reg(IMX_I2CR_IEN_OPCODE, i2c_imx, IMX_I2C_I2CR); |
247 | 263 |
|
248 | 264 | /* Wait controller to be stable */
|
249 | 265 | udelay(50);
|
@@ -287,7 +303,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
|
287 | 303 | }
|
288 | 304 |
|
289 | 305 | /* Disable I2C controller */
|
290 |
| - imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2CR); |
| 306 | + imx_i2c_write_reg(IMX_I2CR_IEN_OPCODE ^ I2CR_IEN, i2c_imx, IMX_I2C_I2CR); |
291 | 307 | clk_disable_unprepare(i2c_imx->clk);
|
292 | 308 | }
|
293 | 309 |
|
@@ -339,6 +355,7 @@ static irqreturn_t i2c_imx_isr(int irq, void *dev_id)
|
339 | 355 | /* save status register */
|
340 | 356 | i2c_imx->i2csr = temp;
|
341 | 357 | temp &= ~I2SR_IIF;
|
| 358 | + temp |= (IMX_I2SR_CLR_OPCODE & I2SR_IIF); |
342 | 359 | imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR);
|
343 | 360 | wake_up(&i2c_imx->queue);
|
344 | 361 | return IRQ_HANDLED;
|
@@ -596,8 +613,8 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
|
596 | 613 | i2c_imx_set_clk(i2c_imx, bitrate);
|
597 | 614 |
|
598 | 615 | /* Set up chip registers to defaults */
|
599 |
| - imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2CR); |
600 |
| - imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2SR); |
| 616 | + imx_i2c_write_reg(IMX_I2CR_IEN_OPCODE ^ I2CR_IEN, i2c_imx, IMX_I2C_I2CR); |
| 617 | + imx_i2c_write_reg(IMX_I2SR_CLR_OPCODE, i2c_imx, IMX_I2C_I2SR); |
601 | 618 |
|
602 | 619 | /* Add I2C adapter */
|
603 | 620 | ret = i2c_add_numbered_adapter(&i2c_imx->adapter);
|
|
0 commit comments