aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJingchang Lu <b35083@freescale.com>2013-08-07 05:05:41 -0400
committerWolfram Sang <wsa@the-dreams.de>2013-08-15 10:13:48 -0400
commit171408c21149dd3fd2ed33f19afe2cd558269253 (patch)
tree1c60898b4f9f9c1f923f26415077ad2ec5a4b088 /drivers/i2c
parent8cc7331ff372b9d03f8b2eb1422052bd99430611 (diff)
i2c: imx: add INT flag and IEN bit operatation codes
This add bits operation macro that differ between SoCs. Interrupt flags clear operation in I2SR differ between SoCs: write zero to clear(w0c) INT flag on i.MX, but write one to clear(w1c) INT flag on Vybrid. I2C module enable operation in I2CR also differ between SoCs: set I2CR_IEN bit enable the module on i.MX, but clear I2CR_IEN bit enable the module on Vybrid. Signed-off-by: Jingchang Lu <b35083@freescale.com> Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-imx.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 8a292a95e86a..dc9f2ec22a29 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -95,6 +95,22 @@
95#define I2CR_IIEN 0x40 95#define I2CR_IIEN 0x40
96#define I2CR_IEN 0x80 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/** Variables ****************************************************************** 114/** Variables ******************************************************************
99*******************************************************************************/ 115*******************************************************************************/
100 116
@@ -242,8 +258,8 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
242 clk_prepare_enable(i2c_imx->clk); 258 clk_prepare_enable(i2c_imx->clk);
243 imx_i2c_write_reg(i2c_imx->ifdr, i2c_imx, IMX_I2C_IFDR); 259 imx_i2c_write_reg(i2c_imx->ifdr, i2c_imx, IMX_I2C_IFDR);
244 /* Enable I2C controller */ 260 /* Enable I2C controller */
245 imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2SR); 261 imx_i2c_write_reg(IMX_I2SR_CLR_OPCODE, i2c_imx, IMX_I2C_I2SR);
246 imx_i2c_write_reg(I2CR_IEN, i2c_imx, IMX_I2C_I2CR); 262 imx_i2c_write_reg(IMX_I2CR_IEN_OPCODE, i2c_imx, IMX_I2C_I2CR);
247 263
248 /* Wait controller to be stable */ 264 /* Wait controller to be stable */
249 udelay(50); 265 udelay(50);
@@ -287,7 +303,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
287 } 303 }
288 304
289 /* Disable I2C controller */ 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 clk_disable_unprepare(i2c_imx->clk); 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 /* save status register */ 355 /* save status register */
340 i2c_imx->i2csr = temp; 356 i2c_imx->i2csr = temp;
341 temp &= ~I2SR_IIF; 357 temp &= ~I2SR_IIF;
358 temp |= (IMX_I2SR_CLR_OPCODE & I2SR_IIF);
342 imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR); 359 imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR);
343 wake_up(&i2c_imx->queue); 360 wake_up(&i2c_imx->queue);
344 return IRQ_HANDLED; 361 return IRQ_HANDLED;
@@ -596,8 +613,8 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
596 i2c_imx_set_clk(i2c_imx, bitrate); 613 i2c_imx_set_clk(i2c_imx, bitrate);
597 614
598 /* Set up chip registers to defaults */ 615 /* Set up chip registers to defaults */
599 imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2CR); 616 imx_i2c_write_reg(IMX_I2CR_IEN_OPCODE ^ I2CR_IEN, i2c_imx, IMX_I2C_I2CR);
600 imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2SR); 617 imx_i2c_write_reg(IMX_I2SR_CLR_OPCODE, i2c_imx, IMX_I2C_I2SR);
601 618
602 /* Add I2C adapter */ 619 /* Add I2C adapter */
603 ret = i2c_add_numbered_adapter(&i2c_imx->adapter); 620 ret = i2c_add_numbered_adapter(&i2c_imx->adapter);