aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-pnx4008/i2c.c25
-rw-r--r--drivers/i2c/busses/i2c-pnx.c29
-rw-r--r--include/linux/i2c-pnx.h4
3 files changed, 28 insertions, 30 deletions
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c
index 23ec335a4bc0..33146e832dd7 100644
--- a/arch/arm/mach-pnx4008/i2c.c
+++ b/arch/arm/mach-pnx4008/i2c.c
@@ -18,45 +18,34 @@
18#include <mach/irqs.h> 18#include <mach/irqs.h>
19#include <mach/i2c.h> 19#include <mach/i2c.h>
20 20
21static struct i2c_pnx_algo_data pnx_algo_data0 = {
22 .base = PNX4008_I2C1_BASE,
23 .irq = I2C_1_INT,
24};
25
26static struct i2c_pnx_algo_data pnx_algo_data1 = {
27 .base = PNX4008_I2C2_BASE,
28 .irq = I2C_2_INT,
29};
30
31static struct i2c_pnx_algo_data pnx_algo_data2 = {
32 .base = (PNX4008_USB_CONFIG_BASE + 0x300),
33 .irq = USB_I2C_INT,
34};
35
36static struct i2c_adapter pnx_adapter0 = { 21static struct i2c_adapter pnx_adapter0 = {
37 .name = I2C_CHIP_NAME "0", 22 .name = I2C_CHIP_NAME "0",
38 .algo_data = &pnx_algo_data0,
39}; 23};
24
40static struct i2c_adapter pnx_adapter1 = { 25static struct i2c_adapter pnx_adapter1 = {
41 .name = I2C_CHIP_NAME "1", 26 .name = I2C_CHIP_NAME "1",
42 .algo_data = &pnx_algo_data1,
43}; 27};
44 28
45static struct i2c_adapter pnx_adapter2 = { 29static struct i2c_adapter pnx_adapter2 = {
46 .name = "USB-I2C", 30 .name = "USB-I2C",
47 .algo_data = &pnx_algo_data2,
48}; 31};
49 32
50static struct i2c_pnx_data i2c0_data = { 33static struct i2c_pnx_data i2c0_data = {
51 .adapter = &pnx_adapter0, 34 .adapter = &pnx_adapter0,
35 .base = PNX4008_I2C1_BASE,
36 .irq = I2C_1_INT,
52}; 37};
53 38
54static struct i2c_pnx_data i2c1_data = { 39static struct i2c_pnx_data i2c1_data = {
55 .adapter = &pnx_adapter1, 40 .adapter = &pnx_adapter1,
41 .base = PNX4008_I2C2_BASE,
42 .irq = I2C_2_INT,
56}; 43};
57 44
58static struct i2c_pnx_data i2c2_data = { 45static struct i2c_pnx_data i2c2_data = {
59 .adapter = &pnx_adapter2, 46 .adapter = &pnx_adapter2,
47 .base = (PNX4008_USB_CONFIG_BASE + 0x300),
48 .irq = USB_I2C_INT,
60}; 49};
61 50
62static struct platform_device i2c0_device = { 51static struct platform_device i2c0_device = {
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 882579e64111..1d66856a22fd 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -587,10 +587,16 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
587 goto out; 587 goto out;
588 } 588 }
589 589
590 alg_data = kzalloc(sizeof(*alg_data), GFP_KERNEL);
591 if (!alg_data) {
592 ret = -ENOMEM;
593 goto err_kzalloc;
594 }
595
590 platform_set_drvdata(pdev, i2c_pnx); 596 platform_set_drvdata(pdev, i2c_pnx);
591 597
592 i2c_pnx->adapter->algo = &pnx_algorithm; 598 i2c_pnx->adapter->algo = &pnx_algorithm;
593 alg_data = i2c_pnx->adapter->algo_data; 599 i2c_pnx->adapter->algo_data = alg_data;
594 600
595 alg_data->clk = clk_get(&pdev->dev, NULL); 601 alg_data->clk = clk_get(&pdev->dev, NULL);
596 if (IS_ERR(alg_data->clk)) { 602 if (IS_ERR(alg_data->clk)) {
@@ -603,16 +609,16 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
603 alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; 609 alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter;
604 610
605 /* Register I/O resource */ 611 /* Register I/O resource */
606 if (!request_mem_region(alg_data->base, I2C_PNX_REGION_SIZE, 612 if (!request_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE,
607 pdev->name)) { 613 pdev->name)) {
608 dev_err(&pdev->dev, 614 dev_err(&pdev->dev,
609 "I/O region 0x%08x for I2C already in use.\n", 615 "I/O region 0x%08x for I2C already in use.\n",
610 alg_data->base); 616 i2c_pnx->base);
611 ret = -ENODEV; 617 ret = -ENODEV;
612 goto out_clkget; 618 goto out_clkget;
613 } 619 }
614 620
615 alg_data->ioaddr = ioremap(alg_data->base, I2C_PNX_REGION_SIZE); 621 alg_data->ioaddr = ioremap(i2c_pnx->base, I2C_PNX_REGION_SIZE);
616 if (!alg_data->ioaddr) { 622 if (!alg_data->ioaddr) {
617 dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n"); 623 dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n");
618 ret = -ENOMEM; 624 ret = -ENOMEM;
@@ -647,7 +653,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
647 } 653 }
648 init_completion(&alg_data->mif.complete); 654 init_completion(&alg_data->mif.complete);
649 655
650 ret = request_irq(alg_data->irq, i2c_pnx_interrupt, 656 ret = request_irq(i2c_pnx->irq, i2c_pnx_interrupt,
651 0, pdev->name, i2c_pnx->adapter); 657 0, pdev->name, i2c_pnx->adapter);
652 if (ret) 658 if (ret)
653 goto out_clock; 659 goto out_clock;
@@ -662,21 +668,23 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
662 } 668 }
663 669
664 dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", 670 dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n",
665 i2c_pnx->adapter->name, alg_data->base, alg_data->irq); 671 i2c_pnx->adapter->name, i2c_pnx->base, i2c_pnx->irq);
666 672
667 return 0; 673 return 0;
668 674
669out_irq: 675out_irq:
670 free_irq(alg_data->irq, i2c_pnx->adapter); 676 free_irq(i2c_pnx->irq, i2c_pnx->adapter);
671out_clock: 677out_clock:
672 clk_disable(alg_data->clk); 678 clk_disable(alg_data->clk);
673out_unmap: 679out_unmap:
674 iounmap(alg_data->ioaddr); 680 iounmap(alg_data->ioaddr);
675out_release: 681out_release:
676 release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); 682 release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE);
677out_clkget: 683out_clkget:
678 clk_put(alg_data->clk); 684 clk_put(alg_data->clk);
679out_drvdata: 685out_drvdata:
686 kfree(alg_data);
687err_kzalloc:
680 platform_set_drvdata(pdev, NULL); 688 platform_set_drvdata(pdev, NULL);
681out: 689out:
682 return ret; 690 return ret;
@@ -688,12 +696,13 @@ static int __devexit i2c_pnx_remove(struct platform_device *pdev)
688 struct i2c_adapter *adap = i2c_pnx->adapter; 696 struct i2c_adapter *adap = i2c_pnx->adapter;
689 struct i2c_pnx_algo_data *alg_data = adap->algo_data; 697 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
690 698
691 free_irq(alg_data->irq, i2c_pnx->adapter); 699 free_irq(i2c_pnx->irq, i2c_pnx->adapter);
692 i2c_del_adapter(adap); 700 i2c_del_adapter(adap);
693 clk_disable(alg_data->clk); 701 clk_disable(alg_data->clk);
694 iounmap(alg_data->ioaddr); 702 iounmap(alg_data->ioaddr);
695 release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); 703 release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE);
696 clk_put(alg_data->clk); 704 clk_put(alg_data->clk);
705 kfree(alg_data);
697 platform_set_drvdata(pdev, NULL); 706 platform_set_drvdata(pdev, NULL);
698 707
699 return 0; 708 return 0;
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h
index 5a48f33046fb..9ebdf882d032 100644
--- a/include/linux/i2c-pnx.h
+++ b/include/linux/i2c-pnx.h
@@ -25,9 +25,7 @@ struct i2c_pnx_mif {
25}; 25};
26 26
27struct i2c_pnx_algo_data { 27struct i2c_pnx_algo_data {
28 u32 base;
29 void __iomem *ioaddr; 28 void __iomem *ioaddr;
30 int irq;
31 struct i2c_pnx_mif mif; 29 struct i2c_pnx_mif mif;
32 int last; 30 int last;
33 struct clk *clk; 31 struct clk *clk;
@@ -35,6 +33,8 @@ struct i2c_pnx_algo_data {
35 33
36struct i2c_pnx_data { 34struct i2c_pnx_data {
37 struct i2c_adapter *adapter; 35 struct i2c_adapter *adapter;
36 u32 base;
37 int irq;
38}; 38};
39 39
40#endif /* __I2C_PNX_H__ */ 40#endif /* __I2C_PNX_H__ */