diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-12-29 16:32:35 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-12-29 16:32:35 -0500 |
commit | 33edcf133ba93ecba2e4b6472e97b689895d805c (patch) | |
tree | 327d7a20acef64005e7c5ccbfa1265be28aeb6ac /drivers/i2c | |
parent | be4d638c1597580ed2294d899d9f1a2cd10e462c (diff) | |
parent | 3c92ec8ae91ecf59d88c798301833d7cf83f2179 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-cpm.c | 1 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-highlander.c | 4 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-pmcmsp.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-s3c2410.c | 18 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-sh_mobile.c | 73 |
5 files changed, 55 insertions, 43 deletions
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c index 228f75723063..3fcf78e906db 100644 --- a/drivers/i2c/busses/i2c-cpm.c +++ b/drivers/i2c/busses/i2c-cpm.c | |||
@@ -365,6 +365,7 @@ static int cpm_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | |||
365 | pmsg = &msgs[tptr]; | 365 | pmsg = &msgs[tptr]; |
366 | if (pmsg->flags & I2C_M_RD) | 366 | if (pmsg->flags & I2C_M_RD) |
367 | ret = wait_event_interruptible_timeout(cpm->i2c_wait, | 367 | ret = wait_event_interruptible_timeout(cpm->i2c_wait, |
368 | (in_be16(&tbdf[tptr].cbd_sc) & BD_SC_NAK) || | ||
368 | !(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY), | 369 | !(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY), |
369 | 1 * HZ); | 370 | 1 * HZ); |
370 | else | 371 | else |
diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c index f4d22ae9d294..e5a8dae4a289 100644 --- a/drivers/i2c/busses/i2c-highlander.c +++ b/drivers/i2c/busses/i2c-highlander.c | |||
@@ -92,7 +92,7 @@ static void highlander_i2c_setup(struct highlander_i2c_dev *dev) | |||
92 | static void smbus_write_data(u8 *src, u16 *dst, int len) | 92 | static void smbus_write_data(u8 *src, u16 *dst, int len) |
93 | { | 93 | { |
94 | for (; len > 1; len -= 2) { | 94 | for (; len > 1; len -= 2) { |
95 | *dst++ = be16_to_cpup((u16 *)src); | 95 | *dst++ = be16_to_cpup((__be16 *)src); |
96 | src += 2; | 96 | src += 2; |
97 | } | 97 | } |
98 | 98 | ||
@@ -103,7 +103,7 @@ static void smbus_write_data(u8 *src, u16 *dst, int len) | |||
103 | static void smbus_read_data(u16 *src, u8 *dst, int len) | 103 | static void smbus_read_data(u16 *src, u8 *dst, int len) |
104 | { | 104 | { |
105 | for (; len > 1; len -= 2) { | 105 | for (; len > 1; len -= 2) { |
106 | *(u16 *)dst = cpu_to_be16p(src++); | 106 | *(__be16 *)dst = cpu_to_be16p(src++); |
107 | dst += 2; | 107 | dst += 2; |
108 | } | 108 | } |
109 | 109 | ||
diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c index dcf2045b5222..0bdb2d7f0570 100644 --- a/drivers/i2c/busses/i2c-pmcmsp.c +++ b/drivers/i2c/busses/i2c-pmcmsp.c | |||
@@ -486,7 +486,7 @@ static enum pmcmsptwi_xfer_result pmcmsptwi_xfer_cmd( | |||
486 | 486 | ||
487 | if (cmd->type == MSP_TWI_CMD_WRITE || | 487 | if (cmd->type == MSP_TWI_CMD_WRITE || |
488 | cmd->type == MSP_TWI_CMD_WRITE_READ) { | 488 | cmd->type == MSP_TWI_CMD_WRITE_READ) { |
489 | __be64 tmp = cpu_to_be64p((u64 *)cmd->write_data); | 489 | u64 tmp = be64_to_cpup((__be64 *)cmd->write_data); |
490 | tmp >>= (MSP_MAX_BYTES_PER_RW - cmd->write_len) * 8; | 490 | tmp >>= (MSP_MAX_BYTES_PER_RW - cmd->write_len) * 8; |
491 | dev_dbg(&pmcmsptwi_adapter.dev, "Writing 0x%016llx\n", tmp); | 491 | dev_dbg(&pmcmsptwi_adapter.dev, "Writing 0x%016llx\n", tmp); |
492 | pmcmsptwi_writel(tmp & 0x00000000ffffffffLL, | 492 | pmcmsptwi_writel(tmp & 0x00000000ffffffffLL, |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 1fac4e233133..b7434d24904e 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -56,6 +56,7 @@ enum s3c24xx_i2c_state { | |||
56 | struct s3c24xx_i2c { | 56 | struct s3c24xx_i2c { |
57 | spinlock_t lock; | 57 | spinlock_t lock; |
58 | wait_queue_head_t wait; | 58 | wait_queue_head_t wait; |
59 | unsigned int suspended:1; | ||
59 | 60 | ||
60 | struct i2c_msg *msg; | 61 | struct i2c_msg *msg; |
61 | unsigned int msg_num; | 62 | unsigned int msg_num; |
@@ -507,7 +508,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int | |||
507 | unsigned long timeout; | 508 | unsigned long timeout; |
508 | int ret; | 509 | int ret; |
509 | 510 | ||
510 | if (!(readl(i2c->regs + S3C2410_IICCON) & S3C2410_IICCON_IRQEN)) | 511 | if (i2c->suspended) |
511 | return -EIO; | 512 | return -EIO; |
512 | 513 | ||
513 | ret = s3c24xx_i2c_set_master(i2c); | 514 | ret = s3c24xx_i2c_set_master(i2c); |
@@ -986,17 +987,26 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) | |||
986 | } | 987 | } |
987 | 988 | ||
988 | #ifdef CONFIG_PM | 989 | #ifdef CONFIG_PM |
990 | static int s3c24xx_i2c_suspend_late(struct platform_device *dev, | ||
991 | pm_message_t msg) | ||
992 | { | ||
993 | struct s3c24xx_i2c *i2c = platform_get_drvdata(dev); | ||
994 | i2c->suspended = 1; | ||
995 | return 0; | ||
996 | } | ||
997 | |||
989 | static int s3c24xx_i2c_resume(struct platform_device *dev) | 998 | static int s3c24xx_i2c_resume(struct platform_device *dev) |
990 | { | 999 | { |
991 | struct s3c24xx_i2c *i2c = platform_get_drvdata(dev); | 1000 | struct s3c24xx_i2c *i2c = platform_get_drvdata(dev); |
992 | 1001 | ||
993 | if (i2c != NULL) | 1002 | i2c->suspended = 0; |
994 | s3c24xx_i2c_init(i2c); | 1003 | s3c24xx_i2c_init(i2c); |
995 | 1004 | ||
996 | return 0; | 1005 | return 0; |
997 | } | 1006 | } |
998 | 1007 | ||
999 | #else | 1008 | #else |
1009 | #define s3c24xx_i2c_suspend_late NULL | ||
1000 | #define s3c24xx_i2c_resume NULL | 1010 | #define s3c24xx_i2c_resume NULL |
1001 | #endif | 1011 | #endif |
1002 | 1012 | ||
@@ -1005,6 +1015,7 @@ static int s3c24xx_i2c_resume(struct platform_device *dev) | |||
1005 | static struct platform_driver s3c2410_i2c_driver = { | 1015 | static struct platform_driver s3c2410_i2c_driver = { |
1006 | .probe = s3c24xx_i2c_probe, | 1016 | .probe = s3c24xx_i2c_probe, |
1007 | .remove = s3c24xx_i2c_remove, | 1017 | .remove = s3c24xx_i2c_remove, |
1018 | .suspend_late = s3c24xx_i2c_suspend_late, | ||
1008 | .resume = s3c24xx_i2c_resume, | 1019 | .resume = s3c24xx_i2c_resume, |
1009 | .driver = { | 1020 | .driver = { |
1010 | .owner = THIS_MODULE, | 1021 | .owner = THIS_MODULE, |
@@ -1015,6 +1026,7 @@ static struct platform_driver s3c2410_i2c_driver = { | |||
1015 | static struct platform_driver s3c2440_i2c_driver = { | 1026 | static struct platform_driver s3c2440_i2c_driver = { |
1016 | .probe = s3c24xx_i2c_probe, | 1027 | .probe = s3c24xx_i2c_probe, |
1017 | .remove = s3c24xx_i2c_remove, | 1028 | .remove = s3c24xx_i2c_remove, |
1029 | .suspend_late = s3c24xx_i2c_suspend_late, | ||
1018 | .resume = s3c24xx_i2c_resume, | 1030 | .resume = s3c24xx_i2c_resume, |
1019 | .driver = { | 1031 | .driver = { |
1020 | .owner = THIS_MODULE, | 1032 | .owner = THIS_MODULE, |
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 3384a717fec0..6c3d60b939bf 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -160,9 +160,39 @@ struct sh_mobile_i2c_data { | |||
160 | 160 | ||
161 | static void activate_ch(struct sh_mobile_i2c_data *pd) | 161 | static void activate_ch(struct sh_mobile_i2c_data *pd) |
162 | { | 162 | { |
163 | unsigned long i2c_clk; | ||
164 | u_int32_t num; | ||
165 | u_int32_t denom; | ||
166 | u_int32_t tmp; | ||
167 | |||
163 | /* Make sure the clock is enabled */ | 168 | /* Make sure the clock is enabled */ |
164 | clk_enable(pd->clk); | 169 | clk_enable(pd->clk); |
165 | 170 | ||
171 | /* Get clock rate after clock is enabled */ | ||
172 | i2c_clk = clk_get_rate(pd->clk); | ||
173 | |||
174 | /* Calculate the value for iccl. From the data sheet: | ||
175 | * iccl = (p clock / transfer rate) * (L / (L + H)) | ||
176 | * where L and H are the SCL low/high ratio (5/4 in this case). | ||
177 | * We also round off the result. | ||
178 | */ | ||
179 | num = i2c_clk * 5; | ||
180 | denom = NORMAL_SPEED * 9; | ||
181 | tmp = num * 10 / denom; | ||
182 | if (tmp % 10 >= 5) | ||
183 | pd->iccl = (u_int8_t)((num/denom) + 1); | ||
184 | else | ||
185 | pd->iccl = (u_int8_t)(num/denom); | ||
186 | |||
187 | /* Calculate the value for icch. From the data sheet: | ||
188 | icch = (p clock / transfer rate) * (H / (L + H)) */ | ||
189 | num = i2c_clk * 4; | ||
190 | tmp = num * 10 / denom; | ||
191 | if (tmp % 10 >= 5) | ||
192 | pd->icch = (u_int8_t)((num/denom) + 1); | ||
193 | else | ||
194 | pd->icch = (u_int8_t)(num/denom); | ||
195 | |||
166 | /* Enable channel and configure rx ack */ | 196 | /* Enable channel and configure rx ack */ |
167 | iowrite8(ioread8(ICCR(pd)) | ICCR_ICE, ICCR(pd)); | 197 | iowrite8(ioread8(ICCR(pd)) | ICCR_ICE, ICCR(pd)); |
168 | 198 | ||
@@ -459,40 +489,6 @@ static struct i2c_algorithm sh_mobile_i2c_algorithm = { | |||
459 | .master_xfer = sh_mobile_i2c_xfer, | 489 | .master_xfer = sh_mobile_i2c_xfer, |
460 | }; | 490 | }; |
461 | 491 | ||
462 | static void sh_mobile_i2c_setup_channel(struct platform_device *dev) | ||
463 | { | ||
464 | struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev); | ||
465 | unsigned long peripheral_clk = clk_get_rate(pd->clk); | ||
466 | u_int32_t num; | ||
467 | u_int32_t denom; | ||
468 | u_int32_t tmp; | ||
469 | |||
470 | spin_lock_init(&pd->lock); | ||
471 | init_waitqueue_head(&pd->wait); | ||
472 | |||
473 | /* Calculate the value for iccl. From the data sheet: | ||
474 | * iccl = (p clock / transfer rate) * (L / (L + H)) | ||
475 | * where L and H are the SCL low/high ratio (5/4 in this case). | ||
476 | * We also round off the result. | ||
477 | */ | ||
478 | num = peripheral_clk * 5; | ||
479 | denom = NORMAL_SPEED * 9; | ||
480 | tmp = num * 10 / denom; | ||
481 | if (tmp % 10 >= 5) | ||
482 | pd->iccl = (u_int8_t)((num/denom) + 1); | ||
483 | else | ||
484 | pd->iccl = (u_int8_t)(num/denom); | ||
485 | |||
486 | /* Calculate the value for icch. From the data sheet: | ||
487 | icch = (p clock / transfer rate) * (H / (L + H)) */ | ||
488 | num = peripheral_clk * 4; | ||
489 | tmp = num * 10 / denom; | ||
490 | if (tmp % 10 >= 5) | ||
491 | pd->icch = (u_int8_t)((num/denom) + 1); | ||
492 | else | ||
493 | pd->icch = (u_int8_t)(num/denom); | ||
494 | } | ||
495 | |||
496 | static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook) | 492 | static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook) |
497 | { | 493 | { |
498 | struct resource *res; | 494 | struct resource *res; |
@@ -533,6 +529,7 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
533 | struct sh_mobile_i2c_data *pd; | 529 | struct sh_mobile_i2c_data *pd; |
534 | struct i2c_adapter *adap; | 530 | struct i2c_adapter *adap; |
535 | struct resource *res; | 531 | struct resource *res; |
532 | char clk_name[8]; | ||
536 | int size; | 533 | int size; |
537 | int ret; | 534 | int ret; |
538 | 535 | ||
@@ -542,9 +539,10 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
542 | return -ENOMEM; | 539 | return -ENOMEM; |
543 | } | 540 | } |
544 | 541 | ||
545 | pd->clk = clk_get(&dev->dev, "peripheral_clk"); | 542 | snprintf(clk_name, sizeof(clk_name), "i2c%d", dev->id); |
543 | pd->clk = clk_get(&dev->dev, clk_name); | ||
546 | if (IS_ERR(pd->clk)) { | 544 | if (IS_ERR(pd->clk)) { |
547 | dev_err(&dev->dev, "cannot get peripheral clock\n"); | 545 | dev_err(&dev->dev, "cannot get clock \"%s\"\n", clk_name); |
548 | ret = PTR_ERR(pd->clk); | 546 | ret = PTR_ERR(pd->clk); |
549 | goto err; | 547 | goto err; |
550 | } | 548 | } |
@@ -586,7 +584,8 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
586 | 584 | ||
587 | strlcpy(adap->name, dev->name, sizeof(adap->name)); | 585 | strlcpy(adap->name, dev->name, sizeof(adap->name)); |
588 | 586 | ||
589 | sh_mobile_i2c_setup_channel(dev); | 587 | spin_lock_init(&pd->lock); |
588 | init_waitqueue_head(&pd->wait); | ||
590 | 589 | ||
591 | ret = i2c_add_numbered_adapter(adap); | 590 | ret = i2c_add_numbered_adapter(adap); |
592 | if (ret < 0) { | 591 | if (ret < 0) { |