aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/i2c/busses/i2c-mpc.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 26bf37010586..1215686bd3c2 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -20,7 +20,7 @@
20#include <linux/of_platform.h> 20#include <linux/of_platform.h>
21#include <linux/of_i2c.h> 21#include <linux/of_i2c.h>
22 22
23#include <asm/io.h> 23#include <linux/io.h>
24#include <linux/fsl_devices.h> 24#include <linux/fsl_devices.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
@@ -28,10 +28,10 @@
28 28
29#define DRV_NAME "mpc-i2c" 29#define DRV_NAME "mpc-i2c"
30 30
31#define MPC_I2C_FDR 0x04 31#define MPC_I2C_FDR 0x04
32#define MPC_I2C_CR 0x08 32#define MPC_I2C_CR 0x08
33#define MPC_I2C_SR 0x0c 33#define MPC_I2C_SR 0x0c
34#define MPC_I2C_DR 0x10 34#define MPC_I2C_DR 0x10
35#define MPC_I2C_DFSRR 0x14 35#define MPC_I2C_DFSRR 0x14
36 36
37#define CCR_MEN 0x80 37#define CCR_MEN 0x80
@@ -58,7 +58,7 @@ struct mpc_i2c {
58 u32 flags; 58 u32 flags;
59}; 59};
60 60
61static __inline__ void writeccr(struct mpc_i2c *i2c, u32 x) 61static inline void writeccr(struct mpc_i2c *i2c, u32 x)
62{ 62{
63 writeb(x, i2c->base + MPC_I2C_CR); 63 writeb(x, i2c->base + MPC_I2C_CR);
64} 64}
@@ -100,8 +100,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
100 u32 x; 100 u32 x;
101 int result = 0; 101 int result = 0;
102 102
103 if (i2c->irq == NO_IRQ) 103 if (i2c->irq == NO_IRQ) {
104 {
105 while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) { 104 while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
106 schedule(); 105 schedule();
107 if (time_after(jiffies, orig_jiffies + timeout)) { 106 if (time_after(jiffies, orig_jiffies + timeout)) {
@@ -176,7 +175,7 @@ static void mpc_i2c_stop(struct mpc_i2c *i2c)
176} 175}
177 176
178static int mpc_write(struct mpc_i2c *i2c, int target, 177static int mpc_write(struct mpc_i2c *i2c, int target,
179 const u8 * data, int length, int restart) 178 const u8 *data, int length, int restart)
180{ 179{
181 int i, result; 180 int i, result;
182 unsigned timeout = i2c->adap.timeout; 181 unsigned timeout = i2c->adap.timeout;
@@ -207,7 +206,7 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
207} 206}
208 207
209static int mpc_read(struct mpc_i2c *i2c, int target, 208static int mpc_read(struct mpc_i2c *i2c, int target,
210 u8 * data, int length, int restart) 209 u8 *data, int length, int restart)
211{ 210{
212 unsigned timeout = i2c->adap.timeout; 211 unsigned timeout = i2c->adap.timeout;
213 int i, result; 212 int i, result;
@@ -311,7 +310,8 @@ static struct i2c_adapter mpc_ops = {
311 .timeout = HZ, 310 .timeout = HZ,
312}; 311};
313 312
314static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_id *match) 313static int __devinit fsl_i2c_probe(struct of_device *op,
314 const struct of_device_id *match)
315{ 315{
316 int result = 0; 316 int result = 0;
317 struct mpc_i2c *i2c; 317 struct mpc_i2c *i2c;
@@ -341,11 +341,12 @@ static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_
341 result = request_irq(i2c->irq, mpc_i2c_isr, 341 result = request_irq(i2c->irq, mpc_i2c_isr,
342 IRQF_SHARED, "i2c-mpc", i2c); 342 IRQF_SHARED, "i2c-mpc", i2c);
343 if (result < 0) { 343 if (result < 0) {
344 printk(KERN_ERR "i2c-mpc - failed to attach interrupt\n"); 344 printk(KERN_ERR
345 "i2c-mpc - failed to attach interrupt\n");
345 goto fail_request; 346 goto fail_request;
346 } 347 }
347 } 348 }
348 349
349 mpc_i2c_setclock(i2c); 350 mpc_i2c_setclock(i2c);
350 351
351 dev_set_drvdata(&op->dev, i2c); 352 dev_set_drvdata(&op->dev, i2c);
@@ -368,7 +369,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op, const struct of_device_
368 free_irq(i2c->irq, i2c); 369 free_irq(i2c->irq, i2c);
369 fail_request: 370 fail_request:
370 irq_dispose_mapping(i2c->irq); 371 irq_dispose_mapping(i2c->irq);
371 iounmap(i2c->base); 372 iounmap(i2c->base);
372 fail_map: 373 fail_map:
373 kfree(i2c); 374 kfree(i2c);
374 return result; 375 return result;
@@ -414,7 +415,7 @@ static int __init fsl_i2c_init(void)
414 415
415 rv = of_register_platform_driver(&mpc_i2c_driver); 416 rv = of_register_platform_driver(&mpc_i2c_driver);
416 if (rv) 417 if (rv)
417 printk(KERN_ERR DRV_NAME 418 printk(KERN_ERR DRV_NAME
418 " of_register_platform_driver failed (%i)\n", rv); 419 " of_register_platform_driver failed (%i)\n", rv);
419 return rv; 420 return rv;
420} 421}
@@ -428,6 +429,6 @@ module_init(fsl_i2c_init);
428module_exit(fsl_i2c_exit); 429module_exit(fsl_i2c_exit);
429 430
430MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); 431MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>");
431MODULE_DESCRIPTION 432MODULE_DESCRIPTION("I2C-Bus adapter for MPC107 bridge and "
432 ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); 433 "MPC824x/85xx/52xx processors");
433MODULE_LICENSE("GPL"); 434MODULE_LICENSE("GPL");