1
2
3
4
5
6
7
8
9
10
11
12
13#include <linux/clk.h>
14#include <linux/delay.h>
15#include <linux/i2c.h>
16#include <linux/interrupt.h>
17#include <linux/io.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20#include <linux/of.h>
21#include <linux/of_gpio.h>
22#include <linux/pm_runtime.h>
23#include <linux/pinctrl/consumer.h>
24
25
26#define CDNS_I2C_CR_OFFSET 0x00
27#define CDNS_I2C_SR_OFFSET 0x04
28#define CDNS_I2C_ADDR_OFFSET 0x08
29#define CDNS_I2C_DATA_OFFSET 0x0C
30#define CDNS_I2C_ISR_OFFSET 0x10
31#define CDNS_I2C_XFER_SIZE_OFFSET 0x14
32#define CDNS_I2C_SLV_PAUSE_OFFSET 0x18
33#define CDNS_I2C_TIME_OUT_OFFSET 0x1C
34#define CDNS_I2C_IMR_OFFSET 0x20
35#define CDNS_I2C_IER_OFFSET 0x24
36#define CDNS_I2C_IDR_OFFSET 0x28
37
38
39#define CDNS_I2C_CR_SLVMON BIT(5)
40#define CDNS_I2C_CR_HOLD BIT(4)
41#define CDNS_I2C_CR_ACK_EN BIT(3)
42#define CDNS_I2C_CR_NEA BIT(2)
43#define CDNS_I2C_CR_MS BIT(1)
44
45#define CDNS_I2C_CR_RW BIT(0)
46
47#define CDNS_I2C_CR_CLR_FIFO BIT(6)
48#define CDNS_I2C_CR_DIVA_SHIFT 14
49#define CDNS_I2C_CR_DIVA_MASK (3 << CDNS_I2C_CR_DIVA_SHIFT)
50#define CDNS_I2C_CR_DIVB_SHIFT 8
51#define CDNS_I2C_CR_DIVB_MASK (0x3f << CDNS_I2C_CR_DIVB_SHIFT)
52
53#define CDNS_I2C_CR_SLAVE_EN_MASK (CDNS_I2C_CR_CLR_FIFO | \
54 CDNS_I2C_CR_NEA | \
55 CDNS_I2C_CR_ACK_EN | \
56 CDNS_I2C_CR_MS)
57
58
59#define CDNS_I2C_SR_BA BIT(8)
60#define CDNS_I2C_SR_TXDV BIT(6)
61#define CDNS_I2C_SR_RXDV BIT(5)
62#define CDNS_I2C_SR_RXRW BIT(3)
63
64
65
66
67
68
69
70#define CDNS_I2C_ADDR_MASK 0x000003FF
71
72
73
74
75
76
77#define CDNS_I2C_IXR_ARB_LOST BIT(9)
78#define CDNS_I2C_IXR_RX_UNF BIT(7)
79#define CDNS_I2C_IXR_TX_OVF BIT(6)
80#define CDNS_I2C_IXR_RX_OVF BIT(5)
81#define CDNS_I2C_IXR_SLV_RDY BIT(4)
82#define CDNS_I2C_IXR_TO BIT(3)
83#define CDNS_I2C_IXR_NACK BIT(2)
84#define CDNS_I2C_IXR_DATA BIT(1)
85#define CDNS_I2C_IXR_COMP BIT(0)
86
87#define CDNS_I2C_IXR_ALL_INTR_MASK (CDNS_I2C_IXR_ARB_LOST | \
88 CDNS_I2C_IXR_RX_UNF | \
89 CDNS_I2C_IXR_TX_OVF | \
90 CDNS_I2C_IXR_RX_OVF | \
91 CDNS_I2C_IXR_SLV_RDY | \
92 CDNS_I2C_IXR_TO | \
93 CDNS_I2C_IXR_NACK | \
94 CDNS_I2C_IXR_DATA | \
95 CDNS_I2C_IXR_COMP)
96
97#define CDNS_I2C_IXR_ERR_INTR_MASK (CDNS_I2C_IXR_ARB_LOST | \
98 CDNS_I2C_IXR_RX_UNF | \
99 CDNS_I2C_IXR_TX_OVF | \
100 CDNS_I2C_IXR_RX_OVF | \
101 CDNS_I2C_IXR_NACK)
102
103#define CDNS_I2C_ENABLED_INTR_MASK (CDNS_I2C_IXR_ARB_LOST | \
104 CDNS_I2C_IXR_RX_UNF | \
105 CDNS_I2C_IXR_TX_OVF | \
106 CDNS_I2C_IXR_RX_OVF | \
107 CDNS_I2C_IXR_NACK | \
108 CDNS_I2C_IXR_DATA | \
109 CDNS_I2C_IXR_COMP)
110
111#define CDNS_I2C_IXR_SLAVE_INTR_MASK (CDNS_I2C_IXR_RX_UNF | \
112 CDNS_I2C_IXR_TX_OVF | \
113 CDNS_I2C_IXR_RX_OVF | \
114 CDNS_I2C_IXR_TO | \
115 CDNS_I2C_IXR_NACK | \
116 CDNS_I2C_IXR_DATA | \
117 CDNS_I2C_IXR_COMP)
118
119#define CDNS_I2C_TIMEOUT msecs_to_jiffies(1000)
120
121#define CNDS_I2C_PM_TIMEOUT 1000
122
123#define CDNS_I2C_FIFO_DEPTH 16
124
125#define CDNS_I2C_DATA_INTR_DEPTH (CDNS_I2C_FIFO_DEPTH - 2)
126#define CDNS_I2C_MAX_TRANSFER_SIZE 255
127
128#define CDNS_I2C_TRANSFER_SIZE (CDNS_I2C_MAX_TRANSFER_SIZE - 3)
129
130#define DRIVER_NAME "cdns-i2c"
131
132#define CDNS_I2C_SPEED_MAX 400000
133#define CDNS_I2C_SPEED_DEFAULT 100000
134
135#define CDNS_I2C_DIVA_MAX 4
136#define CDNS_I2C_DIVB_MAX 64
137
138#define CDNS_I2C_TIMEOUT_MAX 0xFF
139
140#define CDNS_I2C_BROKEN_HOLD_BIT BIT(0)
141
142#define cdns_i2c_readreg(offset) readl_relaxed(id->membase + offset)
143#define cdns_i2c_writereg(val, offset) writel_relaxed(val, id->membase + offset)
144
145#if IS_ENABLED(CONFIG_I2C_SLAVE)
146
147
148
149
150
151
152enum cdns_i2c_mode {
153 CDNS_I2C_MODE_SLAVE,
154 CDNS_I2C_MODE_MASTER,
155};
156
157
158
159
160
161
162
163
164enum cdns_i2c_slave_state {
165 CDNS_I2C_SLAVE_STATE_IDLE,
166 CDNS_I2C_SLAVE_STATE_SEND,
167 CDNS_I2C_SLAVE_STATE_RECV,
168};
169#endif
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201struct cdns_i2c {
202 struct device *dev;
203 void __iomem *membase;
204 struct i2c_adapter adap;
205 struct i2c_msg *p_msg;
206 int err_status;
207 struct completion xfer_done;
208 unsigned char *p_send_buf;
209 unsigned char *p_recv_buf;
210 unsigned int send_count;
211 unsigned int recv_count;
212 unsigned int curr_recv_count;
213 int irq;
214 unsigned long input_clk;
215 unsigned int i2c_clk;
216 unsigned int bus_hold_flag;
217 struct clk *clk;
218 struct notifier_block clk_rate_change_nb;
219 u32 quirks;
220 u32 ctrl_reg;
221 struct i2c_bus_recovery_info rinfo;
222 struct pinctrl *pinctrl;
223 struct pinctrl_state *pinctrl_pins_default;
224 struct pinctrl_state *pinctrl_pins_gpio;
225#if IS_ENABLED(CONFIG_I2C_SLAVE)
226 struct i2c_client *slave;
227 enum cdns_i2c_mode dev_mode;
228 enum cdns_i2c_slave_state slave_state;
229#endif
230};
231
232struct cdns_platform_data {
233 u32 quirks;
234};
235
236#define to_cdns_i2c(_nb) container_of(_nb, struct cdns_i2c, \
237 clk_rate_change_nb)
238
239
240
241
242
243
244
245static void cdns_i2c_clear_bus_hold(struct cdns_i2c *id)
246{
247 u32 reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
248 if (reg & CDNS_I2C_CR_HOLD)
249 cdns_i2c_writereg(reg & ~CDNS_I2C_CR_HOLD, CDNS_I2C_CR_OFFSET);
250}
251
252static inline bool cdns_is_holdquirk(struct cdns_i2c *id, bool hold_wrkaround)
253{
254 return (hold_wrkaround &&
255 (id->curr_recv_count == CDNS_I2C_FIFO_DEPTH + 1));
256}
257
258#if IS_ENABLED(CONFIG_I2C_SLAVE)
259static void cdns_i2c_set_mode(enum cdns_i2c_mode mode, struct cdns_i2c *id)
260{
261 u32 reg;
262
263
264 cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK, CDNS_I2C_IDR_OFFSET);
265
266
267 cdns_i2c_writereg(CDNS_I2C_CR_CLR_FIFO, CDNS_I2C_CR_OFFSET);
268
269
270 id->dev_mode = mode;
271 id->slave_state = CDNS_I2C_SLAVE_STATE_IDLE;
272
273 switch (mode) {
274 case CDNS_I2C_MODE_MASTER:
275
276 cdns_i2c_writereg(id->ctrl_reg, CDNS_I2C_CR_OFFSET);
277 break;
278 case CDNS_I2C_MODE_SLAVE:
279
280 reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
281 reg &= ~CDNS_I2C_CR_SLAVE_EN_MASK;
282 cdns_i2c_writereg(reg, CDNS_I2C_CR_OFFSET);
283
284
285 cdns_i2c_writereg(id->slave->addr & CDNS_I2C_ADDR_MASK,
286 CDNS_I2C_ADDR_OFFSET);
287
288
289 cdns_i2c_writereg(CDNS_I2C_IXR_SLAVE_INTR_MASK,
290 CDNS_I2C_IER_OFFSET);
291 break;
292 }
293}
294
295static void cdns_i2c_slave_rcv_data(struct cdns_i2c *id)
296{
297 u8 bytes;
298 unsigned char data;
299
300
301 if (id->slave_state == CDNS_I2C_SLAVE_STATE_IDLE) {
302 id->slave_state = CDNS_I2C_SLAVE_STATE_RECV;
303 i2c_slave_event(id->slave, I2C_SLAVE_WRITE_REQUESTED, NULL);
304 }
305
306
307 bytes = cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET);
308
309
310 while (bytes--) {
311 data = cdns_i2c_readreg(CDNS_I2C_DATA_OFFSET);
312 i2c_slave_event(id->slave, I2C_SLAVE_WRITE_RECEIVED, &data);
313 }
314}
315
316static void cdns_i2c_slave_send_data(struct cdns_i2c *id)
317{
318 u8 data;
319
320
321 if (id->slave_state == CDNS_I2C_SLAVE_STATE_IDLE) {
322 id->slave_state = CDNS_I2C_SLAVE_STATE_SEND;
323 i2c_slave_event(id->slave, I2C_SLAVE_READ_REQUESTED, &data);
324 } else {
325 i2c_slave_event(id->slave, I2C_SLAVE_READ_PROCESSED, &data);
326 }
327
328
329 cdns_i2c_writereg(data, CDNS_I2C_DATA_OFFSET);
330}
331
332
333
334
335
336
337
338
339
340
341static irqreturn_t cdns_i2c_slave_isr(void *ptr)
342{
343 struct cdns_i2c *id = ptr;
344 unsigned int isr_status, i2c_status;
345
346
347 isr_status = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
348 cdns_i2c_writereg(isr_status, CDNS_I2C_ISR_OFFSET);
349
350
351 isr_status &= ~cdns_i2c_readreg(CDNS_I2C_IMR_OFFSET);
352
353
354 i2c_status = cdns_i2c_readreg(CDNS_I2C_SR_OFFSET);
355
356
357 if (i2c_status & CDNS_I2C_SR_RXRW) {
358
359 if (isr_status & CDNS_I2C_IXR_DATA)
360 cdns_i2c_slave_send_data(id);
361
362 if (isr_status & CDNS_I2C_IXR_COMP) {
363 id->slave_state = CDNS_I2C_SLAVE_STATE_IDLE;
364 i2c_slave_event(id->slave, I2C_SLAVE_STOP, NULL);
365 }
366 } else {
367
368 if (isr_status & CDNS_I2C_IXR_DATA)
369 cdns_i2c_slave_rcv_data(id);
370
371 if (isr_status & CDNS_I2C_IXR_COMP) {
372 cdns_i2c_slave_rcv_data(id);
373 id->slave_state = CDNS_I2C_SLAVE_STATE_IDLE;
374 i2c_slave_event(id->slave, I2C_SLAVE_STOP, NULL);
375 }
376 }
377
378
379 if (isr_status & (CDNS_I2C_IXR_NACK | CDNS_I2C_IXR_RX_OVF |
380 CDNS_I2C_IXR_RX_UNF | CDNS_I2C_IXR_TX_OVF)) {
381 id->slave_state = CDNS_I2C_SLAVE_STATE_IDLE;
382 i2c_slave_event(id->slave, I2C_SLAVE_STOP, NULL);
383 cdns_i2c_writereg(CDNS_I2C_CR_CLR_FIFO, CDNS_I2C_CR_OFFSET);
384 }
385
386 return IRQ_HANDLED;
387}
388#endif
389
390
391
392
393
394
395
396
397
398
399static irqreturn_t cdns_i2c_master_isr(void *ptr)
400{
401 unsigned int isr_status, avail_bytes, updatetx;
402 unsigned int bytes_to_send;
403 bool hold_quirk;
404 struct cdns_i2c *id = ptr;
405
406 int done_flag = 0;
407 irqreturn_t status = IRQ_NONE;
408
409 isr_status = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
410 cdns_i2c_writereg(isr_status, CDNS_I2C_ISR_OFFSET);
411
412
413 if (isr_status & (CDNS_I2C_IXR_NACK | CDNS_I2C_IXR_ARB_LOST)) {
414 done_flag = 1;
415 status = IRQ_HANDLED;
416 }
417
418
419
420
421
422 updatetx = 0;
423 if (id->recv_count > id->curr_recv_count)
424 updatetx = 1;
425
426 hold_quirk = (id->quirks & CDNS_I2C_BROKEN_HOLD_BIT) && updatetx;
427
428
429 if (id->p_recv_buf &&
430 ((isr_status & CDNS_I2C_IXR_COMP) ||
431 (isr_status & CDNS_I2C_IXR_DATA))) {
432
433 while (cdns_i2c_readreg(CDNS_I2C_SR_OFFSET) &
434 CDNS_I2C_SR_RXDV) {
435
436
437
438
439
440 if ((id->recv_count < CDNS_I2C_FIFO_DEPTH) &&
441 !id->bus_hold_flag)
442 cdns_i2c_clear_bus_hold(id);
443
444 *(id->p_recv_buf)++ =
445 cdns_i2c_readreg(CDNS_I2C_DATA_OFFSET);
446 id->recv_count--;
447 id->curr_recv_count--;
448
449 if (cdns_is_holdquirk(id, hold_quirk))
450 break;
451 }
452
453
454
455
456
457
458
459
460 if (cdns_is_holdquirk(id, hold_quirk)) {
461
462 while (cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET) !=
463 (id->curr_recv_count - CDNS_I2C_FIFO_DEPTH))
464 ;
465
466
467
468
469
470 if (((int)(id->recv_count) - CDNS_I2C_FIFO_DEPTH) >
471 CDNS_I2C_TRANSFER_SIZE) {
472 cdns_i2c_writereg(CDNS_I2C_TRANSFER_SIZE,
473 CDNS_I2C_XFER_SIZE_OFFSET);
474 id->curr_recv_count = CDNS_I2C_TRANSFER_SIZE +
475 CDNS_I2C_FIFO_DEPTH;
476 } else {
477 cdns_i2c_writereg(id->recv_count -
478 CDNS_I2C_FIFO_DEPTH,
479 CDNS_I2C_XFER_SIZE_OFFSET);
480 id->curr_recv_count = id->recv_count;
481 }
482 } else if (id->recv_count && !hold_quirk &&
483 !id->curr_recv_count) {
484
485
486 cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK,
487 CDNS_I2C_ADDR_OFFSET);
488
489 if (id->recv_count > CDNS_I2C_TRANSFER_SIZE) {
490 cdns_i2c_writereg(CDNS_I2C_TRANSFER_SIZE,
491 CDNS_I2C_XFER_SIZE_OFFSET);
492 id->curr_recv_count = CDNS_I2C_TRANSFER_SIZE;
493 } else {
494 cdns_i2c_writereg(id->recv_count,
495 CDNS_I2C_XFER_SIZE_OFFSET);
496 id->curr_recv_count = id->recv_count;
497 }
498 }
499
500
501 if ((isr_status & CDNS_I2C_IXR_COMP) && !id->recv_count) {
502 if (!id->bus_hold_flag)
503 cdns_i2c_clear_bus_hold(id);
504 done_flag = 1;
505 }
506
507 status = IRQ_HANDLED;
508 }
509
510
511 if ((isr_status & CDNS_I2C_IXR_COMP) && !id->p_recv_buf) {
512
513
514
515
516 if (id->send_count) {
517 avail_bytes = CDNS_I2C_FIFO_DEPTH -
518 cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET);
519 if (id->send_count > avail_bytes)
520 bytes_to_send = avail_bytes;
521 else
522 bytes_to_send = id->send_count;
523
524 while (bytes_to_send--) {
525 cdns_i2c_writereg(
526 (*(id->p_send_buf)++),
527 CDNS_I2C_DATA_OFFSET);
528 id->send_count--;
529 }
530 } else {
531
532
533
534
535
536 done_flag = 1;
537 }
538 if (!id->send_count && !id->bus_hold_flag)
539 cdns_i2c_clear_bus_hold(id);
540
541 status = IRQ_HANDLED;
542 }
543
544
545 if (isr_status & CDNS_I2C_IXR_SLV_RDY) {
546 unsigned int ctrl_reg;
547
548 ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
549
550
551 ctrl_reg &= ~CDNS_I2C_CR_SLVMON;
552 cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
553
554
555 cdns_i2c_writereg(CDNS_I2C_IXR_SLV_RDY, CDNS_I2C_IDR_OFFSET);
556
557 done_flag = 1;
558 status = IRQ_HANDLED;
559 }
560
561
562 id->err_status = isr_status & CDNS_I2C_IXR_ERR_INTR_MASK;
563 if (id->err_status)
564 status = IRQ_HANDLED;
565
566 if (done_flag)
567 complete(&id->xfer_done);
568
569 return status;
570}
571
572
573
574
575
576
577
578
579
580
581
582static irqreturn_t cdns_i2c_isr(int irq, void *ptr)
583{
584#if IS_ENABLED(CONFIG_I2C_SLAVE)
585 struct cdns_i2c *id = ptr;
586
587 switch (id->dev_mode) {
588 case CDNS_I2C_MODE_SLAVE:
589 dev_dbg(&id->adap.dev, "slave interrupt\n");
590 cdns_i2c_slave_isr(ptr);
591 break;
592 case CDNS_I2C_MODE_MASTER:
593 dev_dbg(&id->adap.dev, "master interrupt\n");
594 cdns_i2c_master_isr(ptr);
595 break;
596 default:
597 dev_dbg(&id->adap.dev, "undefined interrupt\n");
598 break;
599 }
600#else
601 cdns_i2c_master_isr(ptr);
602#endif
603 return IRQ_HANDLED;
604}
605
606
607
608
609
610static void cdns_i2c_mrecv(struct cdns_i2c *id)
611{
612 unsigned int ctrl_reg;
613 unsigned int isr_status;
614
615 id->p_recv_buf = id->p_msg->buf;
616 id->recv_count = id->p_msg->len;
617
618
619 ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
620 ctrl_reg |= CDNS_I2C_CR_RW | CDNS_I2C_CR_CLR_FIFO;
621
622 if (id->p_msg->flags & I2C_M_RECV_LEN)
623 id->recv_count = I2C_SMBUS_BLOCK_MAX + 1;
624
625 id->curr_recv_count = id->recv_count;
626
627
628
629
630
631 if (id->recv_count > CDNS_I2C_FIFO_DEPTH)
632 ctrl_reg |= CDNS_I2C_CR_HOLD;
633
634 cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
635
636
637 isr_status = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
638 cdns_i2c_writereg(isr_status, CDNS_I2C_ISR_OFFSET);
639
640
641
642
643
644
645
646 if (id->recv_count > CDNS_I2C_TRANSFER_SIZE) {
647 cdns_i2c_writereg(CDNS_I2C_TRANSFER_SIZE,
648 CDNS_I2C_XFER_SIZE_OFFSET);
649 id->curr_recv_count = CDNS_I2C_TRANSFER_SIZE;
650 } else {
651 cdns_i2c_writereg(id->recv_count, CDNS_I2C_XFER_SIZE_OFFSET);
652 }
653
654
655 if (!id->bus_hold_flag &&
656 ((id->p_msg->flags & I2C_M_RECV_LEN) != I2C_M_RECV_LEN) &&
657 (id->recv_count <= CDNS_I2C_FIFO_DEPTH))
658 cdns_i2c_clear_bus_hold(id);
659
660 cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK,
661 CDNS_I2C_ADDR_OFFSET);
662 cdns_i2c_writereg(CDNS_I2C_ENABLED_INTR_MASK, CDNS_I2C_IER_OFFSET);
663}
664
665
666
667
668
669static void cdns_i2c_msend(struct cdns_i2c *id)
670{
671 unsigned int avail_bytes;
672 unsigned int bytes_to_send;
673 unsigned int ctrl_reg;
674 unsigned int isr_status;
675
676 id->p_recv_buf = NULL;
677 id->p_send_buf = id->p_msg->buf;
678 id->send_count = id->p_msg->len;
679
680
681 ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
682 ctrl_reg &= ~CDNS_I2C_CR_RW;
683 ctrl_reg |= CDNS_I2C_CR_CLR_FIFO;
684
685
686
687
688
689 if (id->send_count > CDNS_I2C_FIFO_DEPTH)
690 ctrl_reg |= CDNS_I2C_CR_HOLD;
691 cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
692
693
694 isr_status = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
695 cdns_i2c_writereg(isr_status, CDNS_I2C_ISR_OFFSET);
696
697
698
699
700
701
702 avail_bytes = CDNS_I2C_FIFO_DEPTH -
703 cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET);
704
705 if (id->send_count > avail_bytes)
706 bytes_to_send = avail_bytes;
707 else
708 bytes_to_send = id->send_count;
709
710 while (bytes_to_send--) {
711 cdns_i2c_writereg((*(id->p_send_buf)++), CDNS_I2C_DATA_OFFSET);
712 id->send_count--;
713 }
714
715
716
717
718
719 if (!id->bus_hold_flag && !id->send_count)
720 cdns_i2c_clear_bus_hold(id);
721
722 cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK,
723 CDNS_I2C_ADDR_OFFSET);
724
725 cdns_i2c_writereg(CDNS_I2C_ENABLED_INTR_MASK, CDNS_I2C_IER_OFFSET);
726}
727
728
729
730
731
732static void cdns_i2c_slvmon(struct cdns_i2c *id)
733{
734 unsigned int ctrl_reg;
735 unsigned int isr_status;
736
737 id->p_recv_buf = NULL;
738 id->p_send_buf = id->p_msg->buf;
739 id->send_count = id->p_msg->len;
740
741
742 isr_status = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
743 cdns_i2c_writereg(isr_status, CDNS_I2C_ISR_OFFSET);
744
745
746 ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
747 ctrl_reg |= CDNS_I2C_CR_MS | CDNS_I2C_CR_NEA | CDNS_I2C_CR_SLVMON
748 | CDNS_I2C_CR_CLR_FIFO;
749 ctrl_reg &= ~(CDNS_I2C_CR_RW);
750 cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
751
752
753 cdns_i2c_writereg(0xF, CDNS_I2C_SLV_PAUSE_OFFSET);
754
755
756 cdns_i2c_writereg(id->p_msg->addr, CDNS_I2C_ADDR_OFFSET);
757
758
759 cdns_i2c_writereg(CDNS_I2C_IXR_SLV_RDY, CDNS_I2C_IER_OFFSET);
760}
761
762
763
764
765
766
767
768
769static void cdns_i2c_master_reset(struct i2c_adapter *adap)
770{
771 struct cdns_i2c *id = adap->algo_data;
772 u32 regval;
773
774
775 cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK, CDNS_I2C_IDR_OFFSET);
776
777 regval = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
778 regval &= ~(CDNS_I2C_CR_HOLD | CDNS_I2C_CR_SLVMON);
779 regval |= CDNS_I2C_CR_CLR_FIFO;
780 cdns_i2c_writereg(regval, CDNS_I2C_CR_OFFSET);
781
782 cdns_i2c_writereg(0, CDNS_I2C_XFER_SIZE_OFFSET);
783
784 regval = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET);
785 cdns_i2c_writereg(regval, CDNS_I2C_ISR_OFFSET);
786
787 regval = cdns_i2c_readreg(CDNS_I2C_SR_OFFSET);
788 cdns_i2c_writereg(regval, CDNS_I2C_SR_OFFSET);
789}
790
791static int cdns_i2c_process_msg(struct cdns_i2c *id, struct i2c_msg *msg,
792 struct i2c_adapter *adap)
793{
794 unsigned long time_left;
795 u32 reg;
796
797 id->p_msg = msg;
798 id->err_status = 0;
799 reinit_completion(&id->xfer_done);
800
801
802 reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
803 if (msg->flags & I2C_M_TEN) {
804 if (reg & CDNS_I2C_CR_NEA)
805 cdns_i2c_writereg(reg & ~CDNS_I2C_CR_NEA,
806 CDNS_I2C_CR_OFFSET);
807 } else {
808 if (!(reg & CDNS_I2C_CR_NEA))
809 cdns_i2c_writereg(reg | CDNS_I2C_CR_NEA,
810 CDNS_I2C_CR_OFFSET);
811 }
812
813 if (msg->len == 0)
814 cdns_i2c_slvmon(id);
815
816 else if (msg->flags & I2C_M_RD)
817 cdns_i2c_mrecv(id);
818 else
819 cdns_i2c_msend(id);
820
821
822 time_left = wait_for_completion_timeout(&id->xfer_done, adap->timeout);
823 if (time_left == 0) {
824 i2c_recover_bus(adap);
825 cdns_i2c_master_reset(adap);
826 dev_err(id->adap.dev.parent,
827 "timeout waiting on completion\n");
828 return -ETIMEDOUT;
829 }
830
831 cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK,
832 CDNS_I2C_IDR_OFFSET);
833
834
835 if (id->err_status & CDNS_I2C_IXR_ARB_LOST)
836 return -EAGAIN;
837
838 return 0;
839}
840
841
842
843
844
845
846
847
848
849
850
851static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
852 int num)
853{
854 int ret, count;
855 u32 reg;
856 struct cdns_i2c *id = adap->algo_data;
857 bool hold_quirk;
858#if IS_ENABLED(CONFIG_I2C_SLAVE)
859 bool change_role = false;
860#endif
861
862 ret = pm_runtime_get_sync(id->dev);
863 if (ret < 0)
864 return ret;
865
866#if IS_ENABLED(CONFIG_I2C_SLAVE)
867
868 if (id->dev_mode == CDNS_I2C_MODE_SLAVE) {
869 if (id->slave_state != CDNS_I2C_SLAVE_STATE_IDLE)
870 return -EAGAIN;
871
872
873 cdns_i2c_set_mode(CDNS_I2C_MODE_MASTER, id);
874
875
876 change_role = true;
877 }
878#endif
879
880
881 if (msgs->len)
882 if (cdns_i2c_readreg(CDNS_I2C_SR_OFFSET) & CDNS_I2C_SR_BA) {
883 ret = -EAGAIN;
884 goto out;
885 }
886
887 hold_quirk = !!(id->quirks & CDNS_I2C_BROKEN_HOLD_BIT);
888
889
890
891
892 if (num > 1) {
893
894
895
896
897
898
899
900 for (count = 0; (count < num - 1 && hold_quirk); count++) {
901 if (msgs[count].flags & I2C_M_RD) {
902 dev_warn(adap->dev.parent,
903 "Can't do repeated start after a receive message\n");
904 ret = -EOPNOTSUPP;
905 goto out;
906 }
907 }
908 id->bus_hold_flag = 1;
909 reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
910 reg |= CDNS_I2C_CR_HOLD;
911 cdns_i2c_writereg(reg, CDNS_I2C_CR_OFFSET);
912 } else {
913 id->bus_hold_flag = 0;
914 }
915
916
917 for (count = 0; count < num; count++, msgs++) {
918 if (count == (num - 1))
919 id->bus_hold_flag = 0;
920
921 ret = cdns_i2c_process_msg(id, msgs, adap);
922 if (ret)
923 goto out;
924
925
926 if (id->err_status) {
927 cdns_i2c_master_reset(adap);
928
929 if (id->err_status & CDNS_I2C_IXR_NACK) {
930 ret = -ENXIO;
931 goto out;
932 }
933 ret = -EIO;
934 goto out;
935 }
936 }
937
938 ret = num;
939
940#if IS_ENABLED(CONFIG_I2C_SLAVE)
941
942 if (change_role)
943 cdns_i2c_set_mode(CDNS_I2C_MODE_SLAVE, id);
944#endif
945
946out:
947 pm_runtime_mark_last_busy(id->dev);
948 pm_runtime_put_autosuspend(id->dev);
949 return ret;
950}
951
952
953
954
955
956
957
958static u32 cdns_i2c_func(struct i2c_adapter *adap)
959{
960 u32 func = I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR |
961 (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK) |
962 I2C_FUNC_SMBUS_BLOCK_DATA;
963
964#if IS_ENABLED(CONFIG_I2C_SLAVE)
965 func |= I2C_FUNC_SLAVE;
966#endif
967
968 return func;
969}
970
971#if IS_ENABLED(CONFIG_I2C_SLAVE)
972static int cdns_reg_slave(struct i2c_client *slave)
973{
974 int ret;
975 struct cdns_i2c *id = container_of(slave->adapter, struct cdns_i2c,
976 adap);
977
978 if (id->slave)
979 return -EBUSY;
980
981 if (slave->flags & I2C_CLIENT_TEN)
982 return -EAFNOSUPPORT;
983
984 ret = pm_runtime_get_sync(id->dev);
985 if (ret < 0)
986 return ret;
987
988
989 id->slave = slave;
990
991
992 cdns_i2c_set_mode(CDNS_I2C_MODE_SLAVE, id);
993
994 return 0;
995}
996
997static int cdns_unreg_slave(struct i2c_client *slave)
998{
999 struct cdns_i2c *id = container_of(slave->adapter, struct cdns_i2c,
1000 adap);
1001
1002 pm_runtime_put(id->dev);
1003
1004
1005 id->slave = NULL;
1006
1007
1008 cdns_i2c_set_mode(CDNS_I2C_MODE_MASTER, id);
1009
1010 return 0;
1011}
1012#endif
1013
1014static const struct i2c_algorithm cdns_i2c_algo = {
1015 .master_xfer = cdns_i2c_master_xfer,
1016 .functionality = cdns_i2c_func,
1017#if IS_ENABLED(CONFIG_I2C_SLAVE)
1018 .reg_slave = cdns_reg_slave,
1019 .unreg_slave = cdns_unreg_slave,
1020#endif
1021};
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035static int cdns_i2c_calc_divs(unsigned long *f, unsigned long input_clk,
1036 unsigned int *a, unsigned int *b)
1037{
1038 unsigned long fscl = *f, best_fscl = *f, actual_fscl, temp;
1039 unsigned int div_a, div_b, calc_div_a = 0, calc_div_b = 0;
1040 unsigned int last_error, current_error;
1041
1042
1043 temp = input_clk / (22 * fscl);
1044
1045
1046
1047
1048
1049 if (!temp || (temp > (CDNS_I2C_DIVA_MAX * CDNS_I2C_DIVB_MAX)))
1050 return -EINVAL;
1051
1052 last_error = -1;
1053 for (div_a = 0; div_a < CDNS_I2C_DIVA_MAX; div_a++) {
1054 div_b = DIV_ROUND_UP(input_clk, 22 * fscl * (div_a + 1));
1055
1056 if ((div_b < 1) || (div_b > CDNS_I2C_DIVB_MAX))
1057 continue;
1058 div_b--;
1059
1060 actual_fscl = input_clk / (22 * (div_a + 1) * (div_b + 1));
1061
1062 if (actual_fscl > fscl)
1063 continue;
1064
1065 current_error = ((actual_fscl > fscl) ? (actual_fscl - fscl) :
1066 (fscl - actual_fscl));
1067
1068 if (last_error > current_error) {
1069 calc_div_a = div_a;
1070 calc_div_b = div_b;
1071 best_fscl = actual_fscl;
1072 last_error = current_error;
1073 }
1074 }
1075
1076 *a = calc_div_a;
1077 *b = calc_div_b;
1078 *f = best_fscl;
1079
1080 return 0;
1081}
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099static int cdns_i2c_setclk(unsigned long clk_in, struct cdns_i2c *id)
1100{
1101 unsigned int div_a, div_b;
1102 unsigned int ctrl_reg;
1103 int ret = 0;
1104 unsigned long fscl = id->i2c_clk;
1105
1106 ret = cdns_i2c_calc_divs(&fscl, clk_in, &div_a, &div_b);
1107 if (ret)
1108 return ret;
1109
1110 ctrl_reg = id->ctrl_reg;
1111 ctrl_reg &= ~(CDNS_I2C_CR_DIVA_MASK | CDNS_I2C_CR_DIVB_MASK);
1112 ctrl_reg |= ((div_a << CDNS_I2C_CR_DIVA_SHIFT) |
1113 (div_b << CDNS_I2C_CR_DIVB_SHIFT));
1114 id->ctrl_reg = ctrl_reg;
1115 return 0;
1116}
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long
1135 event, void *data)
1136{
1137 struct clk_notifier_data *ndata = data;
1138 struct cdns_i2c *id = to_cdns_i2c(nb);
1139
1140 if (pm_runtime_suspended(id->dev))
1141 return NOTIFY_OK;
1142
1143 switch (event) {
1144 case PRE_RATE_CHANGE:
1145 {
1146 unsigned long input_clk = ndata->new_rate;
1147 unsigned long fscl = id->i2c_clk;
1148 unsigned int div_a, div_b;
1149 int ret;
1150
1151 ret = cdns_i2c_calc_divs(&fscl, input_clk, &div_a, &div_b);
1152 if (ret) {
1153 dev_warn(id->adap.dev.parent,
1154 "clock rate change rejected\n");
1155 return NOTIFY_STOP;
1156 }
1157
1158
1159 if (ndata->new_rate > ndata->old_rate)
1160 cdns_i2c_setclk(ndata->new_rate, id);
1161
1162 return NOTIFY_OK;
1163 }
1164 case POST_RATE_CHANGE:
1165 id->input_clk = ndata->new_rate;
1166
1167 if (ndata->new_rate < ndata->old_rate)
1168 cdns_i2c_setclk(ndata->new_rate, id);
1169 return NOTIFY_OK;
1170 case ABORT_RATE_CHANGE:
1171
1172 if (ndata->new_rate > ndata->old_rate)
1173 cdns_i2c_setclk(ndata->old_rate, id);
1174 return NOTIFY_OK;
1175 default:
1176 return NOTIFY_DONE;
1177 }
1178}
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188static int __maybe_unused cdns_i2c_runtime_suspend(struct device *dev)
1189{
1190 struct platform_device *pdev = to_platform_device(dev);
1191 struct cdns_i2c *xi2c = platform_get_drvdata(pdev);
1192
1193 clk_disable(xi2c->clk);
1194
1195 return 0;
1196}
1197
1198
1199
1200
1201
1202
1203
1204
1205static void cdns_i2c_init(struct cdns_i2c *id)
1206{
1207 cdns_i2c_writereg(id->ctrl_reg, CDNS_I2C_CR_OFFSET);
1208
1209
1210
1211
1212
1213
1214
1215 cdns_i2c_writereg(CDNS_I2C_TIMEOUT_MAX, CDNS_I2C_TIME_OUT_OFFSET);
1216}
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226static int __maybe_unused cdns_i2c_runtime_resume(struct device *dev)
1227{
1228 struct platform_device *pdev = to_platform_device(dev);
1229 struct cdns_i2c *xi2c = platform_get_drvdata(pdev);
1230 int ret;
1231
1232 ret = clk_enable(xi2c->clk);
1233 if (ret) {
1234 dev_err(dev, "Cannot enable clock.\n");
1235 return ret;
1236 }
1237 cdns_i2c_init(xi2c);
1238
1239 return 0;
1240}
1241
1242
1243
1244
1245
1246
1247
1248
1249static void cdns_i2c_prepare_recovery(struct i2c_adapter *adapter)
1250{
1251 struct cdns_i2c *p_cdns_i2c;
1252
1253 p_cdns_i2c = container_of(adapter, struct cdns_i2c, adap);
1254
1255
1256 pinctrl_select_state(p_cdns_i2c->pinctrl,
1257 p_cdns_i2c->pinctrl_pins_gpio);
1258}
1259
1260
1261
1262
1263
1264
1265
1266
1267static void cdns_i2c_unprepare_recovery(struct i2c_adapter *adapter)
1268{
1269 struct cdns_i2c *p_cdns_i2c;
1270
1271 p_cdns_i2c = container_of(adapter, struct cdns_i2c, adap);
1272
1273
1274 pinctrl_select_state(p_cdns_i2c->pinctrl,
1275 p_cdns_i2c->pinctrl_pins_default);
1276}
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289static int cdns_i2c_init_recovery_info(struct cdns_i2c *pid,
1290 struct platform_device *pdev)
1291{
1292 struct i2c_bus_recovery_info *rinfo = &pid->rinfo;
1293
1294 pid->pinctrl_pins_default = pinctrl_lookup_state(pid->pinctrl,
1295 PINCTRL_STATE_DEFAULT);
1296 pid->pinctrl_pins_gpio = pinctrl_lookup_state(pid->pinctrl, "gpio");
1297
1298
1299 rinfo->sda_gpio = of_get_named_gpio(pdev->dev.of_node, "sda-gpios", 0);
1300 rinfo->scl_gpio = of_get_named_gpio(pdev->dev.of_node, "scl-gpios", 0);
1301
1302
1303 if (rinfo->sda_gpio == -EPROBE_DEFER ||
1304 rinfo->scl_gpio == -EPROBE_DEFER)
1305 return -EPROBE_DEFER;
1306
1307
1308 if (!gpio_is_valid(rinfo->sda_gpio) ||
1309 !gpio_is_valid(rinfo->scl_gpio) ||
1310 IS_ERR(pid->pinctrl_pins_default) ||
1311 IS_ERR(pid->pinctrl_pins_gpio)) {
1312 dev_dbg(&pdev->dev, "recovery information incomplete\n");
1313 return 0;
1314 }
1315
1316 dev_dbg(&pdev->dev, "using scl-gpio %d and sda-gpio %d for recovery\n",
1317 rinfo->sda_gpio, rinfo->scl_gpio);
1318
1319 rinfo->prepare_recovery = cdns_i2c_prepare_recovery;
1320 rinfo->unprepare_recovery = cdns_i2c_unprepare_recovery;
1321 rinfo->recover_bus = i2c_generic_gpio_recovery;
1322 pid->adap.bus_recovery_info = rinfo;
1323
1324 return 0;
1325}
1326
1327static const struct dev_pm_ops cdns_i2c_dev_pm_ops = {
1328 SET_RUNTIME_PM_OPS(cdns_i2c_runtime_suspend,
1329 cdns_i2c_runtime_resume, NULL)
1330};
1331
1332static const struct cdns_platform_data r1p10_i2c_def = {
1333 .quirks = CDNS_I2C_BROKEN_HOLD_BIT,
1334};
1335
1336static const struct of_device_id cdns_i2c_of_match[] = {
1337 { .compatible = "cdns,i2c-r1p10", .data = &r1p10_i2c_def },
1338 { .compatible = "cdns,i2c-r1p14",},
1339 { }
1340};
1341MODULE_DEVICE_TABLE(of, cdns_i2c_of_match);
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353static int cdns_i2c_probe(struct platform_device *pdev)
1354{
1355 struct resource *r_mem;
1356 struct cdns_i2c *id;
1357 int ret;
1358 const struct of_device_id *match;
1359
1360 id = devm_kzalloc(&pdev->dev, sizeof(*id), GFP_KERNEL);
1361 if (!id)
1362 return -ENOMEM;
1363
1364 id->dev = &pdev->dev;
1365 platform_set_drvdata(pdev, id);
1366
1367 match = of_match_node(cdns_i2c_of_match, pdev->dev.of_node);
1368 if (match && match->data) {
1369 const struct cdns_platform_data *data = match->data;
1370 id->quirks = data->quirks;
1371 }
1372
1373 id->pinctrl = devm_pinctrl_get(&pdev->dev);
1374 if (!IS_ERR(id->pinctrl)) {
1375 ret = cdns_i2c_init_recovery_info(id, pdev);
1376 if (ret)
1377 return ret;
1378 }
1379
1380 r_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1381 id->membase = devm_ioremap_resource(&pdev->dev, r_mem);
1382 if (IS_ERR(id->membase))
1383 return PTR_ERR(id->membase);
1384
1385 id->irq = platform_get_irq(pdev, 0);
1386
1387 id->adap.owner = THIS_MODULE;
1388 id->adap.dev.of_node = pdev->dev.of_node;
1389 id->adap.algo = &cdns_i2c_algo;
1390 id->adap.timeout = CDNS_I2C_TIMEOUT;
1391 id->adap.retries = 3;
1392 id->adap.algo_data = id;
1393 id->adap.dev.parent = &pdev->dev;
1394 init_completion(&id->xfer_done);
1395 snprintf(id->adap.name, sizeof(id->adap.name),
1396 "Cadence I2C at %08lx", (unsigned long)r_mem->start);
1397
1398 id->clk = devm_clk_get(&pdev->dev, NULL);
1399 if (IS_ERR(id->clk)) {
1400 dev_err(&pdev->dev, "input clock not found.\n");
1401 return PTR_ERR(id->clk);
1402 }
1403 ret = clk_prepare_enable(id->clk);
1404 if (ret)
1405 dev_err(&pdev->dev, "Unable to enable clock.\n");
1406
1407 pm_runtime_set_autosuspend_delay(id->dev, CNDS_I2C_PM_TIMEOUT);
1408 pm_runtime_use_autosuspend(id->dev);
1409 pm_runtime_set_active(id->dev);
1410 pm_runtime_enable(id->dev);
1411
1412 id->clk_rate_change_nb.notifier_call = cdns_i2c_clk_notifier_cb;
1413 if (clk_notifier_register(id->clk, &id->clk_rate_change_nb))
1414 dev_warn(&pdev->dev, "Unable to register clock notifier.\n");
1415 id->input_clk = clk_get_rate(id->clk);
1416
1417 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
1418 &id->i2c_clk);
1419 if (ret || (id->i2c_clk > CDNS_I2C_SPEED_MAX))
1420 id->i2c_clk = CDNS_I2C_SPEED_DEFAULT;
1421
1422#if IS_ENABLED(CONFIG_I2C_SLAVE)
1423
1424 id->dev_mode = CDNS_I2C_MODE_MASTER;
1425 id->slave_state = CDNS_I2C_SLAVE_STATE_IDLE;
1426#endif
1427 id->ctrl_reg = CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS;
1428
1429 ret = cdns_i2c_setclk(id->input_clk, id);
1430 if (ret) {
1431 dev_err(&pdev->dev, "invalid SCL clock: %u Hz\n", id->i2c_clk);
1432 ret = -EINVAL;
1433 goto err_clk_dis;
1434 }
1435
1436 ret = devm_request_irq(&pdev->dev, id->irq, cdns_i2c_isr, 0,
1437 DRIVER_NAME, id);
1438 if (ret) {
1439 dev_err(&pdev->dev, "cannot get irq %d\n", id->irq);
1440 goto err_clk_dis;
1441 }
1442
1443 cdns_i2c_init(id);
1444
1445 dev_info(&pdev->dev, "%u kHz mmio %08lx irq %d\n",
1446 id->i2c_clk / 1000, (unsigned long)r_mem->start, id->irq);
1447
1448 ret = i2c_add_adapter(&id->adap);
1449 if (ret < 0)
1450 goto err_clk_dis;
1451
1452 return 0;
1453
1454err_clk_dis:
1455 clk_disable_unprepare(id->clk);
1456 pm_runtime_disable(&pdev->dev);
1457 pm_runtime_set_suspended(&pdev->dev);
1458 return ret;
1459}
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469static int cdns_i2c_remove(struct platform_device *pdev)
1470{
1471 struct cdns_i2c *id = platform_get_drvdata(pdev);
1472
1473 pm_runtime_disable(&pdev->dev);
1474 pm_runtime_set_suspended(&pdev->dev);
1475 pm_runtime_dont_use_autosuspend(&pdev->dev);
1476
1477 i2c_del_adapter(&id->adap);
1478 clk_notifier_unregister(id->clk, &id->clk_rate_change_nb);
1479 clk_disable_unprepare(id->clk);
1480 pm_runtime_disable(&pdev->dev);
1481
1482 return 0;
1483}
1484
1485static struct platform_driver cdns_i2c_drv = {
1486 .driver = {
1487 .name = DRIVER_NAME,
1488 .of_match_table = cdns_i2c_of_match,
1489 .pm = &cdns_i2c_dev_pm_ops,
1490 },
1491 .probe = cdns_i2c_probe,
1492 .remove = cdns_i2c_remove,
1493};
1494
1495module_platform_driver(cdns_i2c_drv);
1496
1497MODULE_AUTHOR("Xilinx Inc.");
1498MODULE_DESCRIPTION("Cadence I2C bus driver");
1499MODULE_LICENSE("GPL");
1500