aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-pxa.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-pxa.c')
-rw-r--r--drivers/i2c/busses/i2c-pxa.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 14e83d0aac8c..873544ab598e 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -539,6 +539,18 @@ static inline void i2c_pxa_start_message(struct pxa_i2c *i2c)
539 writel(icr | ICR_START | ICR_TB, _ICR(i2c)); 539 writel(icr | ICR_START | ICR_TB, _ICR(i2c));
540} 540}
541 541
542static inline void i2c_pxa_stop_message(struct pxa_i2c *i2c)
543{
544 u32 icr;
545
546 /*
547 * Clear the STOP and ACK flags
548 */
549 icr = readl(_ICR(i2c));
550 icr &= ~(ICR_STOP | ICR_ACKNAK);
551 writel(icr, _IRC(i2c));
552}
553
542/* 554/*
543 * We are protected by the adapter bus mutex. 555 * We are protected by the adapter bus mutex.
544 */ 556 */
@@ -581,6 +593,7 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
581 * The rest of the processing occurs in the interrupt handler. 593 * The rest of the processing occurs in the interrupt handler.
582 */ 594 */
583 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); 595 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
596 i2c_pxa_stop_message(i2c);
584 597
585 /* 598 /*
586 * We place the return code in i2c->msg_idx. 599 * We place the return code in i2c->msg_idx.
@@ -825,7 +838,7 @@ static const struct i2c_algorithm i2c_pxa_algorithm = {
825}; 838};
826 839
827static struct pxa_i2c i2c_pxa = { 840static struct pxa_i2c i2c_pxa = {
828 .lock = SPIN_LOCK_UNLOCKED, 841 .lock = __SPIN_LOCK_UNLOCKED(i2c_pxa.lock),
829 .adap = { 842 .adap = {
830 .owner = THIS_MODULE, 843 .owner = THIS_MODULE,
831 .algo = &i2c_pxa_algorithm, 844 .algo = &i2c_pxa_algorithm,
@@ -839,9 +852,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
839{ 852{
840 struct pxa_i2c *i2c = &i2c_pxa; 853 struct pxa_i2c *i2c = &i2c_pxa;
841 struct resource *res; 854 struct resource *res;
842#ifdef CONFIG_I2C_PXA_SLAVE
843 struct i2c_pxa_platform_data *plat = dev->dev.platform_data; 855 struct i2c_pxa_platform_data *plat = dev->dev.platform_data;
844#endif
845 int ret; 856 int ret;
846 int irq; 857 int irq;
847 858
@@ -889,14 +900,14 @@ static int i2c_pxa_probe(struct platform_device *dev)
889 pxa_gpio_mode(GPIO117_I2CSCL_MD); 900 pxa_gpio_mode(GPIO117_I2CSCL_MD);
890 pxa_gpio_mode(GPIO118_I2CSDA_MD); 901 pxa_gpio_mode(GPIO118_I2CSDA_MD);
891#endif 902#endif
892 pxa_set_cken(CKEN14_I2C, 1); 903 pxa_set_cken(CKEN_I2C, 1);
893 break; 904 break;
894#ifdef CONFIG_PXA27x 905#ifdef CONFIG_PXA27x
895 case 1: 906 case 1:
896 local_irq_disable(); 907 local_irq_disable();
897 PCFR |= PCFR_PI2CEN; 908 PCFR |= PCFR_PI2CEN;
898 local_irq_enable(); 909 local_irq_enable();
899 pxa_set_cken(CKEN15_PWRI2C, 1); 910 pxa_set_cken(CKEN_PWRI2C, 1);
900#endif 911#endif
901 } 912 }
902 913
@@ -911,6 +922,10 @@ static int i2c_pxa_probe(struct platform_device *dev)
911 i2c->adap.algo_data = i2c; 922 i2c->adap.algo_data = i2c;
912 i2c->adap.dev.parent = &dev->dev; 923 i2c->adap.dev.parent = &dev->dev;
913 924
925 if (plat) {
926 i2c->adap.class = plat->class;
927 }
928
914 ret = i2c_add_adapter(&i2c->adap); 929 ret = i2c_add_adapter(&i2c->adap);
915 if (ret < 0) { 930 if (ret < 0) {
916 printk(KERN_INFO "I2C: Failed to add bus\n"); 931 printk(KERN_INFO "I2C: Failed to add bus\n");
@@ -933,11 +948,11 @@ eadapt:
933ereqirq: 948ereqirq:
934 switch (dev->id) { 949 switch (dev->id) {
935 case 0: 950 case 0:
936 pxa_set_cken(CKEN14_I2C, 0); 951 pxa_set_cken(CKEN_I2C, 0);
937 break; 952 break;
938#ifdef CONFIG_PXA27x 953#ifdef CONFIG_PXA27x
939 case 1: 954 case 1:
940 pxa_set_cken(CKEN15_PWRI2C, 0); 955 pxa_set_cken(CKEN_PWRI2C, 0);
941 local_irq_disable(); 956 local_irq_disable();
942 PCFR &= ~PCFR_PI2CEN; 957 PCFR &= ~PCFR_PI2CEN;
943 local_irq_enable(); 958 local_irq_enable();
@@ -960,11 +975,11 @@ static int i2c_pxa_remove(struct platform_device *dev)
960 free_irq(i2c->irq, i2c); 975 free_irq(i2c->irq, i2c);
961 switch (dev->id) { 976 switch (dev->id) {
962 case 0: 977 case 0:
963 pxa_set_cken(CKEN14_I2C, 0); 978 pxa_set_cken(CKEN_I2C, 0);
964 break; 979 break;
965#ifdef CONFIG_PXA27x 980#ifdef CONFIG_PXA27x
966 case 1: 981 case 1:
967 pxa_set_cken(CKEN15_PWRI2C, 0); 982 pxa_set_cken(CKEN_PWRI2C, 0);
968 local_irq_disable(); 983 local_irq_disable();
969 PCFR &= ~PCFR_PI2CEN; 984 PCFR &= ~PCFR_PI2CEN;
970 local_irq_enable(); 985 local_irq_enable();