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>
24 #include <asm/blackfin.h>
25 #include <asm/portmux.h>
28 #define POLL_TIMEOUT (2 * HZ)
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 struct bfin_twi_iface
{
48 struct timer_list timeout_timer
;
49 struct i2c_adapter adap
;
50 struct completion complete
;
56 void __iomem
*regs_base
;
60 #define DEFINE_TWI_REG(reg, off) \
61 static inline u16 read_##reg(struct bfin_twi_iface *iface) \
62 { return bfin_read16(iface->regs_base + (off)); } \
63 static inline void write_##reg(struct bfin_twi_iface *iface, u16 v) \
64 { bfin_write16(iface->regs_base + (off), v); }
66 DEFINE_TWI_REG(CLKDIV
, 0x00)
67 DEFINE_TWI_REG(CONTROL
, 0x04)
68 DEFINE_TWI_REG(SLAVE_CTL
, 0x08)
69 DEFINE_TWI_REG(SLAVE_STAT
, 0x0C)
70 DEFINE_TWI_REG(SLAVE_ADDR
, 0x10)
71 DEFINE_TWI_REG(MASTER_CTL
, 0x14)
72 DEFINE_TWI_REG(MASTER_STAT
, 0x18)
73 DEFINE_TWI_REG(MASTER_ADDR
, 0x1C)
74 DEFINE_TWI_REG(INT_STAT
, 0x20)
75 DEFINE_TWI_REG(INT_MASK
, 0x24)
76 DEFINE_TWI_REG(FIFO_CTL
, 0x28)
77 DEFINE_TWI_REG(FIFO_STAT
, 0x2C)
78 DEFINE_TWI_REG(XMT_DATA8
, 0x80)
79 DEFINE_TWI_REG(XMT_DATA16
, 0x84)
80 DEFINE_TWI_REG(RCV_DATA8
, 0x88)
81 DEFINE_TWI_REG(RCV_DATA16
, 0x8C)
83 static const u16 pin_req
[2][3] = {
84 {P_TWI0_SCL
, P_TWI0_SDA
, 0},
85 {P_TWI1_SCL
, P_TWI1_SDA
, 0},
88 static void bfin_twi_handle_interrupt(struct bfin_twi_iface
*iface
)
90 unsigned short twi_int_status
= read_INT_STAT(iface
);
91 unsigned short mast_stat
= read_MASTER_STAT(iface
);
93 if (twi_int_status
& XMTSERV
) {
94 /* Transmit next data */
95 if (iface
->writeNum
> 0) {
96 write_XMT_DATA8(iface
, *(iface
->transPtr
++));
99 /* start receive immediately after complete sending in
102 else if (iface
->cur_mode
== TWI_I2C_MODE_COMBINED
)
103 write_MASTER_CTL(iface
,
104 read_MASTER_CTL(iface
) | MDIR
| RSTART
);
105 else if (iface
->manual_stop
)
106 write_MASTER_CTL(iface
,
107 read_MASTER_CTL(iface
) | STOP
);
108 else if (iface
->cur_mode
== TWI_I2C_MODE_REPEAT
&&
109 iface
->cur_msg
+ 1 < iface
->msg_num
) {
110 if (iface
->pmsg
[iface
->cur_msg
+ 1].flags
& I2C_M_RD
)
111 write_MASTER_CTL(iface
,
112 read_MASTER_CTL(iface
) | RSTART
| MDIR
);
114 write_MASTER_CTL(iface
,
115 (read_MASTER_CTL(iface
) | RSTART
) & ~MDIR
);
119 write_INT_STAT(iface
, XMTSERV
);
122 if (twi_int_status
& RCVSERV
) {
123 if (iface
->readNum
> 0) {
124 /* Receive next data */
125 *(iface
->transPtr
) = read_RCV_DATA8(iface
);
126 if (iface
->cur_mode
== TWI_I2C_MODE_COMBINED
) {
127 /* Change combine mode into sub mode after
130 iface
->cur_mode
= TWI_I2C_MODE_STANDARDSUB
;
131 /* Get read number from first byte in block
134 if (iface
->readNum
== 1 && iface
->manual_stop
)
135 iface
->readNum
= *iface
->transPtr
+ 1;
139 } else if (iface
->manual_stop
) {
140 write_MASTER_CTL(iface
,
141 read_MASTER_CTL(iface
) | STOP
);
143 } else if (iface
->cur_mode
== TWI_I2C_MODE_REPEAT
&&
144 iface
->cur_msg
+ 1 < iface
->msg_num
) {
145 if (iface
->pmsg
[iface
->cur_msg
+ 1].flags
& I2C_M_RD
)
146 write_MASTER_CTL(iface
,
147 read_MASTER_CTL(iface
) | RSTART
| MDIR
);
149 write_MASTER_CTL(iface
,
150 (read_MASTER_CTL(iface
) | RSTART
) & ~MDIR
);
153 /* Clear interrupt source */
154 write_INT_STAT(iface
, RCVSERV
);
157 if (twi_int_status
& MERR
) {
158 write_INT_STAT(iface
, MERR
);
159 write_INT_MASK(iface
, 0);
160 write_MASTER_STAT(iface
, 0x3e);
161 write_MASTER_CTL(iface
, 0);
163 iface
->result
= -EIO
;
164 /* if both err and complete int stats are set, return proper
167 if (twi_int_status
& MCOMP
) {
168 write_INT_STAT(iface
, MCOMP
);
169 write_INT_MASK(iface
, 0);
170 write_MASTER_CTL(iface
, 0);
172 /* If it is a quick transfer, only address bug no data,
173 * not an err, return 1.
175 if (iface
->writeNum
== 0 && (mast_stat
& BUFRDERR
))
177 /* If address not acknowledged return -1,
180 else if (!(mast_stat
& ANAK
))
183 complete(&iface
->complete
);
186 if (twi_int_status
& MCOMP
) {
187 write_INT_STAT(iface
, MCOMP
);
189 if (iface
->cur_mode
== TWI_I2C_MODE_COMBINED
) {
190 if (iface
->readNum
== 0) {
191 /* set the read number to 1 and ask for manual
192 * stop in block combine mode
195 iface
->manual_stop
= 1;
196 write_MASTER_CTL(iface
,
197 read_MASTER_CTL(iface
) | (0xff << 6));
199 /* set the readd number in other
202 write_MASTER_CTL(iface
,
203 (read_MASTER_CTL(iface
) &
205 (iface
->readNum
<< 6));
207 /* remove restart bit and enable master receive */
208 write_MASTER_CTL(iface
,
209 read_MASTER_CTL(iface
) & ~RSTART
);
211 } else if (iface
->cur_mode
== TWI_I2C_MODE_REPEAT
&&
212 iface
->cur_msg
+1 < iface
->msg_num
) {
214 iface
->transPtr
= iface
->pmsg
[iface
->cur_msg
].buf
;
215 iface
->writeNum
= iface
->readNum
=
216 iface
->pmsg
[iface
->cur_msg
].len
;
217 /* Set Transmit device address */
218 write_MASTER_ADDR(iface
,
219 iface
->pmsg
[iface
->cur_msg
].addr
);
220 if (iface
->pmsg
[iface
->cur_msg
].flags
& I2C_M_RD
)
221 iface
->read_write
= I2C_SMBUS_READ
;
223 iface
->read_write
= I2C_SMBUS_WRITE
;
224 /* Transmit first data */
225 if (iface
->writeNum
> 0) {
226 write_XMT_DATA8(iface
,
227 *(iface
->transPtr
++));
233 if (iface
->pmsg
[iface
->cur_msg
].len
<= 255)
234 write_MASTER_CTL(iface
,
235 (read_MASTER_CTL(iface
) &
237 (iface
->pmsg
[iface
->cur_msg
].len
<< 6));
239 write_MASTER_CTL(iface
,
240 (read_MASTER_CTL(iface
) |
242 iface
->manual_stop
= 1;
244 /* remove restart bit and enable master receive */
245 write_MASTER_CTL(iface
,
246 read_MASTER_CTL(iface
) & ~RSTART
);
250 write_INT_MASK(iface
, 0);
251 write_MASTER_CTL(iface
, 0);
253 complete(&iface
->complete
);
258 /* Interrupt handler */
259 static irqreturn_t
bfin_twi_interrupt_entry(int irq
, void *dev_id
)
261 struct bfin_twi_iface
*iface
= dev_id
;
264 spin_lock_irqsave(&iface
->lock
, flags
);
265 del_timer(&iface
->timeout_timer
);
266 bfin_twi_handle_interrupt(iface
);
267 spin_unlock_irqrestore(&iface
->lock
, flags
);
271 static void bfin_twi_timeout(unsigned long data
)
273 struct bfin_twi_iface
*iface
= (struct bfin_twi_iface
*)data
;
276 spin_lock_irqsave(&iface
->lock
, flags
);
277 bfin_twi_handle_interrupt(iface
);
278 if (iface
->result
== 0) {
279 iface
->timeout_count
--;
280 if (iface
->timeout_count
> 0) {
281 iface
->timeout_timer
.expires
= jiffies
+ POLL_TIMEOUT
;
282 add_timer(&iface
->timeout_timer
);
285 complete(&iface
->complete
);
288 spin_unlock_irqrestore(&iface
->lock
, flags
);
292 * Generic i2c master transfer entrypoint
294 static int bfin_twi_master_xfer(struct i2c_adapter
*adap
,
295 struct i2c_msg
*msgs
, int num
)
297 struct bfin_twi_iface
*iface
= adap
->algo_data
;
298 struct i2c_msg
*pmsg
;
301 if (!(read_CONTROL(iface
) & TWI_ENA
))
304 while (read_MASTER_STAT(iface
) & BUSBUSY
)
308 iface
->msg_num
= num
;
312 if (pmsg
->flags
& I2C_M_TEN
) {
313 dev_err(&adap
->dev
, "10 bits addr not supported!\n");
317 iface
->cur_mode
= TWI_I2C_MODE_REPEAT
;
318 iface
->manual_stop
= 0;
319 iface
->transPtr
= pmsg
->buf
;
320 iface
->writeNum
= iface
->readNum
= pmsg
->len
;
322 iface
->timeout_count
= 10;
323 init_completion(&(iface
->complete
));
324 /* Set Transmit device address */
325 write_MASTER_ADDR(iface
, pmsg
->addr
);
327 /* FIFO Initiation. Data in FIFO should be
328 * discarded before start a new operation.
330 write_FIFO_CTL(iface
, 0x3);
332 write_FIFO_CTL(iface
, 0);
335 if (pmsg
->flags
& I2C_M_RD
)
336 iface
->read_write
= I2C_SMBUS_READ
;
338 iface
->read_write
= I2C_SMBUS_WRITE
;
339 /* Transmit first data */
340 if (iface
->writeNum
> 0) {
341 write_XMT_DATA8(iface
, *(iface
->transPtr
++));
348 write_INT_STAT(iface
, MERR
| MCOMP
| XMTSERV
| RCVSERV
);
350 /* Interrupt mask . Enable XMT, RCV interrupt */
351 write_INT_MASK(iface
, MCOMP
| MERR
| RCVSERV
| XMTSERV
);
354 if (pmsg
->len
<= 255)
355 write_MASTER_CTL(iface
, pmsg
->len
<< 6);
357 write_MASTER_CTL(iface
, 0xff << 6);
358 iface
->manual_stop
= 1;
361 iface
->timeout_timer
.expires
= jiffies
+ POLL_TIMEOUT
;
362 add_timer(&iface
->timeout_timer
);
365 write_MASTER_CTL(iface
, read_MASTER_CTL(iface
) | MEN
|
366 ((iface
->read_write
== I2C_SMBUS_READ
) ? MDIR
: 0) |
367 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ
> 100) ? FAST
: 0));
370 wait_for_completion(&iface
->complete
);
381 * SMBus type transfer entrypoint
384 int bfin_twi_smbus_xfer(struct i2c_adapter
*adap
, u16 addr
,
385 unsigned short flags
, char read_write
,
386 u8 command
, int size
, union i2c_smbus_data
*data
)
388 struct bfin_twi_iface
*iface
= adap
->algo_data
;
391 if (!(read_CONTROL(iface
) & TWI_ENA
))
394 while (read_MASTER_STAT(iface
) & BUSBUSY
)
400 /* Prepare datas & select mode */
402 case I2C_SMBUS_QUICK
:
403 iface
->transPtr
= NULL
;
404 iface
->cur_mode
= TWI_I2C_MODE_STANDARD
;
408 iface
->transPtr
= NULL
;
410 if (read_write
== I2C_SMBUS_READ
)
414 iface
->transPtr
= &data
->byte
;
416 iface
->cur_mode
= TWI_I2C_MODE_STANDARD
;
418 case I2C_SMBUS_BYTE_DATA
:
419 if (read_write
== I2C_SMBUS_READ
) {
421 iface
->cur_mode
= TWI_I2C_MODE_COMBINED
;
424 iface
->cur_mode
= TWI_I2C_MODE_STANDARDSUB
;
426 iface
->transPtr
= &data
->byte
;
428 case I2C_SMBUS_WORD_DATA
:
429 if (read_write
== I2C_SMBUS_READ
) {
431 iface
->cur_mode
= TWI_I2C_MODE_COMBINED
;
434 iface
->cur_mode
= TWI_I2C_MODE_STANDARDSUB
;
436 iface
->transPtr
= (u8
*)&data
->word
;
438 case I2C_SMBUS_PROC_CALL
:
441 iface
->cur_mode
= TWI_I2C_MODE_COMBINED
;
442 iface
->transPtr
= (u8
*)&data
->word
;
444 case I2C_SMBUS_BLOCK_DATA
:
445 if (read_write
== I2C_SMBUS_READ
) {
447 iface
->cur_mode
= TWI_I2C_MODE_COMBINED
;
449 iface
->writeNum
= data
->block
[0] + 1;
450 iface
->cur_mode
= TWI_I2C_MODE_STANDARDSUB
;
452 iface
->transPtr
= data
->block
;
454 case I2C_SMBUS_I2C_BLOCK_DATA
:
455 if (read_write
== I2C_SMBUS_READ
) {
456 iface
->readNum
= data
->block
[0];
457 iface
->cur_mode
= TWI_I2C_MODE_COMBINED
;
459 iface
->writeNum
= data
->block
[0];
460 iface
->cur_mode
= TWI_I2C_MODE_STANDARDSUB
;
462 iface
->transPtr
= (u8
*)&data
->block
[1];
469 iface
->manual_stop
= 0;
470 iface
->read_write
= read_write
;
471 iface
->command
= command
;
472 iface
->timeout_count
= 10;
473 init_completion(&(iface
->complete
));
475 /* FIFO Initiation. Data in FIFO should be discarded before
476 * start a new operation.
478 write_FIFO_CTL(iface
, 0x3);
480 write_FIFO_CTL(iface
, 0);
483 write_INT_STAT(iface
, MERR
| MCOMP
| XMTSERV
| RCVSERV
);
485 /* Set Transmit device address */
486 write_MASTER_ADDR(iface
, addr
);
489 iface
->timeout_timer
.expires
= jiffies
+ POLL_TIMEOUT
;
490 add_timer(&iface
->timeout_timer
);
492 switch (iface
->cur_mode
) {
493 case TWI_I2C_MODE_STANDARDSUB
:
494 write_XMT_DATA8(iface
, iface
->command
);
495 write_INT_MASK(iface
, MCOMP
| MERR
|
496 ((iface
->read_write
== I2C_SMBUS_READ
) ?
500 if (iface
->writeNum
+ 1 <= 255)
501 write_MASTER_CTL(iface
, (iface
->writeNum
+ 1) << 6);
503 write_MASTER_CTL(iface
, 0xff << 6);
504 iface
->manual_stop
= 1;
507 write_MASTER_CTL(iface
, read_MASTER_CTL(iface
) | MEN
|
508 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ
>100) ? FAST
: 0));
510 case TWI_I2C_MODE_COMBINED
:
511 write_XMT_DATA8(iface
, iface
->command
);
512 write_INT_MASK(iface
, MCOMP
| MERR
| RCVSERV
| XMTSERV
);
515 if (iface
->writeNum
> 0)
516 write_MASTER_CTL(iface
, (iface
->writeNum
+ 1) << 6);
518 write_MASTER_CTL(iface
, 0x1 << 6);
520 write_MASTER_CTL(iface
, read_MASTER_CTL(iface
) | MEN
|
521 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ
>100) ? FAST
: 0));
524 write_MASTER_CTL(iface
, 0);
525 if (size
!= I2C_SMBUS_QUICK
) {
526 /* Don't access xmit data register when this is a
529 if (iface
->read_write
!= I2C_SMBUS_READ
) {
530 if (iface
->writeNum
> 0) {
531 write_XMT_DATA8(iface
,
532 *(iface
->transPtr
++));
533 if (iface
->writeNum
<= 255)
534 write_MASTER_CTL(iface
,
535 iface
->writeNum
<< 6);
537 write_MASTER_CTL(iface
,
539 iface
->manual_stop
= 1;
543 write_XMT_DATA8(iface
, iface
->command
);
544 write_MASTER_CTL(iface
, 1 << 6);
547 if (iface
->readNum
> 0 && iface
->readNum
<= 255)
548 write_MASTER_CTL(iface
,
549 iface
->readNum
<< 6);
550 else if (iface
->readNum
> 255) {
551 write_MASTER_CTL(iface
, 0xff << 6);
552 iface
->manual_stop
= 1;
554 del_timer(&iface
->timeout_timer
);
559 write_INT_MASK(iface
, MCOMP
| MERR
|
560 ((iface
->read_write
== I2C_SMBUS_READ
) ?
565 write_MASTER_CTL(iface
, read_MASTER_CTL(iface
) | MEN
|
566 ((iface
->read_write
== I2C_SMBUS_READ
) ? MDIR
: 0) |
567 ((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ
> 100) ? FAST
: 0));
572 wait_for_completion(&iface
->complete
);
574 rc
= (iface
->result
>= 0) ? 0 : -1;
580 * Return what the adapter supports
582 static u32
bfin_twi_functionality(struct i2c_adapter
*adap
)
584 return I2C_FUNC_SMBUS_QUICK
| I2C_FUNC_SMBUS_BYTE
|
585 I2C_FUNC_SMBUS_BYTE_DATA
| I2C_FUNC_SMBUS_WORD_DATA
|
586 I2C_FUNC_SMBUS_BLOCK_DATA
| I2C_FUNC_SMBUS_PROC_CALL
|
587 I2C_FUNC_I2C
| I2C_FUNC_SMBUS_I2C_BLOCK
;
590 static struct i2c_algorithm bfin_twi_algorithm
= {
591 .master_xfer
= bfin_twi_master_xfer
,
592 .smbus_xfer
= bfin_twi_smbus_xfer
,
593 .functionality
= bfin_twi_functionality
,
596 static int i2c_bfin_twi_suspend(struct platform_device
*pdev
, pm_message_t state
)
598 struct bfin_twi_iface
*iface
= platform_get_drvdata(pdev
);
600 iface
->saved_clkdiv
= read_CLKDIV(iface
);
601 iface
->saved_control
= read_CONTROL(iface
);
603 free_irq(iface
->irq
, iface
);
606 write_CONTROL(iface
, iface
->saved_control
& ~TWI_ENA
);
611 static int i2c_bfin_twi_resume(struct platform_device
*pdev
)
613 struct bfin_twi_iface
*iface
= platform_get_drvdata(pdev
);
615 int rc
= request_irq(iface
->irq
, bfin_twi_interrupt_entry
,
616 IRQF_DISABLED
, pdev
->name
, iface
);
618 dev_err(&pdev
->dev
, "Can't get IRQ %d !\n", iface
->irq
);
622 /* Resume TWI interface clock as specified */
623 write_CLKDIV(iface
, iface
->saved_clkdiv
);
626 write_CONTROL(iface
, iface
->saved_control
);
631 static int i2c_bfin_twi_probe(struct platform_device
*pdev
)
633 struct bfin_twi_iface
*iface
;
634 struct i2c_adapter
*p_adap
;
635 struct resource
*res
;
637 unsigned int clkhilow
;
639 iface
= kzalloc(sizeof(struct bfin_twi_iface
), GFP_KERNEL
);
641 dev_err(&pdev
->dev
, "Cannot allocate memory\n");
643 goto out_error_nomem
;
646 spin_lock_init(&(iface
->lock
));
648 /* Find and map our resources */
649 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
651 dev_err(&pdev
->dev
, "Cannot get IORESOURCE_MEM\n");
653 goto out_error_get_res
;
656 iface
->regs_base
= ioremap(res
->start
, resource_size(res
));
657 if (iface
->regs_base
== NULL
) {
658 dev_err(&pdev
->dev
, "Cannot map IO\n");
660 goto out_error_ioremap
;
663 iface
->irq
= platform_get_irq(pdev
, 0);
664 if (iface
->irq
< 0) {
665 dev_err(&pdev
->dev
, "No IRQ specified\n");
667 goto out_error_no_irq
;
670 init_timer(&(iface
->timeout_timer
));
671 iface
->timeout_timer
.function
= bfin_twi_timeout
;
672 iface
->timeout_timer
.data
= (unsigned long)iface
;
674 p_adap
= &iface
->adap
;
675 p_adap
->nr
= pdev
->id
;
676 strlcpy(p_adap
->name
, pdev
->name
, sizeof(p_adap
->name
));
677 p_adap
->algo
= &bfin_twi_algorithm
;
678 p_adap
->algo_data
= iface
;
679 p_adap
->class = I2C_CLASS_HWMON
| I2C_CLASS_SPD
;
680 p_adap
->dev
.parent
= &pdev
->dev
;
682 rc
= peripheral_request_list(pin_req
[pdev
->id
], "i2c-bfin-twi");
684 dev_err(&pdev
->dev
, "Can't setup pin mux!\n");
685 goto out_error_pin_mux
;
688 rc
= request_irq(iface
->irq
, bfin_twi_interrupt_entry
,
689 IRQF_DISABLED
, pdev
->name
, iface
);
691 dev_err(&pdev
->dev
, "Can't get IRQ %d !\n", iface
->irq
);
693 goto out_error_req_irq
;
696 /* Set TWI internal clock as 10MHz */
697 write_CONTROL(iface
, ((get_sclk() / 1000 / 1000 + 5) / 10) & 0x7F);
700 * We will not end up with a CLKDIV=0 because no one will specify
701 * 20kHz SCL or less in Kconfig now. (5 * 1000 / 20 = 250)
703 clkhilow
= ((10 * 1000 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ
) + 1) / 2;
705 /* Set Twi interface clock as specified */
706 write_CLKDIV(iface
, (clkhilow
<< 8) | clkhilow
);
709 write_CONTROL(iface
, read_CONTROL(iface
) | TWI_ENA
);
712 rc
= i2c_add_numbered_adapter(p_adap
);
714 dev_err(&pdev
->dev
, "Can't add i2c adapter!\n");
715 goto out_error_add_adapter
;
718 platform_set_drvdata(pdev
, iface
);
720 dev_info(&pdev
->dev
, "Blackfin BF5xx on-chip I2C TWI Contoller, "
721 "regs_base@%p\n", iface
->regs_base
);
725 out_error_add_adapter
:
726 free_irq(iface
->irq
, iface
);
729 peripheral_free_list(pin_req
[pdev
->id
]);
731 iounmap(iface
->regs_base
);
739 static int i2c_bfin_twi_remove(struct platform_device
*pdev
)
741 struct bfin_twi_iface
*iface
= platform_get_drvdata(pdev
);
743 platform_set_drvdata(pdev
, NULL
);
745 i2c_del_adapter(&(iface
->adap
));
746 free_irq(iface
->irq
, iface
);
747 peripheral_free_list(pin_req
[pdev
->id
]);
748 iounmap(iface
->regs_base
);
754 static struct platform_driver i2c_bfin_twi_driver
= {
755 .probe
= i2c_bfin_twi_probe
,
756 .remove
= i2c_bfin_twi_remove
,
757 .suspend
= i2c_bfin_twi_suspend
,
758 .resume
= i2c_bfin_twi_resume
,
760 .name
= "i2c-bfin-twi",
761 .owner
= THIS_MODULE
,
765 static int __init
i2c_bfin_twi_init(void)
767 return platform_driver_register(&i2c_bfin_twi_driver
);
770 static void __exit
i2c_bfin_twi_exit(void)
772 platform_driver_unregister(&i2c_bfin_twi_driver
);
775 module_init(i2c_bfin_twi_init
);
776 module_exit(i2c_bfin_twi_exit
);
778 MODULE_AUTHOR("Bryan Wu, Sonic Zhang");
779 MODULE_DESCRIPTION("Blackfin BF5xx on-chip I2C TWI Contoller Driver");
780 MODULE_LICENSE("GPL");
781 MODULE_ALIAS("platform:i2c-bfin-twi");