2 * Provides I2C support for Philips PNX010x/PNX4008 boards.
4 * Authors: Dennis Kovalev <dkovalev@ru.mvista.com>
5 * Vitaly Wool <vwool@ru.mvista.com>
7 * 2004-2006 (c) MontaVista Software, Inc. This file is licensed under
8 * the terms of the GNU General Public License version 2. This program
9 * is licensed "as is" without any warranty of any kind, whether express
13 #include <linux/module.h>
14 #include <linux/interrupt.h>
15 #include <linux/ioport.h>
16 #include <linux/delay.h>
17 #include <linux/i2c.h>
18 #include <linux/timer.h>
19 #include <linux/completion.h>
20 #include <linux/platform_device.h>
21 #include <linux/i2c-pnx.h>
23 #include <linux/err.h>
24 #include <linux/clk.h>
26 #include <mach/hardware.h>
29 #define I2C_PNX_TIMEOUT 10 /* msec */
30 #define I2C_PNX_SPEED_KHZ 100
31 #define I2C_PNX_REGION_SIZE 0x100
33 static inline int wait_timeout(long timeout
, struct i2c_pnx_algo_data
*data
)
36 (ioread32(I2C_REG_STS(data
)) & mstatus_active
)) {
40 return (timeout
<= 0);
43 static inline int wait_reset(long timeout
, struct i2c_pnx_algo_data
*data
)
46 (ioread32(I2C_REG_CTL(data
)) & mcntrl_reset
)) {
50 return (timeout
<= 0);
53 static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data
*alg_data
)
55 struct timer_list
*timer
= &alg_data
->mif
.timer
;
56 unsigned long expires
= msecs_to_jiffies(I2C_PNX_TIMEOUT
);
61 del_timer_sync(timer
);
63 dev_dbg(&alg_data
->adapter
.dev
, "Timer armed at %lu plus %lu jiffies.\n",
66 timer
->expires
= jiffies
+ expires
;
67 timer
->data
= (unsigned long)&alg_data
;
73 * i2c_pnx_start - start a device
74 * @slave_addr: slave address
75 * @adap: pointer to adapter structure
77 * Generate a START signal in the desired mode.
79 static int i2c_pnx_start(unsigned char slave_addr
,
80 struct i2c_pnx_algo_data
*alg_data
)
82 dev_dbg(&alg_data
->adapter
.dev
, "%s(): addr 0x%x mode %d\n", __func__
,
83 slave_addr
, alg_data
->mif
.mode
);
85 /* Check for 7 bit slave addresses only */
86 if (slave_addr
& ~0x7f) {
87 dev_err(&alg_data
->adapter
.dev
,
88 "%s: Invalid slave address %x. Only 7-bit addresses are supported\n",
89 alg_data
->adapter
.name
, slave_addr
);
93 /* First, make sure bus is idle */
94 if (wait_timeout(I2C_PNX_TIMEOUT
, alg_data
)) {
95 /* Somebody else is monopolizing the bus */
96 dev_err(&alg_data
->adapter
.dev
,
97 "%s: Bus busy. Slave addr = %02x, cntrl = %x, stat = %x\n",
98 alg_data
->adapter
.name
, slave_addr
,
99 ioread32(I2C_REG_CTL(alg_data
)),
100 ioread32(I2C_REG_STS(alg_data
)));
102 } else if (ioread32(I2C_REG_STS(alg_data
)) & mstatus_afi
) {
103 /* Sorry, we lost the bus */
104 dev_err(&alg_data
->adapter
.dev
,
105 "%s: Arbitration failure. Slave addr = %02x\n",
106 alg_data
->adapter
.name
, slave_addr
);
111 * OK, I2C is enabled and we have the bus.
112 * Clear the current TDI and AFI status flags.
114 iowrite32(ioread32(I2C_REG_STS(alg_data
)) | mstatus_tdi
| mstatus_afi
,
115 I2C_REG_STS(alg_data
));
117 dev_dbg(&alg_data
->adapter
.dev
, "%s(): sending %#x\n", __func__
,
118 (slave_addr
<< 1) | start_bit
| alg_data
->mif
.mode
);
120 /* Write the slave address, START bit and R/W bit */
121 iowrite32((slave_addr
<< 1) | start_bit
| alg_data
->mif
.mode
,
122 I2C_REG_TX(alg_data
));
124 dev_dbg(&alg_data
->adapter
.dev
, "%s(): exit\n", __func__
);
130 * i2c_pnx_stop - stop a device
131 * @adap: pointer to I2C adapter structure
133 * Generate a STOP signal to terminate the master transaction.
135 static void i2c_pnx_stop(struct i2c_pnx_algo_data
*alg_data
)
137 /* Only 1 msec max timeout due to interrupt context */
140 dev_dbg(&alg_data
->adapter
.dev
, "%s(): entering: stat = %04x.\n",
141 __func__
, ioread32(I2C_REG_STS(alg_data
)));
143 /* Write a STOP bit to TX FIFO */
144 iowrite32(0xff | stop_bit
, I2C_REG_TX(alg_data
));
146 /* Wait until the STOP is seen. */
147 while (timeout
> 0 &&
148 (ioread32(I2C_REG_STS(alg_data
)) & mstatus_active
)) {
149 /* may be called from interrupt context */
154 dev_dbg(&alg_data
->adapter
.dev
, "%s(): exiting: stat = %04x.\n",
155 __func__
, ioread32(I2C_REG_STS(alg_data
)));
159 * i2c_pnx_master_xmit - transmit data to slave
160 * @adap: pointer to I2C adapter structure
162 * Sends one byte of data to the slave
164 static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data
*alg_data
)
168 dev_dbg(&alg_data
->adapter
.dev
, "%s(): entering: stat = %04x.\n",
169 __func__
, ioread32(I2C_REG_STS(alg_data
)));
171 if (alg_data
->mif
.len
> 0) {
172 /* We still have something to talk about... */
173 val
= *alg_data
->mif
.buf
++;
176 iowrite32(val
, I2C_REG_TX(alg_data
));
178 dev_dbg(&alg_data
->adapter
.dev
, "%s(): xmit %#x [%d]\n",
179 __func__
, val
, alg_data
->mif
.len
+ 1);
181 if (alg_data
->mif
.len
== 0) {
182 if (alg_data
->last
) {
183 /* Wait until the STOP is seen. */
184 if (wait_timeout(I2C_PNX_TIMEOUT
, alg_data
))
185 dev_err(&alg_data
->adapter
.dev
,
186 "The bus is still active after timeout\n");
188 /* Disable master interrupts */
189 iowrite32(ioread32(I2C_REG_CTL(alg_data
)) &
190 ~(mcntrl_afie
| mcntrl_naie
| mcntrl_drmie
),
191 I2C_REG_CTL(alg_data
));
193 del_timer_sync(&alg_data
->mif
.timer
);
195 dev_dbg(&alg_data
->adapter
.dev
,
196 "%s(): Waking up xfer routine.\n",
199 complete(&alg_data
->mif
.complete
);
201 } else if (alg_data
->mif
.len
== 0) {
202 /* zero-sized transfer */
203 i2c_pnx_stop(alg_data
);
205 /* Disable master interrupts. */
206 iowrite32(ioread32(I2C_REG_CTL(alg_data
)) &
207 ~(mcntrl_afie
| mcntrl_naie
| mcntrl_drmie
),
208 I2C_REG_CTL(alg_data
));
211 del_timer_sync(&alg_data
->mif
.timer
);
212 dev_dbg(&alg_data
->adapter
.dev
,
213 "%s(): Waking up xfer routine after zero-xfer.\n",
216 complete(&alg_data
->mif
.complete
);
219 dev_dbg(&alg_data
->adapter
.dev
, "%s(): exiting: stat = %04x.\n",
220 __func__
, ioread32(I2C_REG_STS(alg_data
)));
226 * i2c_pnx_master_rcv - receive data from slave
227 * @adap: pointer to I2C adapter structure
229 * Reads one byte data from the slave
231 static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data
*alg_data
)
233 unsigned int val
= 0;
236 dev_dbg(&alg_data
->adapter
.dev
, "%s(): entering: stat = %04x.\n",
237 __func__
, ioread32(I2C_REG_STS(alg_data
)));
239 /* Check, whether there is already data,
240 * or we didn't 'ask' for it yet.
242 if (ioread32(I2C_REG_STS(alg_data
)) & mstatus_rfe
) {
243 dev_dbg(&alg_data
->adapter
.dev
,
244 "%s(): Write dummy data to fill Rx-fifo...\n",
247 if (alg_data
->mif
.len
== 1) {
249 * Enable interrupt RFDAIE (data in Rx fifo),
250 * and disable DRMIE (need data for Tx)
252 ctl
= ioread32(I2C_REG_CTL(alg_data
));
253 ctl
|= mcntrl_rffie
| mcntrl_daie
;
254 ctl
&= ~mcntrl_drmie
;
255 iowrite32(ctl
, I2C_REG_CTL(alg_data
));
259 * Now we'll 'ask' for data:
260 * For each byte we want to receive, we must
261 * write a (dummy) byte to the Tx-FIFO.
263 iowrite32(val
, I2C_REG_TX(alg_data
));
269 if (alg_data
->mif
.len
> 0) {
270 val
= ioread32(I2C_REG_RX(alg_data
));
271 *alg_data
->mif
.buf
++ = (u8
) (val
& 0xff);
272 dev_dbg(&alg_data
->adapter
.dev
, "%s(): rcv 0x%x [%d]\n",
273 __func__
, val
, alg_data
->mif
.len
);
276 if (alg_data
->mif
.len
== 0) {
278 /* Wait until the STOP is seen. */
279 if (wait_timeout(I2C_PNX_TIMEOUT
, alg_data
))
280 dev_err(&alg_data
->adapter
.dev
,
281 "The bus is still active after timeout\n");
283 /* Disable master interrupts */
284 ctl
= ioread32(I2C_REG_CTL(alg_data
));
285 ctl
&= ~(mcntrl_afie
| mcntrl_naie
| mcntrl_rffie
|
286 mcntrl_drmie
| mcntrl_daie
);
287 iowrite32(ctl
, I2C_REG_CTL(alg_data
));
290 del_timer_sync(&alg_data
->mif
.timer
);
291 complete(&alg_data
->mif
.complete
);
295 dev_dbg(&alg_data
->adapter
.dev
, "%s(): exiting: stat = %04x.\n",
296 __func__
, ioread32(I2C_REG_STS(alg_data
)));
301 static irqreturn_t
i2c_pnx_interrupt(int irq
, void *dev_id
)
303 struct i2c_pnx_algo_data
*alg_data
= dev_id
;
306 dev_dbg(&alg_data
->adapter
.dev
,
307 "%s(): mstat = %x mctrl = %x, mode = %d\n",
309 ioread32(I2C_REG_STS(alg_data
)),
310 ioread32(I2C_REG_CTL(alg_data
)),
312 stat
= ioread32(I2C_REG_STS(alg_data
));
314 /* let's see what kind of event this is */
315 if (stat
& mstatus_afi
) {
316 /* We lost arbitration in the midst of a transfer */
317 alg_data
->mif
.ret
= -EIO
;
319 /* Disable master interrupts. */
320 ctl
= ioread32(I2C_REG_CTL(alg_data
));
321 ctl
&= ~(mcntrl_afie
| mcntrl_naie
| mcntrl_rffie
|
323 iowrite32(ctl
, I2C_REG_CTL(alg_data
));
325 /* Stop timer, to prevent timeout. */
326 del_timer_sync(&alg_data
->mif
.timer
);
327 complete(&alg_data
->mif
.complete
);
328 } else if (stat
& mstatus_nai
) {
329 /* Slave did not acknowledge, generate a STOP */
330 dev_dbg(&alg_data
->adapter
.dev
,
331 "%s(): Slave did not acknowledge, generating a STOP.\n",
333 i2c_pnx_stop(alg_data
);
335 /* Disable master interrupts. */
336 ctl
= ioread32(I2C_REG_CTL(alg_data
));
337 ctl
&= ~(mcntrl_afie
| mcntrl_naie
| mcntrl_rffie
|
339 iowrite32(ctl
, I2C_REG_CTL(alg_data
));
341 /* Our return value. */
342 alg_data
->mif
.ret
= -EIO
;
344 /* Stop timer, to prevent timeout. */
345 del_timer_sync(&alg_data
->mif
.timer
);
346 complete(&alg_data
->mif
.complete
);
350 * - Master Tx needs data.
351 * - There is data in the Rx-fifo
352 * The latter is only the case if we have requested for data,
353 * via a dummy write. (See 'i2c_pnx_master_rcv'.)
354 * We therefore check, as a sanity check, whether that interrupt
357 if ((stat
& mstatus_drmi
) || !(stat
& mstatus_rfe
)) {
358 if (alg_data
->mif
.mode
== I2C_SMBUS_WRITE
) {
359 i2c_pnx_master_xmit(alg_data
);
360 } else if (alg_data
->mif
.mode
== I2C_SMBUS_READ
) {
361 i2c_pnx_master_rcv(alg_data
);
366 /* Clear TDI and AFI bits */
367 stat
= ioread32(I2C_REG_STS(alg_data
));
368 iowrite32(stat
| mstatus_tdi
| mstatus_afi
, I2C_REG_STS(alg_data
));
370 dev_dbg(&alg_data
->adapter
.dev
,
371 "%s(): exiting, stat = %x ctrl = %x.\n",
372 __func__
, ioread32(I2C_REG_STS(alg_data
)),
373 ioread32(I2C_REG_CTL(alg_data
)));
378 static void i2c_pnx_timeout(unsigned long data
)
380 struct i2c_pnx_algo_data
*alg_data
= (struct i2c_pnx_algo_data
*)data
;
383 dev_err(&alg_data
->adapter
.dev
,
384 "Master timed out. stat = %04x, cntrl = %04x. Resetting master...\n",
385 ioread32(I2C_REG_STS(alg_data
)),
386 ioread32(I2C_REG_CTL(alg_data
)));
388 /* Reset master and disable interrupts */
389 ctl
= ioread32(I2C_REG_CTL(alg_data
));
390 ctl
&= ~(mcntrl_afie
| mcntrl_naie
| mcntrl_rffie
| mcntrl_drmie
);
391 iowrite32(ctl
, I2C_REG_CTL(alg_data
));
394 iowrite32(ctl
, I2C_REG_CTL(alg_data
));
395 wait_reset(I2C_PNX_TIMEOUT
, alg_data
);
396 alg_data
->mif
.ret
= -EIO
;
397 complete(&alg_data
->mif
.complete
);
400 static inline void bus_reset_if_active(struct i2c_pnx_algo_data
*alg_data
)
404 if ((stat
= ioread32(I2C_REG_STS(alg_data
))) & mstatus_active
) {
405 dev_err(&alg_data
->adapter
.dev
,
406 "%s: Bus is still active after xfer. Reset it...\n",
407 alg_data
->adapter
.name
);
408 iowrite32(ioread32(I2C_REG_CTL(alg_data
)) | mcntrl_reset
,
409 I2C_REG_CTL(alg_data
));
410 wait_reset(I2C_PNX_TIMEOUT
, alg_data
);
411 } else if (!(stat
& mstatus_rfe
) || !(stat
& mstatus_tfe
)) {
412 /* If there is data in the fifo's after transfer,
413 * flush fifo's by reset.
415 iowrite32(ioread32(I2C_REG_CTL(alg_data
)) | mcntrl_reset
,
416 I2C_REG_CTL(alg_data
));
417 wait_reset(I2C_PNX_TIMEOUT
, alg_data
);
418 } else if (stat
& mstatus_nai
) {
419 iowrite32(ioread32(I2C_REG_CTL(alg_data
)) | mcntrl_reset
,
420 I2C_REG_CTL(alg_data
));
421 wait_reset(I2C_PNX_TIMEOUT
, alg_data
);
426 * i2c_pnx_xfer - generic transfer entry point
427 * @adap: pointer to I2C adapter structure
428 * @msgs: array of messages
429 * @num: number of messages
431 * Initiates the transfer
434 i2c_pnx_xfer(struct i2c_adapter
*adap
, struct i2c_msg
*msgs
, int num
)
436 struct i2c_msg
*pmsg
;
437 int rc
= 0, completed
= 0, i
;
438 struct i2c_pnx_algo_data
*alg_data
= adap
->algo_data
;
439 u32 stat
= ioread32(I2C_REG_STS(alg_data
));
441 dev_dbg(&alg_data
->adapter
.dev
,
442 "%s(): entering: %d messages, stat = %04x.\n",
443 __func__
, num
, ioread32(I2C_REG_STS(alg_data
)));
445 bus_reset_if_active(alg_data
);
447 /* Process transactions in a loop. */
448 for (i
= 0; rc
>= 0 && i
< num
; i
++) {
454 if (pmsg
->flags
& I2C_M_TEN
) {
455 dev_err(&alg_data
->adapter
.dev
,
456 "%s: 10 bits addr not supported!\n",
457 alg_data
->adapter
.name
);
462 alg_data
->mif
.buf
= pmsg
->buf
;
463 alg_data
->mif
.len
= pmsg
->len
;
464 alg_data
->mif
.mode
= (pmsg
->flags
& I2C_M_RD
) ?
465 I2C_SMBUS_READ
: I2C_SMBUS_WRITE
;
466 alg_data
->mif
.ret
= 0;
467 alg_data
->last
= (i
== num
- 1);
469 dev_dbg(&alg_data
->adapter
.dev
, "%s(): mode %d, %d bytes\n",
470 __func__
, alg_data
->mif
.mode
, alg_data
->mif
.len
);
472 i2c_pnx_arm_timer(alg_data
);
474 /* initialize the completion var */
475 init_completion(&alg_data
->mif
.complete
);
477 /* Enable master interrupt */
478 iowrite32(ioread32(I2C_REG_CTL(alg_data
)) | mcntrl_afie
|
479 mcntrl_naie
| mcntrl_drmie
,
480 I2C_REG_CTL(alg_data
));
482 /* Put start-code and slave-address on the bus. */
483 rc
= i2c_pnx_start(addr
, alg_data
);
487 /* Wait for completion */
488 wait_for_completion(&alg_data
->mif
.complete
);
490 if (!(rc
= alg_data
->mif
.ret
))
492 dev_dbg(&alg_data
->adapter
.dev
,
493 "%s(): Complete, return code = %d.\n",
496 /* Clear TDI and AFI bits in case they are set. */
497 if ((stat
= ioread32(I2C_REG_STS(alg_data
))) & mstatus_tdi
) {
498 dev_dbg(&alg_data
->adapter
.dev
,
499 "%s: TDI still set... clearing now.\n",
500 alg_data
->adapter
.name
);
501 iowrite32(stat
, I2C_REG_STS(alg_data
));
503 if ((stat
= ioread32(I2C_REG_STS(alg_data
))) & mstatus_afi
) {
504 dev_dbg(&alg_data
->adapter
.dev
,
505 "%s: AFI still set... clearing now.\n",
506 alg_data
->adapter
.name
);
507 iowrite32(stat
, I2C_REG_STS(alg_data
));
511 bus_reset_if_active(alg_data
);
513 /* Cleanup to be sure... */
514 alg_data
->mif
.buf
= NULL
;
515 alg_data
->mif
.len
= 0;
517 dev_dbg(&alg_data
->adapter
.dev
, "%s(): exiting, stat = %x\n",
518 __func__
, ioread32(I2C_REG_STS(alg_data
)));
520 if (completed
!= num
)
521 return ((rc
< 0) ? rc
: -EREMOTEIO
);
526 static u32
i2c_pnx_func(struct i2c_adapter
*adapter
)
528 return I2C_FUNC_I2C
| I2C_FUNC_SMBUS_EMUL
;
531 static struct i2c_algorithm pnx_algorithm
= {
532 .master_xfer
= i2c_pnx_xfer
,
533 .functionality
= i2c_pnx_func
,
537 static int i2c_pnx_controller_suspend(struct platform_device
*pdev
,
540 struct i2c_pnx_algo_data
*alg_data
= platform_get_drvdata(pdev
);
542 /* FIXME: shouldn't this be clk_disable? */
543 clk_enable(alg_data
->clk
);
548 static int i2c_pnx_controller_resume(struct platform_device
*pdev
)
550 struct i2c_pnx_algo_data
*alg_data
= platform_get_drvdata(pdev
);
552 return clk_enable(alg_data
->clk
);
555 #define i2c_pnx_controller_suspend NULL
556 #define i2c_pnx_controller_resume NULL
559 static int __devinit
i2c_pnx_probe(struct platform_device
*pdev
)
563 struct i2c_pnx_algo_data
*alg_data
;
565 struct i2c_pnx_data
*i2c_pnx
= pdev
->dev
.platform_data
;
567 if (!i2c_pnx
|| !i2c_pnx
->name
) {
568 dev_err(&pdev
->dev
, "%s: no platform data supplied\n",
574 alg_data
= kzalloc(sizeof(*alg_data
), GFP_KERNEL
);
580 platform_set_drvdata(pdev
, alg_data
);
582 strlcpy(alg_data
->adapter
.name
, i2c_pnx
->name
,
583 sizeof(alg_data
->adapter
.name
));
584 alg_data
->adapter
.dev
.parent
= &pdev
->dev
;
585 alg_data
->adapter
.algo
= &pnx_algorithm
;
586 alg_data
->adapter
.algo_data
= alg_data
;
587 alg_data
->adapter
.nr
= pdev
->id
;
588 alg_data
->i2c_pnx
= i2c_pnx
;
590 alg_data
->clk
= clk_get(&pdev
->dev
, NULL
);
591 if (IS_ERR(alg_data
->clk
)) {
592 ret
= PTR_ERR(alg_data
->clk
);
596 init_timer(&alg_data
->mif
.timer
);
597 alg_data
->mif
.timer
.function
= i2c_pnx_timeout
;
598 alg_data
->mif
.timer
.data
= (unsigned long)alg_data
;
600 /* Register I/O resource */
601 if (!request_mem_region(i2c_pnx
->base
, I2C_PNX_REGION_SIZE
,
604 "I/O region 0x%08x for I2C already in use.\n",
610 alg_data
->ioaddr
= ioremap(i2c_pnx
->base
, I2C_PNX_REGION_SIZE
);
611 if (!alg_data
->ioaddr
) {
612 dev_err(&pdev
->dev
, "Couldn't ioremap I2C I/O region\n");
617 ret
= clk_enable(alg_data
->clk
);
621 freq
= clk_get_rate(alg_data
->clk
);
624 * Clock Divisor High This value is the number of system clocks
625 * the serial clock (SCL) will be high.
626 * For example, if the system clock period is 50 ns and the maximum
627 * desired serial period is 10000 ns (100 kHz), then CLKHI would be
628 * set to 0.5*(f_sys/f_i2c)-2=0.5*(20e6/100e3)-2=98. The actual value
629 * programmed into CLKHI will vary from this slightly due to
630 * variations in the output pad's rise and fall times as well as
631 * the deglitching filter length.
634 tmp
= ((freq
/ 1000) / I2C_PNX_SPEED_KHZ
) / 2 - 2;
635 iowrite32(tmp
, I2C_REG_CKH(alg_data
));
636 iowrite32(tmp
, I2C_REG_CKL(alg_data
));
638 iowrite32(mcntrl_reset
, I2C_REG_CTL(alg_data
));
639 if (wait_reset(I2C_PNX_TIMEOUT
, alg_data
)) {
643 init_completion(&alg_data
->mif
.complete
);
645 ret
= request_irq(i2c_pnx
->irq
, i2c_pnx_interrupt
,
646 0, pdev
->name
, alg_data
);
650 /* Register this adapter with the I2C subsystem */
651 ret
= i2c_add_numbered_adapter(&alg_data
->adapter
);
653 dev_err(&pdev
->dev
, "I2C: Failed to add bus\n");
657 dev_dbg(&pdev
->dev
, "%s: Master at %#8x, irq %d.\n",
658 alg_data
->adapter
.name
, i2c_pnx
->base
, i2c_pnx
->irq
);
663 free_irq(i2c_pnx
->irq
, alg_data
);
665 clk_disable(alg_data
->clk
);
667 iounmap(alg_data
->ioaddr
);
669 release_mem_region(i2c_pnx
->base
, I2C_PNX_REGION_SIZE
);
671 clk_put(alg_data
->clk
);
675 platform_set_drvdata(pdev
, NULL
);
680 static int __devexit
i2c_pnx_remove(struct platform_device
*pdev
)
682 struct i2c_pnx_algo_data
*alg_data
= platform_get_drvdata(pdev
);
683 struct i2c_pnx_data
*i2c_pnx
= alg_data
->i2c_pnx
;
685 free_irq(i2c_pnx
->irq
, alg_data
);
686 i2c_del_adapter(&alg_data
->adapter
);
687 clk_disable(alg_data
->clk
);
688 iounmap(alg_data
->ioaddr
);
689 release_mem_region(i2c_pnx
->base
, I2C_PNX_REGION_SIZE
);
690 clk_put(alg_data
->clk
);
692 platform_set_drvdata(pdev
, NULL
);
697 static struct platform_driver i2c_pnx_driver
= {
700 .owner
= THIS_MODULE
,
702 .probe
= i2c_pnx_probe
,
703 .remove
= __devexit_p(i2c_pnx_remove
),
704 .suspend
= i2c_pnx_controller_suspend
,
705 .resume
= i2c_pnx_controller_resume
,
708 static int __init
i2c_adap_pnx_init(void)
710 return platform_driver_register(&i2c_pnx_driver
);
713 static void __exit
i2c_adap_pnx_exit(void)
715 platform_driver_unregister(&i2c_pnx_driver
);
718 MODULE_AUTHOR("Vitaly Wool, Dennis Kovalev <source@mvista.com>");
719 MODULE_DESCRIPTION("I2C driver for Philips IP3204-based I2C busses");
720 MODULE_LICENSE("GPL");
721 MODULE_ALIAS("platform:pnx-i2c");
723 /* We need to make sure I2C is initialized before USB */
724 subsys_initcall(i2c_adap_pnx_init
);
725 module_exit(i2c_adap_pnx_exit
);