diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-omap.c')
-rw-r--r-- | drivers/i2c/busses/i2c-omap.c | 275 |
1 files changed, 215 insertions, 60 deletions
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 6bd0f19cd451..7674efb55378 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/clk.h> | 38 | #include <linux/clk.h> |
39 | #include <linux/io.h> | 39 | #include <linux/io.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/i2c-omap.h> | ||
41 | 42 | ||
42 | /* I2C controller revisions */ | 43 | /* I2C controller revisions */ |
43 | #define OMAP_I2C_REV_2 0x20 | 44 | #define OMAP_I2C_REV_2 0x20 |
@@ -45,29 +46,37 @@ | |||
45 | /* I2C controller revisions present on specific hardware */ | 46 | /* I2C controller revisions present on specific hardware */ |
46 | #define OMAP_I2C_REV_ON_2430 0x36 | 47 | #define OMAP_I2C_REV_ON_2430 0x36 |
47 | #define OMAP_I2C_REV_ON_3430 0x3C | 48 | #define OMAP_I2C_REV_ON_3430 0x3C |
49 | #define OMAP_I2C_REV_ON_4430 0x40 | ||
48 | 50 | ||
49 | /* timeout waiting for the controller to respond */ | 51 | /* timeout waiting for the controller to respond */ |
50 | #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) | 52 | #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) |
51 | 53 | ||
52 | #define OMAP_I2C_REV_REG 0x00 | ||
53 | #define OMAP_I2C_IE_REG 0x01 | ||
54 | #define OMAP_I2C_STAT_REG 0x02 | ||
55 | #define OMAP_I2C_IV_REG 0x03 | ||
56 | /* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */ | 54 | /* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */ |
57 | #define OMAP_I2C_WE_REG 0x03 | 55 | enum { |
58 | #define OMAP_I2C_SYSS_REG 0x04 | 56 | OMAP_I2C_REV_REG = 0, |
59 | #define OMAP_I2C_BUF_REG 0x05 | 57 | OMAP_I2C_IE_REG, |
60 | #define OMAP_I2C_CNT_REG 0x06 | 58 | OMAP_I2C_STAT_REG, |
61 | #define OMAP_I2C_DATA_REG 0x07 | 59 | OMAP_I2C_IV_REG, |
62 | #define OMAP_I2C_SYSC_REG 0x08 | 60 | OMAP_I2C_WE_REG, |
63 | #define OMAP_I2C_CON_REG 0x09 | 61 | OMAP_I2C_SYSS_REG, |
64 | #define OMAP_I2C_OA_REG 0x0a | 62 | OMAP_I2C_BUF_REG, |
65 | #define OMAP_I2C_SA_REG 0x0b | 63 | OMAP_I2C_CNT_REG, |
66 | #define OMAP_I2C_PSC_REG 0x0c | 64 | OMAP_I2C_DATA_REG, |
67 | #define OMAP_I2C_SCLL_REG 0x0d | 65 | OMAP_I2C_SYSC_REG, |
68 | #define OMAP_I2C_SCLH_REG 0x0e | 66 | OMAP_I2C_CON_REG, |
69 | #define OMAP_I2C_SYSTEST_REG 0x0f | 67 | OMAP_I2C_OA_REG, |
70 | #define OMAP_I2C_BUFSTAT_REG 0x10 | 68 | OMAP_I2C_SA_REG, |
69 | OMAP_I2C_PSC_REG, | ||
70 | OMAP_I2C_SCLL_REG, | ||
71 | OMAP_I2C_SCLH_REG, | ||
72 | OMAP_I2C_SYSTEST_REG, | ||
73 | OMAP_I2C_BUFSTAT_REG, | ||
74 | OMAP_I2C_REVNB_LO, | ||
75 | OMAP_I2C_REVNB_HI, | ||
76 | OMAP_I2C_IRQSTATUS_RAW, | ||
77 | OMAP_I2C_IRQENABLE_SET, | ||
78 | OMAP_I2C_IRQENABLE_CLR, | ||
79 | }; | ||
71 | 80 | ||
72 | /* I2C Interrupt Enable Register (OMAP_I2C_IE): */ | 81 | /* I2C Interrupt Enable Register (OMAP_I2C_IE): */ |
73 | #define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */ | 82 | #define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */ |
@@ -157,6 +166,9 @@ | |||
157 | #define SYSC_IDLEMODE_SMART 0x2 | 166 | #define SYSC_IDLEMODE_SMART 0x2 |
158 | #define SYSC_CLOCKACTIVITY_FCLK 0x2 | 167 | #define SYSC_CLOCKACTIVITY_FCLK 0x2 |
159 | 168 | ||
169 | /* Errata definitions */ | ||
170 | #define I2C_OMAP_ERRATA_I207 (1 << 0) | ||
171 | #define I2C_OMAP3_1P153 (1 << 1) | ||
160 | 172 | ||
161 | struct omap_i2c_dev { | 173 | struct omap_i2c_dev { |
162 | struct device *dev; | 174 | struct device *dev; |
@@ -167,9 +179,13 @@ struct omap_i2c_dev { | |||
167 | struct clk *fclk; /* Functional clock */ | 179 | struct clk *fclk; /* Functional clock */ |
168 | struct completion cmd_complete; | 180 | struct completion cmd_complete; |
169 | struct resource *ioarea; | 181 | struct resource *ioarea; |
182 | u32 latency; /* maximum mpu wkup latency */ | ||
183 | void (*set_mpu_wkup_lat)(struct device *dev, | ||
184 | long latency); | ||
170 | u32 speed; /* Speed of bus in Khz */ | 185 | u32 speed; /* Speed of bus in Khz */ |
171 | u16 cmd_err; | 186 | u16 cmd_err; |
172 | u8 *buf; | 187 | u8 *buf; |
188 | u8 *regs; | ||
173 | size_t buf_len; | 189 | size_t buf_len; |
174 | struct i2c_adapter adapter; | 190 | struct i2c_adapter adapter; |
175 | u8 fifo_size; /* use as flag and value | 191 | u8 fifo_size; /* use as flag and value |
@@ -186,17 +202,67 @@ struct omap_i2c_dev { | |||
186 | u16 bufstate; | 202 | u16 bufstate; |
187 | u16 syscstate; | 203 | u16 syscstate; |
188 | u16 westate; | 204 | u16 westate; |
205 | u16 errata; | ||
206 | }; | ||
207 | |||
208 | const static u8 reg_map[] = { | ||
209 | [OMAP_I2C_REV_REG] = 0x00, | ||
210 | [OMAP_I2C_IE_REG] = 0x01, | ||
211 | [OMAP_I2C_STAT_REG] = 0x02, | ||
212 | [OMAP_I2C_IV_REG] = 0x03, | ||
213 | [OMAP_I2C_WE_REG] = 0x03, | ||
214 | [OMAP_I2C_SYSS_REG] = 0x04, | ||
215 | [OMAP_I2C_BUF_REG] = 0x05, | ||
216 | [OMAP_I2C_CNT_REG] = 0x06, | ||
217 | [OMAP_I2C_DATA_REG] = 0x07, | ||
218 | [OMAP_I2C_SYSC_REG] = 0x08, | ||
219 | [OMAP_I2C_CON_REG] = 0x09, | ||
220 | [OMAP_I2C_OA_REG] = 0x0a, | ||
221 | [OMAP_I2C_SA_REG] = 0x0b, | ||
222 | [OMAP_I2C_PSC_REG] = 0x0c, | ||
223 | [OMAP_I2C_SCLL_REG] = 0x0d, | ||
224 | [OMAP_I2C_SCLH_REG] = 0x0e, | ||
225 | [OMAP_I2C_SYSTEST_REG] = 0x0f, | ||
226 | [OMAP_I2C_BUFSTAT_REG] = 0x10, | ||
227 | }; | ||
228 | |||
229 | const static u8 omap4_reg_map[] = { | ||
230 | [OMAP_I2C_REV_REG] = 0x04, | ||
231 | [OMAP_I2C_IE_REG] = 0x2c, | ||
232 | [OMAP_I2C_STAT_REG] = 0x28, | ||
233 | [OMAP_I2C_IV_REG] = 0x34, | ||
234 | [OMAP_I2C_WE_REG] = 0x34, | ||
235 | [OMAP_I2C_SYSS_REG] = 0x90, | ||
236 | [OMAP_I2C_BUF_REG] = 0x94, | ||
237 | [OMAP_I2C_CNT_REG] = 0x98, | ||
238 | [OMAP_I2C_DATA_REG] = 0x9c, | ||
239 | [OMAP_I2C_SYSC_REG] = 0x20, | ||
240 | [OMAP_I2C_CON_REG] = 0xa4, | ||
241 | [OMAP_I2C_OA_REG] = 0xa8, | ||
242 | [OMAP_I2C_SA_REG] = 0xac, | ||
243 | [OMAP_I2C_PSC_REG] = 0xb0, | ||
244 | [OMAP_I2C_SCLL_REG] = 0xb4, | ||
245 | [OMAP_I2C_SCLH_REG] = 0xb8, | ||
246 | [OMAP_I2C_SYSTEST_REG] = 0xbC, | ||
247 | [OMAP_I2C_BUFSTAT_REG] = 0xc0, | ||
248 | [OMAP_I2C_REVNB_LO] = 0x00, | ||
249 | [OMAP_I2C_REVNB_HI] = 0x04, | ||
250 | [OMAP_I2C_IRQSTATUS_RAW] = 0x24, | ||
251 | [OMAP_I2C_IRQENABLE_SET] = 0x2c, | ||
252 | [OMAP_I2C_IRQENABLE_CLR] = 0x30, | ||
189 | }; | 253 | }; |
190 | 254 | ||
191 | static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, | 255 | static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, |
192 | int reg, u16 val) | 256 | int reg, u16 val) |
193 | { | 257 | { |
194 | __raw_writew(val, i2c_dev->base + (reg << i2c_dev->reg_shift)); | 258 | __raw_writew(val, i2c_dev->base + |
259 | (i2c_dev->regs[reg] << i2c_dev->reg_shift)); | ||
195 | } | 260 | } |
196 | 261 | ||
197 | static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) | 262 | static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) |
198 | { | 263 | { |
199 | return __raw_readw(i2c_dev->base + (reg << i2c_dev->reg_shift)); | 264 | return __raw_readw(i2c_dev->base + |
265 | (i2c_dev->regs[reg] << i2c_dev->reg_shift)); | ||
200 | } | 266 | } |
201 | 267 | ||
202 | static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) | 268 | static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) |
@@ -265,7 +331,11 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev) | |||
265 | WARN_ON(dev->idle); | 331 | WARN_ON(dev->idle); |
266 | 332 | ||
267 | dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); | 333 | dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); |
268 | omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0); | 334 | if (dev->rev >= OMAP_I2C_REV_ON_4430) |
335 | omap_i2c_write_reg(dev, OMAP_I2C_IRQENABLE_CLR, 1); | ||
336 | else | ||
337 | omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0); | ||
338 | |||
269 | if (dev->rev < OMAP_I2C_REV_2) { | 339 | if (dev->rev < OMAP_I2C_REV_2) { |
270 | iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */ | 340 | iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */ |
271 | } else { | 341 | } else { |
@@ -330,7 +400,9 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
330 | * REVISIT: Some wkup sources might not be needed. | 400 | * REVISIT: Some wkup sources might not be needed. |
331 | */ | 401 | */ |
332 | dev->westate = OMAP_I2C_WE_ALL; | 402 | dev->westate = OMAP_I2C_WE_ALL; |
333 | omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate); | 403 | if (dev->rev < OMAP_I2C_REV_ON_4430) |
404 | omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, | ||
405 | dev->westate); | ||
334 | } | 406 | } |
335 | } | 407 | } |
336 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); | 408 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); |
@@ -357,7 +429,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
357 | psc = fclk_rate / 12000000; | 429 | psc = fclk_rate / 12000000; |
358 | } | 430 | } |
359 | 431 | ||
360 | if (cpu_is_omap2430() || cpu_is_omap34xx()) { | 432 | if (!(cpu_class_is_omap1() || cpu_is_omap2420())) { |
361 | 433 | ||
362 | /* | 434 | /* |
363 | * HSI2C controller internal clk rate should be 19.2 Mhz for | 435 | * HSI2C controller internal clk rate should be 19.2 Mhz for |
@@ -430,6 +502,11 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
430 | /* Take the I2C module out of reset: */ | 502 | /* Take the I2C module out of reset: */ |
431 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); | 503 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); |
432 | 504 | ||
505 | dev->errata = 0; | ||
506 | |||
507 | if (cpu_is_omap2430() || cpu_is_omap34xx()) | ||
508 | dev->errata |= I2C_OMAP_ERRATA_I207; | ||
509 | |||
433 | /* Enable interrupts */ | 510 | /* Enable interrupts */ |
434 | dev->iestate = (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | | 511 | dev->iestate = (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | |
435 | OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK | | 512 | OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK | |
@@ -539,8 +616,12 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, | |||
539 | * REVISIT: We should abort the transfer on signals, but the bus goes | 616 | * REVISIT: We should abort the transfer on signals, but the bus goes |
540 | * into arbitration and we're currently unable to recover from it. | 617 | * into arbitration and we're currently unable to recover from it. |
541 | */ | 618 | */ |
619 | if (dev->set_mpu_wkup_lat != NULL) | ||
620 | dev->set_mpu_wkup_lat(dev->dev, dev->latency); | ||
542 | r = wait_for_completion_timeout(&dev->cmd_complete, | 621 | r = wait_for_completion_timeout(&dev->cmd_complete, |
543 | OMAP_I2C_TIMEOUT); | 622 | OMAP_I2C_TIMEOUT); |
623 | if (dev->set_mpu_wkup_lat != NULL) | ||
624 | dev->set_mpu_wkup_lat(dev->dev, -1); | ||
544 | dev->buf_len = 0; | 625 | dev->buf_len = 0; |
545 | if (r < 0) | 626 | if (r < 0) |
546 | return r; | 627 | return r; |
@@ -623,6 +704,34 @@ omap_i2c_ack_stat(struct omap_i2c_dev *dev, u16 stat) | |||
623 | omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); | 704 | omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); |
624 | } | 705 | } |
625 | 706 | ||
707 | static inline void i2c_omap_errata_i207(struct omap_i2c_dev *dev, u16 stat) | ||
708 | { | ||
709 | /* | ||
710 | * I2C Errata(Errata Nos. OMAP2: 1.67, OMAP3: 1.8) | ||
711 | * Not applicable for OMAP4. | ||
712 | * Under certain rare conditions, RDR could be set again | ||
713 | * when the bus is busy, then ignore the interrupt and | ||
714 | * clear the interrupt. | ||
715 | */ | ||
716 | if (stat & OMAP_I2C_STAT_RDR) { | ||
717 | /* Step 1: If RDR is set, clear it */ | ||
718 | omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RDR); | ||
719 | |||
720 | /* Step 2: */ | ||
721 | if (!(omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG) | ||
722 | & OMAP_I2C_STAT_BB)) { | ||
723 | |||
724 | /* Step 3: */ | ||
725 | if (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG) | ||
726 | & OMAP_I2C_STAT_RDR) { | ||
727 | omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RDR); | ||
728 | dev_dbg(dev->dev, "RDR when bus is busy.\n"); | ||
729 | } | ||
730 | |||
731 | } | ||
732 | } | ||
733 | } | ||
734 | |||
626 | /* rev1 devices are apparently only on some 15xx */ | 735 | /* rev1 devices are apparently only on some 15xx */ |
627 | #ifdef CONFIG_ARCH_OMAP15XX | 736 | #ifdef CONFIG_ARCH_OMAP15XX |
628 | 737 | ||
@@ -684,6 +793,35 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id) | |||
684 | #define omap_i2c_rev1_isr NULL | 793 | #define omap_i2c_rev1_isr NULL |
685 | #endif | 794 | #endif |
686 | 795 | ||
796 | /* | ||
797 | * OMAP3430 Errata 1.153: When an XRDY/XDR is hit, wait for XUDF before writing | ||
798 | * data to DATA_REG. Otherwise some data bytes can be lost while transferring | ||
799 | * them from the memory to the I2C interface. | ||
800 | */ | ||
801 | static int errata_omap3_1p153(struct omap_i2c_dev *dev, u16 *stat, int *err) | ||
802 | { | ||
803 | unsigned long timeout = 10000; | ||
804 | |||
805 | while (--timeout && !(*stat & OMAP_I2C_STAT_XUDF)) { | ||
806 | if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { | ||
807 | omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY | | ||
808 | OMAP_I2C_STAT_XDR)); | ||
809 | *err |= OMAP_I2C_STAT_XUDF; | ||
810 | return -ETIMEDOUT; | ||
811 | } | ||
812 | |||
813 | cpu_relax(); | ||
814 | *stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); | ||
815 | } | ||
816 | |||
817 | if (!timeout) { | ||
818 | dev_err(dev->dev, "timeout waiting on XUDF bit\n"); | ||
819 | return 0; | ||
820 | } | ||
821 | |||
822 | return 0; | ||
823 | } | ||
824 | |||
687 | static irqreturn_t | 825 | static irqreturn_t |
688 | omap_i2c_isr(int this_irq, void *dev_id) | 826 | omap_i2c_isr(int this_irq, void *dev_id) |
689 | { | 827 | { |
@@ -733,6 +871,10 @@ complete: | |||
733 | } | 871 | } |
734 | if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) { | 872 | if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) { |
735 | u8 num_bytes = 1; | 873 | u8 num_bytes = 1; |
874 | |||
875 | if (dev->errata & I2C_OMAP_ERRATA_I207) | ||
876 | i2c_omap_errata_i207(dev, stat); | ||
877 | |||
736 | if (dev->fifo_size) { | 878 | if (dev->fifo_size) { |
737 | if (stat & OMAP_I2C_STAT_RRDY) | 879 | if (stat & OMAP_I2C_STAT_RRDY) |
738 | num_bytes = dev->fifo_size; | 880 | num_bytes = dev->fifo_size; |
@@ -747,9 +889,12 @@ complete: | |||
747 | if (dev->buf_len) { | 889 | if (dev->buf_len) { |
748 | *dev->buf++ = w; | 890 | *dev->buf++ = w; |
749 | dev->buf_len--; | 891 | dev->buf_len--; |
750 | /* Data reg from 2430 is 8 bit wide */ | 892 | /* |
751 | if (!cpu_is_omap2430() && | 893 | * Data reg in 2430, omap3 and |
752 | !cpu_is_omap34xx()) { | 894 | * omap4 is 8 bit wide |
895 | */ | ||
896 | if (cpu_class_is_omap1() || | ||
897 | cpu_is_omap2420()) { | ||
753 | if (dev->buf_len) { | 898 | if (dev->buf_len) { |
754 | *dev->buf++ = w >> 8; | 899 | *dev->buf++ = w >> 8; |
755 | dev->buf_len--; | 900 | dev->buf_len--; |
@@ -787,9 +932,12 @@ complete: | |||
787 | if (dev->buf_len) { | 932 | if (dev->buf_len) { |
788 | w = *dev->buf++; | 933 | w = *dev->buf++; |
789 | dev->buf_len--; | 934 | dev->buf_len--; |
790 | /* Data reg from 2430 is 8 bit wide */ | 935 | /* |
791 | if (!cpu_is_omap2430() && | 936 | * Data reg in 2430, omap3 and |
792 | !cpu_is_omap34xx()) { | 937 | * omap4 is 8 bit wide |
938 | */ | ||
939 | if (cpu_class_is_omap1() || | ||
940 | cpu_is_omap2420()) { | ||
793 | if (dev->buf_len) { | 941 | if (dev->buf_len) { |
794 | w |= *dev->buf++ << 8; | 942 | w |= *dev->buf++ << 8; |
795 | dev->buf_len--; | 943 | dev->buf_len--; |
@@ -807,25 +955,9 @@ complete: | |||
807 | break; | 955 | break; |
808 | } | 956 | } |
809 | 957 | ||
810 | /* | 958 | if ((dev->errata & I2C_OMAP3_1P153) && |
811 | * OMAP3430 Errata 1.153: When an XRDY/XDR | 959 | errata_omap3_1p153(dev, &stat, &err)) |
812 | * is hit, wait for XUDF before writing data | 960 | goto complete; |
813 | * to DATA_REG. Otherwise some data bytes can | ||
814 | * be lost while transferring them from the | ||
815 | * memory to the I2C interface. | ||
816 | */ | ||
817 | |||
818 | if (dev->rev <= OMAP_I2C_REV_ON_3430) { | ||
819 | while (!(stat & OMAP_I2C_STAT_XUDF)) { | ||
820 | if (stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { | ||
821 | omap_i2c_ack_stat(dev, stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)); | ||
822 | err |= OMAP_I2C_STAT_XUDF; | ||
823 | goto complete; | ||
824 | } | ||
825 | cpu_relax(); | ||
826 | stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); | ||
827 | } | ||
828 | } | ||
829 | 961 | ||
830 | omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); | 962 | omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); |
831 | } | 963 | } |
@@ -857,6 +989,7 @@ omap_i2c_probe(struct platform_device *pdev) | |||
857 | struct omap_i2c_dev *dev; | 989 | struct omap_i2c_dev *dev; |
858 | struct i2c_adapter *adap; | 990 | struct i2c_adapter *adap; |
859 | struct resource *mem, *irq, *ioarea; | 991 | struct resource *mem, *irq, *ioarea; |
992 | struct omap_i2c_bus_platform_data *pdata = pdev->dev.platform_data; | ||
860 | irq_handler_t isr; | 993 | irq_handler_t isr; |
861 | int r; | 994 | int r; |
862 | u32 speed = 0; | 995 | u32 speed = 0; |
@@ -886,10 +1019,13 @@ omap_i2c_probe(struct platform_device *pdev) | |||
886 | goto err_release_region; | 1019 | goto err_release_region; |
887 | } | 1020 | } |
888 | 1021 | ||
889 | if (pdev->dev.platform_data != NULL) | 1022 | if (pdata != NULL) { |
890 | speed = *(u32 *)pdev->dev.platform_data; | 1023 | speed = pdata->clkrate; |
891 | else | 1024 | dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; |
892 | speed = 100; /* Defualt speed */ | 1025 | } else { |
1026 | speed = 100; /* Default speed */ | ||
1027 | dev->set_mpu_wkup_lat = NULL; | ||
1028 | } | ||
893 | 1029 | ||
894 | dev->speed = speed; | 1030 | dev->speed = speed; |
895 | dev->idle = 1; | 1031 | dev->idle = 1; |
@@ -903,14 +1039,29 @@ omap_i2c_probe(struct platform_device *pdev) | |||
903 | 1039 | ||
904 | platform_set_drvdata(pdev, dev); | 1040 | platform_set_drvdata(pdev, dev); |
905 | 1041 | ||
1042 | if (cpu_is_omap7xx()) | ||
1043 | dev->reg_shift = 1; | ||
1044 | else if (cpu_is_omap44xx()) | ||
1045 | dev->reg_shift = 0; | ||
1046 | else | ||
1047 | dev->reg_shift = 2; | ||
1048 | |||
906 | if ((r = omap_i2c_get_clocks(dev)) != 0) | 1049 | if ((r = omap_i2c_get_clocks(dev)) != 0) |
907 | goto err_iounmap; | 1050 | goto err_iounmap; |
908 | 1051 | ||
1052 | if (cpu_is_omap44xx()) | ||
1053 | dev->regs = (u8 *) omap4_reg_map; | ||
1054 | else | ||
1055 | dev->regs = (u8 *) reg_map; | ||
1056 | |||
909 | omap_i2c_unidle(dev); | 1057 | omap_i2c_unidle(dev); |
910 | 1058 | ||
911 | dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff; | 1059 | dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff; |
912 | 1060 | ||
913 | if (cpu_is_omap2430() || cpu_is_omap34xx()) { | 1061 | if (dev->rev <= OMAP_I2C_REV_ON_3430) |
1062 | dev->errata |= I2C_OMAP3_1P153; | ||
1063 | |||
1064 | if (!(cpu_class_is_omap1() || cpu_is_omap2420())) { | ||
914 | u16 s; | 1065 | u16 s; |
915 | 1066 | ||
916 | /* Set up the fifo size - Get total size */ | 1067 | /* Set up the fifo size - Get total size */ |
@@ -922,15 +1073,19 @@ omap_i2c_probe(struct platform_device *pdev) | |||
922 | * size. This is to ensure that we can handle the status on int | 1073 | * size. This is to ensure that we can handle the status on int |
923 | * call back latencies. | 1074 | * call back latencies. |
924 | */ | 1075 | */ |
925 | dev->fifo_size = (dev->fifo_size / 2); | 1076 | if (dev->rev >= OMAP_I2C_REV_ON_4430) { |
926 | dev->b_hw = 1; /* Enable hardware fixes */ | 1077 | dev->fifo_size = 0; |
1078 | dev->b_hw = 0; /* Disable hardware fixes */ | ||
1079 | } else { | ||
1080 | dev->fifo_size = (dev->fifo_size / 2); | ||
1081 | dev->b_hw = 1; /* Enable hardware fixes */ | ||
1082 | } | ||
1083 | /* calculate wakeup latency constraint for MPU */ | ||
1084 | if (dev->set_mpu_wkup_lat != NULL) | ||
1085 | dev->latency = (1000000 * dev->fifo_size) / | ||
1086 | (1000 * speed / 8); | ||
927 | } | 1087 | } |
928 | 1088 | ||
929 | if (cpu_is_omap7xx()) | ||
930 | dev->reg_shift = 1; | ||
931 | else | ||
932 | dev->reg_shift = 2; | ||
933 | |||
934 | /* reset ASAP, clearing any IRQs */ | 1089 | /* reset ASAP, clearing any IRQs */ |
935 | omap_i2c_init(dev); | 1090 | omap_i2c_init(dev); |
936 | 1091 | ||