2 * Blackfin On-Chip Two Wire Interface Driver
4 * Copyright 2005-2007 Analog Devices Inc.
6 * Enter bugs at http://blackfin.uclinux.org/
8 * Licensed under the GPL-2 or later.
11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/i2c.h>
15 #include <linux/slab.h>
18 #include <linux/timer.h>
19 #include <linux/spinlock.h>
20 #include <linux/completion.h>
21 #include <linux/interrupt.h>
22 #include <linux/platform_device.h>
23 #include <linux/delay.h>
25 #include <asm/blackfin.h>
26 #include <asm/portmux.h>
28 #include <asm/bfin_twi.h>
31 #define TWI_I2C_MODE_STANDARD 1
32 #define TWI_I2C_MODE_STANDARDSUB 2
33 #define TWI_I2C_MODE_COMBINED 3
34 #define TWI_I2C_MODE_REPEAT 4
36 static void bfin_twi_handle_interrupt(struct bfin_twi_iface
*iface
,
37 unsigned short twi_int_status
)
39 unsigned short mast_stat
= read_MASTER_STAT(iface
);
41 if (twi_int_status
& XMTSERV
) {
42 if (iface
->writeNum
<= 0) {
43 /* start receive immediately after complete sending in
46 if (iface
->cur_mode
== TWI_I2C_MODE_COMBINED
)
47 write_MASTER_CTL(iface
,
48 read_MASTER_CTL(iface
) | MDIR
);
49 else if (iface
->manual_stop
)
50 write_MASTER_CTL(iface
,
51 read_MASTER_CTL(iface
) | STOP
);
52 else if (iface
->cur_mode
== TWI_I2C_MODE_REPEAT
&&
53 iface
->cur_msg
+ 1 < iface
->msg_num
) {
54 if (iface
->pmsg
[iface
->cur_msg
+ 1].flags
&
56 write_MASTER_CTL(iface
,
57 read_MASTER_CTL(iface
) |
60 write_MASTER_CTL(iface
,
61 read_MASTER_CTL(iface
) &
65 /* Transmit next data */
66 while (iface
->writeNum
> 0 &&
67 (read_FIFO_STAT(iface
) & XMTSTAT
) != XMT_FULL
) {
69 write_XMT_DATA8(iface
, *(iface
->transPtr
++));
73 if (twi_int_status
& RCVSERV
) {
74 while (iface
->readNum
> 0 &&
75 (read_FIFO_STAT(iface
) & RCVSTAT
)) {
76 /* Receive next data */
77 *(iface
->transPtr
) = read_RCV_DATA8(iface
);
78 if (iface
->cur_mode
== TWI_I2C_MODE_COMBINED
) {
79 /* Change combine mode into sub mode after
82 iface
->cur_mode
= TWI_I2C_MODE_STANDARDSUB
;
83 /* Get read number from first byte in block
86 if (iface
->readNum
== 1 && iface
->manual_stop
)
87 iface
->readNum
= *iface
->transPtr
+ 1;
93 if (iface
->readNum
== 0) {
94 if (iface
->manual_stop
) {
95 /* Temporary workaround to avoid possible bus stall -
96 * Flush FIFO before issuing the STOP condition
98 read_RCV_DATA16(iface
);
99 write_MASTER_CTL(iface
,
100 read_MASTER_CTL(iface
) | STOP
);
101 } else if (iface
->cur_mode
== TWI_I2C_MODE_REPEAT
&&
102 iface
->cur_msg
+ 1 < iface
->msg_num
) {
103 if (iface
->pmsg
[iface
->cur_msg
+ 1].flags
& I2C_M_RD
)
104 write_MASTER_CTL(iface
,
105 read_MASTER_CTL(iface
) | MDIR
);
107 write_MASTER_CTL(iface
,
108 read_MASTER_CTL(iface
) & ~MDIR
);
112 if (twi_int_status
& MERR
) {
113 write_INT_MASK(iface
, 0);
114 write_MASTER_STAT(iface
, 0x3e);
115 write_MASTER_CTL(iface
, 0);
116 iface
->result
= -EIO
;
118 if (mast_stat
& LOSTARB
)
119 dev_dbg(&iface
->adap
.dev
, "Lost Arbitration\n");
120 if (mast_stat
& ANAK
)
121 dev_dbg(&iface
->adap
.dev
, "Address Not Acknowledged\n");
122 if (mast_stat
& DNAK
)
123 dev_dbg(&iface
->adap
.dev
, "Data Not Acknowledged\n");
124 if (mast_stat
& BUFRDERR
)
125 dev_dbg(&iface
->adap
.dev
, "Buffer Read Error\n");
126 if (mast_stat
& BUFWRERR
)
127 dev_dbg(&iface
->adap
.dev
, "Buffer Write Error\n");
129 /* Faulty slave devices, may drive SDA low after a transfer
130 * finishes. To release the bus this code generates up to 9
131 * extra clocks until SDA is released.
134 if (read_MASTER_STAT(iface
) & SDASEN
) {
137 write_MASTER_CTL(iface
, SCLOVR
);
139 write_MASTER_CTL(iface
, 0);
141 } while ((read_MASTER_STAT(iface
) & SDASEN
) && cnt
--);
143 write_MASTER_CTL(iface
, SDAOVR
| SCLOVR
);
145 write_MASTER_CTL(iface
, SDAOVR
);
147 write_MASTER_CTL(iface
, 0);
150 /* If it is a quick transfer, only address without data,
151 * not an err, return 1.
153 if (iface
->cur_mode
== TWI_I2C_MODE_STANDARD
&&
154 iface
->transPtr
== NULL
&&
155 (twi_int_status
& MCOMP
) && (mast_stat
& DNAK
))
158 complete(&iface
->complete
);
161 if (twi_int_status
& MCOMP
) {
162 if (twi_int_status
& (XMTSERV
| RCVSERV
) &&
163 (read_MASTER_CTL(iface
) & MEN
) == 0 &&
164 (iface
->cur_mode
== TWI_I2C_MODE_REPEAT
||
165 iface
->cur_mode
== TWI_I2C_MODE_COMBINED
)) {
167 write_INT_MASK(iface
, 0);
168 write_MASTER_CTL(iface
, 0);
169 } else if (iface
->cur_mode
== TWI_I2C_MODE_COMBINED
) {
170 if (iface
->readNum
== 0) {
171 /* set the read number to 1 and ask for manual
172 * stop in block combine mode
175 iface
->manual_stop
= 1;
176 write_MASTER_CTL(iface
,
177 read_MASTER_CTL(iface
) | (0xff << 6));
179 /* set the readd number in other
182 write_MASTER_CTL(iface
,
183 (read_MASTER_CTL(iface
) &
185 (iface
->readNum
<< 6));
187 /* remove restart bit and enable master receive */
188 write_MASTER_CTL(iface
,
189 read_MASTER_CTL(iface
) & ~RSTART
);
190 } else if (iface
->cur_mode
== TWI_I2C_MODE_REPEAT
&&
191 iface
->cur_msg
+ 1 < iface
->msg_num
) {
193 iface
->transPtr
= iface
->pmsg
[iface
->cur_msg
].buf
;
194 iface
->writeNum
= iface
->readNum
=
195 iface
->pmsg
[iface
->cur_msg
].len
;
196 /* Set Transmit device address */
197 write_MASTER_ADDR(iface
,
198 iface
->pmsg
[iface
->cur_msg
].addr
);
199 if (iface
->pmsg
[iface
->cur_msg
].flags
& I2C_M_RD
)
200 iface
->read_write
= I2C_SMBUS_READ
;
202 iface
->read_write
= I2C_SMBUS_WRITE
;
203 /* Transmit first data */
204 if (iface
->writeNum
> 0) {
205 write_XMT_DATA8(iface
,
206 *(iface
->transPtr
++));
211 if (iface
->pmsg
[iface
->cur_msg
].len
<= 255) {
212 write_MASTER_CTL(iface
,
213 (read_MASTER_CTL(iface
) &
215 (iface
->pmsg
[iface
->cur_msg
].len
<< 6));
216 iface
->manual_stop
= 0;
218 write_MASTER_CTL(iface
,
219 (read_MASTER_CTL(iface
) |
221 iface
->manual_stop
= 1;
223 /* remove restart bit before last message */
224 if (iface
->cur_msg
+ 1 == iface
->msg_num
)
225 write_MASTER_CTL(iface
,
226 read_MASTER_CTL(iface
) & ~RSTART
);
229 write_INT_MASK(iface
, 0);
230 write_MASTER_CTL(iface
, 0);
232 complete(&iface
->complete
);
236 /* Interrupt handler */
237 static irqreturn_t
bfin_twi_interrupt_entry(int irq
, void *dev_id
)
239 struct bfin_twi_iface
*iface
= dev_id
;
241 unsigned short twi_int_status
;
243 spin_lock_irqsave(&iface
->lock
, flags
);
245 twi_int_status
= read_INT_STAT(iface
);
248 /* Clear interrupt status */
249 write_INT_STAT(iface
, twi_int_status
);
250 bfin_twi_handle_interrupt(iface
, twi_int_status
);
253 spin_unlock_irqrestore(&iface
->lock
, flags
);
258 * One i2c master transfer
260 static int bfin_twi_do_master_xfer(struct i2c_adapter
*adap
,
261 struct i2c_msg
*msgs
, int num
)
263 struct bfin_twi_iface
*iface
= adap
->algo_data
;
264 struct i2c_msg
*pmsg
;
267 if (!(read_CONTROL(iface
) & TWI_ENA
))
270 if (read_MASTER_STAT(iface
) & BUSBUSY
)
274 iface
->msg_num
= num
;
278 if (pmsg
->flags
& I2C_M_TEN
) {
279 dev_err(&adap
->dev
, "10 bits addr not supported!\n");
283 if (iface
->msg_num
> 1)
284 iface
->cur_mode
= TWI_I2C_MODE_REPEAT
;
285 iface
->manual_stop
= 0;
286 iface
->transPtr
= pmsg
->buf
;
287 iface
->writeNum
= iface
->readNum
= pmsg
->len
;
289 init_completion(&(iface
->complete
));
290 /* Set Transmit device address */
291 write_MASTER_ADDR(iface
, pmsg
->addr
);
293 /* FIFO Initiation. Data in FIFO should be
294 * discarded before start a new operation.
296 write_FIFO_CTL(iface
, 0x3);
298 write_FIFO_CTL(iface
, 0);
301 if (pmsg
->flags
& I2C_M_RD
)
302 iface
->read_write
= I2C_SMBUS_READ
;
304 iface
->read_write
= I2C_SMBUS_WRITE
;
305 /* Transmit first data */
306 if (iface
->writeNum
> 0) {
307 write_XMT_DATA8(iface
, *(iface
->transPtr
++));
314 write_INT_STAT(iface
, MERR
| MCOMP
| XMTSERV
| RCVSERV
);
316 /* Interrupt mask . Enable XMT, RCV interrupt */
317 write_INT_MASK(iface
, MCOMP
| MERR
| RCVSERV
| XMTSERV
);
320 if (pmsg
->len
<= 255)
321 write_MASTER_CTL(iface
, pmsg
->len
<< 6);
323 write_MASTER_CTL(iface
, 0xff << 6);
324 iface
->manual_stop
= 1;
328 write_MASTER_CTL(iface
, read_MASTER_CTL(iface
) | MEN
|
329 (iface
->msg_num
> 1 ? RSTART
: 0) |
330 ((iface
->read_write
== I2C_SMBUS_READ
) ? MDIR
: 0) |
331 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ
> 100) ? FAST
: 0));
334 while (!iface
->result
) {
335 if (!wait_for_completion_timeout(&iface
->complete
,
338 dev_err(&adap
->dev
, "master transfer timeout\n");
342 if (iface
->result
== 1)
343 rc
= iface
->cur_msg
+ 1;
351 * Generic i2c master transfer entrypoint
353 static int bfin_twi_master_xfer(struct i2c_adapter
*adap
,
354 struct i2c_msg
*msgs
, int num
)
356 return bfin_twi_do_master_xfer(adap
, msgs
, num
);
360 * One I2C SMBus transfer
362 int bfin_twi_do_smbus_xfer(struct i2c_adapter
*adap
, u16 addr
,
363 unsigned short flags
, char read_write
,
364 u8 command
, int size
, union i2c_smbus_data
*data
)
366 struct bfin_twi_iface
*iface
= adap
->algo_data
;
369 if (!(read_CONTROL(iface
) & TWI_ENA
))
372 if (read_MASTER_STAT(iface
) & BUSBUSY
)
378 /* Prepare datas & select mode */
380 case I2C_SMBUS_QUICK
:
381 iface
->transPtr
= NULL
;
382 iface
->cur_mode
= TWI_I2C_MODE_STANDARD
;
386 iface
->transPtr
= NULL
;
388 if (read_write
== I2C_SMBUS_READ
)
392 iface
->transPtr
= &data
->byte
;
394 iface
->cur_mode
= TWI_I2C_MODE_STANDARD
;
396 case I2C_SMBUS_BYTE_DATA
:
397 if (read_write
== I2C_SMBUS_READ
) {
399 iface
->cur_mode
= TWI_I2C_MODE_COMBINED
;
402 iface
->cur_mode
= TWI_I2C_MODE_STANDARDSUB
;
404 iface
->transPtr
= &data
->byte
;
406 case I2C_SMBUS_WORD_DATA
:
407 if (read_write
== I2C_SMBUS_READ
) {
409 iface
->cur_mode
= TWI_I2C_MODE_COMBINED
;
412 iface
->cur_mode
= TWI_I2C_MODE_STANDARDSUB
;
414 iface
->transPtr
= (u8
*)&data
->word
;
416 case I2C_SMBUS_PROC_CALL
:
419 iface
->cur_mode
= TWI_I2C_MODE_COMBINED
;
420 iface
->transPtr
= (u8
*)&data
->word
;
422 case I2C_SMBUS_BLOCK_DATA
:
423 if (read_write
== I2C_SMBUS_READ
) {
425 iface
->cur_mode
= TWI_I2C_MODE_COMBINED
;
427 iface
->writeNum
= data
->block
[0] + 1;
428 iface
->cur_mode
= TWI_I2C_MODE_STANDARDSUB
;
430 iface
->transPtr
= data
->block
;
432 case I2C_SMBUS_I2C_BLOCK_DATA
:
433 if (read_write
== I2C_SMBUS_READ
) {
434 iface
->readNum
= data
->block
[0];
435 iface
->cur_mode
= TWI_I2C_MODE_COMBINED
;
437 iface
->writeNum
= data
->block
[0];
438 iface
->cur_mode
= TWI_I2C_MODE_STANDARDSUB
;
440 iface
->transPtr
= (u8
*)&data
->block
[1];
447 iface
->manual_stop
= 0;
448 iface
->read_write
= read_write
;
449 iface
->command
= command
;
450 init_completion(&(iface
->complete
));
452 /* FIFO Initiation. Data in FIFO should be discarded before
453 * start a new operation.
455 write_FIFO_CTL(iface
, 0x3);
457 write_FIFO_CTL(iface
, 0);
460 write_INT_STAT(iface
, MERR
| MCOMP
| XMTSERV
| RCVSERV
);
462 /* Set Transmit device address */
463 write_MASTER_ADDR(iface
, addr
);
466 switch (iface
->cur_mode
) {
467 case TWI_I2C_MODE_STANDARDSUB
:
468 write_XMT_DATA8(iface
, iface
->command
);
469 write_INT_MASK(iface
, MCOMP
| MERR
|
470 ((iface
->read_write
== I2C_SMBUS_READ
) ?
474 if (iface
->writeNum
+ 1 <= 255)
475 write_MASTER_CTL(iface
, (iface
->writeNum
+ 1) << 6);
477 write_MASTER_CTL(iface
, 0xff << 6);
478 iface
->manual_stop
= 1;
481 write_MASTER_CTL(iface
, read_MASTER_CTL(iface
) | MEN
|
482 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ
>100) ? FAST
: 0));
484 case TWI_I2C_MODE_COMBINED
:
485 write_XMT_DATA8(iface
, iface
->command
);
486 write_INT_MASK(iface
, MCOMP
| MERR
| RCVSERV
| XMTSERV
);
489 if (iface
->writeNum
> 0)
490 write_MASTER_CTL(iface
, (iface
->writeNum
+ 1) << 6);
492 write_MASTER_CTL(iface
, 0x1 << 6);
494 write_MASTER_CTL(iface
, read_MASTER_CTL(iface
) | MEN
| RSTART
|
495 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ
>100) ? FAST
: 0));
498 write_MASTER_CTL(iface
, 0);
499 if (size
!= I2C_SMBUS_QUICK
) {
500 /* Don't access xmit data register when this is a
503 if (iface
->read_write
!= I2C_SMBUS_READ
) {
504 if (iface
->writeNum
> 0) {
505 write_XMT_DATA8(iface
,
506 *(iface
->transPtr
++));
507 if (iface
->writeNum
<= 255)
508 write_MASTER_CTL(iface
,
509 iface
->writeNum
<< 6);
511 write_MASTER_CTL(iface
,
513 iface
->manual_stop
= 1;
517 write_XMT_DATA8(iface
, iface
->command
);
518 write_MASTER_CTL(iface
, 1 << 6);
521 if (iface
->readNum
> 0 && iface
->readNum
<= 255)
522 write_MASTER_CTL(iface
,
523 iface
->readNum
<< 6);
524 else if (iface
->readNum
> 255) {
525 write_MASTER_CTL(iface
, 0xff << 6);
526 iface
->manual_stop
= 1;
531 write_INT_MASK(iface
, MCOMP
| MERR
|
532 ((iface
->read_write
== I2C_SMBUS_READ
) ?
537 write_MASTER_CTL(iface
, read_MASTER_CTL(iface
) | MEN
|
538 ((iface
->read_write
== I2C_SMBUS_READ
) ? MDIR
: 0) |
539 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ
> 100) ? FAST
: 0));
544 while (!iface
->result
) {
545 if (!wait_for_completion_timeout(&iface
->complete
,
548 dev_err(&adap
->dev
, "smbus transfer timeout\n");
552 rc
= (iface
->result
>= 0) ? 0 : -1;
558 * Generic I2C SMBus transfer entrypoint
560 int bfin_twi_smbus_xfer(struct i2c_adapter
*adap
, u16 addr
,
561 unsigned short flags
, char read_write
,
562 u8 command
, int size
, union i2c_smbus_data
*data
)
564 return bfin_twi_do_smbus_xfer(adap
, addr
, flags
,
565 read_write
, command
, size
, data
);
569 * Return what the adapter supports
571 static u32
bfin_twi_functionality(struct i2c_adapter
*adap
)
573 return I2C_FUNC_SMBUS_QUICK
| I2C_FUNC_SMBUS_BYTE
|
574 I2C_FUNC_SMBUS_BYTE_DATA
| I2C_FUNC_SMBUS_WORD_DATA
|
575 I2C_FUNC_SMBUS_BLOCK_DATA
| I2C_FUNC_SMBUS_PROC_CALL
|
576 I2C_FUNC_I2C
| I2C_FUNC_SMBUS_I2C_BLOCK
;
579 static struct i2c_algorithm bfin_twi_algorithm
= {
580 .master_xfer
= bfin_twi_master_xfer
,
581 .smbus_xfer
= bfin_twi_smbus_xfer
,
582 .functionality
= bfin_twi_functionality
,
585 #ifdef CONFIG_PM_SLEEP
586 static int i2c_bfin_twi_suspend(struct device
*dev
)
588 struct bfin_twi_iface
*iface
= dev_get_drvdata(dev
);
590 iface
->saved_clkdiv
= read_CLKDIV(iface
);
591 iface
->saved_control
= read_CONTROL(iface
);
593 free_irq(iface
->irq
, iface
);
596 write_CONTROL(iface
, iface
->saved_control
& ~TWI_ENA
);
601 static int i2c_bfin_twi_resume(struct device
*dev
)
603 struct bfin_twi_iface
*iface
= dev_get_drvdata(dev
);
605 int rc
= request_irq(iface
->irq
, bfin_twi_interrupt_entry
,
606 0, to_platform_device(dev
)->name
, iface
);
608 dev_err(dev
, "Can't get IRQ %d !\n", iface
->irq
);
612 /* Resume TWI interface clock as specified */
613 write_CLKDIV(iface
, iface
->saved_clkdiv
);
616 write_CONTROL(iface
, iface
->saved_control
);
621 static SIMPLE_DEV_PM_OPS(i2c_bfin_twi_pm
,
622 i2c_bfin_twi_suspend
, i2c_bfin_twi_resume
);
623 #define I2C_BFIN_TWI_PM_OPS (&i2c_bfin_twi_pm)
625 #define I2C_BFIN_TWI_PM_OPS NULL
628 static int i2c_bfin_twi_probe(struct platform_device
*pdev
)
630 struct bfin_twi_iface
*iface
;
631 struct i2c_adapter
*p_adap
;
632 struct resource
*res
;
634 unsigned int clkhilow
;
636 iface
= kzalloc(sizeof(struct bfin_twi_iface
), GFP_KERNEL
);
638 dev_err(&pdev
->dev
, "Cannot allocate memory\n");
640 goto out_error_nomem
;
643 spin_lock_init(&(iface
->lock
));
645 /* Find and map our resources */
646 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
648 dev_err(&pdev
->dev
, "Cannot get IORESOURCE_MEM\n");
650 goto out_error_get_res
;
653 iface
->regs_base
= ioremap(res
->start
, resource_size(res
));
654 if (iface
->regs_base
== NULL
) {
655 dev_err(&pdev
->dev
, "Cannot map IO\n");
657 goto out_error_ioremap
;
660 iface
->irq
= platform_get_irq(pdev
, 0);
661 if (iface
->irq
< 0) {
662 dev_err(&pdev
->dev
, "No IRQ specified\n");
664 goto out_error_no_irq
;
667 p_adap
= &iface
->adap
;
668 p_adap
->nr
= pdev
->id
;
669 strlcpy(p_adap
->name
, pdev
->name
, sizeof(p_adap
->name
));
670 p_adap
->algo
= &bfin_twi_algorithm
;
671 p_adap
->algo_data
= iface
;
672 p_adap
->class = I2C_CLASS_HWMON
| I2C_CLASS_SPD
;
673 p_adap
->dev
.parent
= &pdev
->dev
;
674 p_adap
->timeout
= 5 * HZ
;
677 rc
= peripheral_request_list(
678 dev_get_platdata(&pdev
->dev
),
681 dev_err(&pdev
->dev
, "Can't setup pin mux!\n");
682 goto out_error_pin_mux
;
685 rc
= request_irq(iface
->irq
, bfin_twi_interrupt_entry
,
686 0, pdev
->name
, iface
);
688 dev_err(&pdev
->dev
, "Can't get IRQ %d !\n", iface
->irq
);
690 goto out_error_req_irq
;
693 /* Set TWI internal clock as 10MHz */
694 write_CONTROL(iface
, ((get_sclk() / 1000 / 1000 + 5) / 10) & 0x7F);
697 * We will not end up with a CLKDIV=0 because no one will specify
698 * 20kHz SCL or less in Kconfig now. (5 * 1000 / 20 = 250)
700 clkhilow
= ((10 * 1000 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ
) + 1) / 2;
702 /* Set Twi interface clock as specified */
703 write_CLKDIV(iface
, (clkhilow
<< 8) | clkhilow
);
706 write_CONTROL(iface
, read_CONTROL(iface
) | TWI_ENA
);
709 rc
= i2c_add_numbered_adapter(p_adap
);
711 dev_err(&pdev
->dev
, "Can't add i2c adapter!\n");
712 goto out_error_add_adapter
;
715 platform_set_drvdata(pdev
, iface
);
717 dev_info(&pdev
->dev
, "Blackfin BF5xx on-chip I2C TWI Contoller, "
718 "regs_base@%p\n", iface
->regs_base
);
722 out_error_add_adapter
:
723 free_irq(iface
->irq
, iface
);
726 peripheral_free_list(dev_get_platdata(&pdev
->dev
));
728 iounmap(iface
->regs_base
);
736 static int i2c_bfin_twi_remove(struct platform_device
*pdev
)
738 struct bfin_twi_iface
*iface
= platform_get_drvdata(pdev
);
740 i2c_del_adapter(&(iface
->adap
));
741 free_irq(iface
->irq
, iface
);
742 peripheral_free_list(dev_get_platdata(&pdev
->dev
));
743 iounmap(iface
->regs_base
);
749 static struct platform_driver i2c_bfin_twi_driver
= {
750 .probe
= i2c_bfin_twi_probe
,
751 .remove
= i2c_bfin_twi_remove
,
753 .name
= "i2c-bfin-twi",
754 .owner
= THIS_MODULE
,
755 .pm
= I2C_BFIN_TWI_PM_OPS
,
759 static int __init
i2c_bfin_twi_init(void)
761 return platform_driver_register(&i2c_bfin_twi_driver
);
764 static void __exit
i2c_bfin_twi_exit(void)
766 platform_driver_unregister(&i2c_bfin_twi_driver
);
769 subsys_initcall(i2c_bfin_twi_init
);
770 module_exit(i2c_bfin_twi_exit
);
772 MODULE_AUTHOR("Bryan Wu, Sonic Zhang");
773 MODULE_DESCRIPTION("Blackfin BF5xx on-chip I2C TWI Contoller Driver");
774 MODULE_LICENSE("GPL");
775 MODULE_ALIAS("platform:i2c-bfin-twi");