aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-pxa.c
diff options
context:
space:
mode:
authoreric miao <eric.y.miao@gmail.com>2008-01-27 12:14:46 -0500
committerJean Delvare <khali@hyperion.delvare>2008-01-27 12:14:46 -0500
commit59d70df025473931c500d6d60510798e4bfa3279 (patch)
tree8b434d43a66e690755eaa07daf0bb9b147ac92f7 /drivers/i2c/busses/i2c-pxa.c
parent7e8b99251be8b6f992baa88e3a6ba3c4ae01660b (diff)
i2c-pxa: Remove hardcoded #ifdef and use cpu_is_pxa27x
remove #ifdef CONFIG_PXA27x .. #endif and use cpu_is_pxaXXXX() macros so that a single binary can support PXA25x/PXA27x/PXA3xx at run-time. Signed-off-by: eric miao <eric.miao@marvell.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-pxa.c')
-rw-r--r--drivers/i2c/busses/i2c-pxa.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 6426a61f8d4d..da3ecf5c591b 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -840,6 +840,32 @@ static const struct i2c_algorithm i2c_pxa_algorithm = {
840 .functionality = i2c_pxa_functionality, 840 .functionality = i2c_pxa_functionality,
841}; 841};
842 842
843static void i2c_pxa_enable(struct platform_device *dev)
844{
845 if (cpu_is_pxa27x()) {
846 switch (dev->id) {
847 case 0:
848 pxa_gpio_mode(GPIO117_I2CSCL_MD);
849 pxa_gpio_mode(GPIO118_I2CSDA_MD);
850 break;
851 case 1:
852 local_irq_disable();
853 PCFR |= PCFR_PI2CEN;
854 local_irq_enable();
855 break;
856 }
857 }
858}
859
860static void i2c_pxa_disable(struct platform_device *dev)
861{
862 if (cpu_is_pxa27x() && dev->id == 1) {
863 local_irq_disable();
864 PCFR &= ~PCFR_PI2CEN;
865 local_irq_enable();
866 }
867}
868
843#define res_len(r) ((r)->end - (r)->start + 1) 869#define res_len(r) ((r)->end - (r)->start + 1)
844static int i2c_pxa_probe(struct platform_device *dev) 870static int i2c_pxa_probe(struct platform_device *dev)
845{ 871{
@@ -899,25 +925,13 @@ static int i2c_pxa_probe(struct platform_device *dev)
899#endif 925#endif
900 926
901 clk_enable(i2c->clk); 927 clk_enable(i2c->clk);
902#ifdef CONFIG_PXA27x 928 i2c_pxa_enable(dev);
903 switch (dev->id) {
904 case 0:
905 pxa_gpio_mode(GPIO117_I2CSCL_MD);
906 pxa_gpio_mode(GPIO118_I2CSDA_MD);
907 break;
908 case 1:
909 local_irq_disable();
910 PCFR |= PCFR_PI2CEN;
911 local_irq_enable();
912 }
913#endif
914 929
915 ret = request_irq(irq, i2c_pxa_handler, IRQF_DISABLED, 930 ret = request_irq(irq, i2c_pxa_handler, IRQF_DISABLED,
916 i2c->adap.name, i2c); 931 i2c->adap.name, i2c);
917 if (ret) 932 if (ret)
918 goto ereqirq; 933 goto ereqirq;
919 934
920
921 i2c_pxa_reset(i2c); 935 i2c_pxa_reset(i2c);
922 936
923 i2c->adap.algo_data = i2c; 937 i2c->adap.algo_data = i2c;
@@ -955,14 +969,7 @@ eadapt:
955 free_irq(irq, i2c); 969 free_irq(irq, i2c);
956ereqirq: 970ereqirq:
957 clk_disable(i2c->clk); 971 clk_disable(i2c->clk);
958 972 i2c_pxa_disable(dev);
959#ifdef CONFIG_PXA27x
960 if (dev->id == 1) {
961 local_irq_disable();
962 PCFR &= ~PCFR_PI2CEN;
963 local_irq_enable();
964 }
965#endif
966eremap: 973eremap:
967 clk_put(i2c->clk); 974 clk_put(i2c->clk);
968eclk: 975eclk:
@@ -983,14 +990,7 @@ static int i2c_pxa_remove(struct platform_device *dev)
983 990
984 clk_disable(i2c->clk); 991 clk_disable(i2c->clk);
985 clk_put(i2c->clk); 992 clk_put(i2c->clk);
986 993 i2c_pxa_disable(dev);
987#ifdef CONFIG_PXA27x
988 if (dev->id == 1) {
989 local_irq_disable();
990 PCFR &= ~PCFR_PI2CEN;
991 local_irq_enable();
992 }
993#endif
994 994
995 release_mem_region(i2c->iobase, i2c->iosize); 995 release_mem_region(i2c->iobase, i2c->iosize);
996 kfree(i2c); 996 kfree(i2c);