4 * I2C adapter for the PXA I2C bus access.
6 * Copyright (C) 2002 Intrinsyc Software Inc.
7 * Copyright (C) 2004-2005 Deep Blue Solutions Ltd.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 * Apr 2002: Initial version [CS]
15 * Jun 2002: Properly seperated algo/adap [FB]
16 * Jan 2003: Fixed several bugs concerning interrupt handling [Kai-Uwe Bloem]
17 * Jan 2003: added limited signal handling [Kai-Uwe Bloem]
18 * Sep 2004: Major rework to ensure efficient bus handling [RMK]
19 * Dec 2004: Added support for PXA27x and slave device probing [Liam Girdwood]
20 * Feb 2005: Rework slave mode handling [RMK]
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/i2c.h>
25 #include <linux/i2c-id.h>
26 #include <linux/init.h>
27 #include <linux/time.h>
28 #include <linux/sched.h>
29 #include <linux/delay.h>
30 #include <linux/errno.h>
31 #include <linux/interrupt.h>
32 #include <linux/i2c-pxa.h>
34 #include <asm/hardware.h>
36 #include <asm/arch/i2c.h>
37 #include <asm/arch/pxa-regs.h>
41 wait_queue_head_t wait;
46 unsigned int slave_addr;
48 struct i2c_adapter adap;
49 #ifdef CONFIG_I2C_PXA_SLAVE
50 struct i2c_slave_client *slave;
53 unsigned int irqlogidx;
59 * I2C Slave mode address
61 #define I2C_PXA_SLAVE_ADDR 0x1
70 #define BIT(m, s, u) { .mask = m, .set = s, .unset = u }
73 decode_bits(const char *prefix, const struct bits *bits, int num, u32 val)
75 printk("%s %08x: ", prefix, val);
77 const char *str = val & bits->mask ? bits->set : bits->unset;
84 static const struct bits isr_bits[] = {
85 BIT(ISR_RWM, "RX", "TX"),
86 BIT(ISR_ACKNAK, "NAK", "ACK"),
87 BIT(ISR_UB, "Bsy", "Rdy"),
88 BIT(ISR_IBB, "BusBsy", "BusRdy"),
89 BIT(ISR_SSD, "SlaveStop", NULL),
90 BIT(ISR_ALD, "ALD", NULL),
91 BIT(ISR_ITE, "TxEmpty", NULL),
92 BIT(ISR_IRF, "RxFull", NULL),
93 BIT(ISR_GCAD, "GenCall", NULL),
94 BIT(ISR_SAD, "SlaveAddr", NULL),
95 BIT(ISR_BED, "BusErr", NULL),
98 static void decode_ISR(unsigned int val)
100 decode_bits(KERN_DEBUG "ISR", isr_bits, ARRAY_SIZE(isr_bits), val);
104 static const struct bits icr_bits[] = {
105 BIT(ICR_START, "START", NULL),
106 BIT(ICR_STOP, "STOP", NULL),
107 BIT(ICR_ACKNAK, "ACKNAK", NULL),
108 BIT(ICR_TB, "TB", NULL),
109 BIT(ICR_MA, "MA", NULL),
110 BIT(ICR_SCLE, "SCLE", "scle"),
111 BIT(ICR_IUE, "IUE", "iue"),
112 BIT(ICR_GCD, "GCD", NULL),
113 BIT(ICR_ITEIE, "ITEIE", NULL),
114 BIT(ICR_IRFIE, "IRFIE", NULL),
115 BIT(ICR_BEIE, "BEIE", NULL),
116 BIT(ICR_SSDIE, "SSDIE", NULL),
117 BIT(ICR_ALDIE, "ALDIE", NULL),
118 BIT(ICR_SADIE, "SADIE", NULL),
119 BIT(ICR_UR, "UR", "ur"),
122 static void decode_ICR(unsigned int val)
124 decode_bits(KERN_DEBUG "ICR", icr_bits, ARRAY_SIZE(icr_bits), val);
128 static unsigned int i2c_debug = DEBUG;
130 static void i2c_pxa_show_state(struct pxa_i2c *i2c, int lno, const char *fname)
132 dev_dbg(&i2c->adap.dev, "state:%s:%d: ISR=%08x, ICR=%08x, IBMR=%02x\n", fname, lno, ISR, ICR, IBMR);
135 #define show_state(i2c) i2c_pxa_show_state(i2c, __LINE__, __FUNCTION__)
139 #define show_state(i2c) do { } while (0)
140 #define decode_ISR(val) do { } while (0)
141 #define decode_ICR(val) do { } while (0)
144 #define eedbg(lvl, x...) do { if ((lvl) < 1) { printk(KERN_DEBUG "" x); } } while(0)
146 static void i2c_pxa_master_complete(struct pxa_i2c *i2c, int ret);
148 static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why)
151 printk("i2c: error: %s\n", why);
152 printk("i2c: msg_num: %d msg_idx: %d msg_ptr: %d\n",
153 i2c->msg_num, i2c->msg_idx, i2c->msg_ptr);
154 printk("i2c: ICR: %08x ISR: %08x\n"
155 "i2c: log: ", ICR, ISR);
156 for (i = 0; i < i2c->irqlogidx; i++)
157 printk("[%08x:%08x] ", i2c->isrlog[i], i2c->icrlog[i]);
161 static inline int i2c_pxa_is_slavemode(struct pxa_i2c *i2c)
163 return !(ICR & ICR_SCLE);
166 static void i2c_pxa_abort(struct pxa_i2c *i2c)
168 unsigned long timeout = jiffies + HZ/4;
170 if (i2c_pxa_is_slavemode(i2c)) {
171 dev_dbg(&i2c->adap.dev, "%s: called in slave mode\n", __func__);
175 while (time_before(jiffies, timeout) && (IBMR & 0x1) == 0) {
176 unsigned long icr = ICR;
179 icr |= ICR_ACKNAK | ICR_STOP | ICR_TB;
188 ICR &= ~(ICR_MA | ICR_START | ICR_STOP);
191 static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
193 int timeout = DEF_TIMEOUT;
195 while (timeout-- && ISR & (ISR_IBB | ISR_UB)) {
196 if ((ISR & ISR_SAD) != 0)
206 return timeout <= 0 ? I2C_RETRY : 0;
209 static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
211 unsigned long timeout = jiffies + HZ*4;
213 while (time_before(jiffies, timeout)) {
215 dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n",
216 __func__, (long)jiffies, ISR, ICR, IBMR);
220 dev_dbg(&i2c->adap.dev, "%s: Slave detected\n", __func__);
224 /* wait for unit and bus being not busy, and we also do a
225 * quick check of the i2c lines themselves to ensure they've
228 if ((ISR & (ISR_UB | ISR_IBB)) == 0 && IBMR == 3) {
230 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__);
238 dev_dbg(&i2c->adap.dev, "%s: did not free\n", __func__);
243 static int i2c_pxa_set_master(struct pxa_i2c *i2c)
246 dev_dbg(&i2c->adap.dev, "setting to bus master\n");
248 if ((ISR & (ISR_UB | ISR_IBB)) != 0) {
249 dev_dbg(&i2c->adap.dev, "%s: unit is busy\n", __func__);
250 if (!i2c_pxa_wait_master(i2c)) {
251 dev_dbg(&i2c->adap.dev, "%s: error: unit busy\n", __func__);
260 #ifdef CONFIG_I2C_PXA_SLAVE
261 static int i2c_pxa_wait_slave(struct pxa_i2c *i2c)
263 unsigned long timeout = jiffies + HZ*1;
269 while (time_before(jiffies, timeout)) {
271 dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n",
272 __func__, (long)jiffies, ISR, ICR, IBMR);
274 if ((ISR & (ISR_UB|ISR_IBB|ISR_SAD)) == ISR_SAD ||
275 (ICR & ICR_SCLE) == 0) {
277 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__);
285 dev_dbg(&i2c->adap.dev, "%s: did not free\n", __func__);
290 * clear the hold on the bus, and take of anything else
291 * that has been configured
293 static void i2c_pxa_set_slave(struct pxa_i2c *i2c, int errcode)
298 udelay(100); /* simple delay */
300 /* we need to wait for the stop condition to end */
302 /* if we where in stop, then clear... */
303 if (ICR & ICR_STOP) {
308 if (!i2c_pxa_wait_slave(i2c)) {
309 dev_err(&i2c->adap.dev, "%s: wait timedout\n",
315 ICR &= ~(ICR_STOP|ICR_ACKNAK|ICR_MA);
319 dev_dbg(&i2c->adap.dev, "ICR now %08x, ISR %08x\n", ICR, ISR);
324 #define i2c_pxa_set_slave(i2c, err) do { } while (0)
327 static void i2c_pxa_reset(struct pxa_i2c *i2c)
329 pr_debug("Resetting I2C Controller Unit\n");
331 /* abort any transfer currently under way */
334 /* reset according to 9.8 */
339 ISAR = i2c->slave_addr;
341 /* set control register values */
344 #ifdef CONFIG_I2C_PXA_SLAVE
345 dev_info(&i2c->adap.dev, "Enabling slave mode\n");
346 ICR |= ICR_SADIE | ICR_ALDIE | ICR_SSDIE;
349 i2c_pxa_set_slave(i2c, 0);
357 #ifdef CONFIG_I2C_PXA_SLAVE
359 * I2C EEPROM emulation.
361 static struct i2c_eeprom_emu eeprom = {
362 .size = I2C_EEPROM_EMU_SIZE,
363 .watch = LIST_HEAD_INIT(eeprom.watch),
366 struct i2c_eeprom_emu *i2c_pxa_get_eeprom(void)
371 int i2c_eeprom_emu_addwatcher(struct i2c_eeprom_emu *emu, void *data,
372 unsigned int addr, unsigned int size,
373 struct i2c_eeprom_emu_watcher *watcher)
375 struct i2c_eeprom_emu_watch *watch;
378 if (addr + size > emu->size)
381 watch = kmalloc(sizeof(struct i2c_eeprom_emu_watch), GFP_KERNEL);
384 watch->end = addr + size - 1;
385 watch->ops = watcher;
388 local_irq_save(flags);
389 list_add(&watch->node, &emu->watch);
390 local_irq_restore(flags);
393 return watch ? 0 : -ENOMEM;
396 void i2c_eeprom_emu_delwatcher(struct i2c_eeprom_emu *emu, void *data,
397 struct i2c_eeprom_emu_watcher *watcher)
399 struct i2c_eeprom_emu_watch *watch, *n;
402 list_for_each_entry_safe(watch, n, &emu->watch, node) {
403 if (watch->ops == watcher && watch->data == data) {
404 local_irq_save(flags);
405 list_del(&watch->node);
406 local_irq_restore(flags);
412 static void i2c_eeprom_emu_event(void *ptr, i2c_slave_event_t event)
414 struct i2c_eeprom_emu *emu = ptr;
416 eedbg(3, "i2c_eeprom_emu_event: %d\n", event);
419 case I2C_SLAVE_EVENT_START_WRITE:
421 eedbg(2, "i2c_eeprom: write initiated\n");
424 case I2C_SLAVE_EVENT_START_READ:
426 eedbg(2, "i2c_eeprom: read initiated\n");
429 case I2C_SLAVE_EVENT_STOP:
431 eedbg(2, "i2c_eeprom: received stop\n");
435 eedbg(0, "i2c_eeprom: unhandled event\n");
440 static int i2c_eeprom_emu_read(void *ptr)
442 struct i2c_eeprom_emu *emu = ptr;
445 ret = emu->bytes[emu->ptr];
446 emu->ptr = (emu->ptr + 1) % emu->size;
451 static void i2c_eeprom_emu_write(void *ptr, unsigned int val)
453 struct i2c_eeprom_emu *emu = ptr;
454 struct i2c_eeprom_emu_watch *watch;
456 if (emu->seen_start != 0) {
457 eedbg(2, "i2c_eeprom_emu_write: setting ptr %02x\n", val);
463 emu->bytes[emu->ptr] = val;
465 eedbg(1, "i2c_eeprom_emu_write: ptr=0x%02x, val=0x%02x\n",
468 list_for_each_entry(watch, &emu->watch, node) {
469 if (!watch->ops || !watch->ops->write)
471 if (watch->start <= emu->ptr && watch->end >= emu->ptr)
472 watch->ops->write(watch->data, emu->ptr, val);
475 emu->ptr = (emu->ptr + 1) % emu->size;
478 struct i2c_slave_client eeprom_client = {
480 .event = i2c_eeprom_emu_event,
481 .read = i2c_eeprom_emu_read,
482 .write = i2c_eeprom_emu_write
489 static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr)
492 /* what should we do here? */
494 int ret = i2c->slave->read(i2c->slave->data);
497 ICR |= ICR_TB; /* allow next byte */
501 static void i2c_pxa_slave_rxfull(struct pxa_i2c *i2c, u32 isr)
503 unsigned int byte = IDBR;
505 if (i2c->slave != NULL)
506 i2c->slave->write(i2c->slave->data, byte);
511 static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr)
516 dev_dbg(&i2c->adap.dev, "SAD, mode is slave-%cx\n",
517 (isr & ISR_RWM) ? 'r' : 't');
519 if (i2c->slave != NULL)
520 i2c->slave->event(i2c->slave->data,
521 (isr & ISR_RWM) ? I2C_SLAVE_EVENT_START_READ : I2C_SLAVE_EVENT_START_WRITE);
524 * slave could interrupt in the middle of us generating a
525 * start condition... if this happens, we'd better back off
526 * and stop holding the poor thing up
528 ICR &= ~(ICR_START|ICR_STOP);
540 dev_err(&i2c->adap.dev, "timeout waiting for SCL high\n");
548 static void i2c_pxa_slave_stop(struct pxa_i2c *i2c)
551 dev_dbg(&i2c->adap.dev, "ISR: SSD (Slave Stop)\n");
553 if (i2c->slave != NULL)
554 i2c->slave->event(i2c->slave->data, I2C_SLAVE_EVENT_STOP);
557 dev_dbg(&i2c->adap.dev, "ISR: SSD (Slave Stop) acked\n");
560 * If we have a master-mode message waiting,
561 * kick it off now that the slave has completed.
564 i2c_pxa_master_complete(i2c, I2C_RETRY);
567 static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr)
570 /* what should we do here? */
577 static void i2c_pxa_slave_rxfull(struct pxa_i2c *i2c, u32 isr)
579 ICR |= ICR_TB | ICR_ACKNAK;
582 static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr)
587 * slave could interrupt in the middle of us generating a
588 * start condition... if this happens, we'd better back off
589 * and stop holding the poor thing up
591 ICR &= ~(ICR_START|ICR_STOP);
592 ICR |= ICR_TB | ICR_ACKNAK;
603 dev_err(&i2c->adap.dev, "timeout waiting for SCL high\n");
611 static void i2c_pxa_slave_stop(struct pxa_i2c *i2c)
614 i2c_pxa_master_complete(i2c, I2C_RETRY);
619 * PXA I2C Master mode
622 static inline unsigned int i2c_pxa_addr_byte(struct i2c_msg *msg)
624 unsigned int addr = (msg->addr & 0x7f) << 1;
626 if (msg->flags & I2C_M_RD)
632 static inline void i2c_pxa_start_message(struct pxa_i2c *i2c)
637 * Step 1: target slave address into IDBR
639 IDBR = i2c_pxa_addr_byte(i2c->msg);
642 * Step 2: initiate the write.
644 icr = ICR & ~(ICR_STOP | ICR_ALDIE);
645 ICR = icr | ICR_START | ICR_TB;
649 * We are protected by the adapter bus semaphore.
651 static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
657 * Wait for the bus to become free.
659 ret = i2c_pxa_wait_bus_not_busy(i2c);
661 dev_err(&i2c->adap.dev, "i2c_pxa: timeout waiting for bus free\n");
668 ret = i2c_pxa_set_master(i2c);
670 dev_err(&i2c->adap.dev, "i2c_pxa_set_master: error %d\n", ret);
674 spin_lock_irq(&i2c->lock);
682 i2c_pxa_start_message(i2c);
684 spin_unlock_irq(&i2c->lock);
687 * The rest of the processing occurs in the interrupt handler.
689 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
692 * We place the return code in i2c->msg_idx.
697 i2c_pxa_scream_blue_murder(i2c, "timeout");
704 * i2c_pxa_master_complete - complete the message and wake up.
706 static void i2c_pxa_master_complete(struct pxa_i2c *i2c, int ret)
717 static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr)
719 u32 icr = ICR & ~(ICR_START|ICR_STOP|ICR_ACKNAK|ICR_TB);
723 * If ISR_ALD is set, we lost arbitration.
727 * Do we need to do anything here? The PXA docs
728 * are vague about what happens.
730 i2c_pxa_scream_blue_murder(i2c, "ALD set");
733 * We ignore this error. We seem to see spurious ALDs
734 * for seemingly no reason. If we handle them as I think
735 * they should, we end up causing an I2C error, which
736 * is painful for some systems.
745 * I2C bus error - either the device NAK'd us, or
746 * something more serious happened. If we were NAK'd
747 * on the initial address phase, we can retry.
749 if (isr & ISR_ACKNAK) {
750 if (i2c->msg_ptr == 0 && i2c->msg_idx == 0)
755 i2c_pxa_master_complete(i2c, ret);
756 } else if (isr & ISR_RWM) {
758 * Read mode. We have just sent the address byte, and
759 * now we must initiate the transfer.
761 if (i2c->msg_ptr == i2c->msg->len - 1 &&
762 i2c->msg_idx == i2c->msg_num - 1)
763 icr |= ICR_STOP | ICR_ACKNAK;
765 icr |= ICR_ALDIE | ICR_TB;
766 } else if (i2c->msg_ptr < i2c->msg->len) {
768 * Write mode. Write the next data byte.
770 IDBR = i2c->msg->buf[i2c->msg_ptr++];
772 icr |= ICR_ALDIE | ICR_TB;
775 * If this is the last byte of the last message, send
778 if (i2c->msg_ptr == i2c->msg->len &&
779 i2c->msg_idx == i2c->msg_num - 1)
781 } else if (i2c->msg_idx < i2c->msg_num - 1) {
783 * Next segment of the message.
790 * If we aren't doing a repeated start and address,
791 * go back and try to send the next byte. Note that
792 * we do not support switching the R/W direction here.
794 if (i2c->msg->flags & I2C_M_NOSTART)
798 * Write the next address.
800 IDBR = i2c_pxa_addr_byte(i2c->msg);
803 * And trigger a repeated start, and send the byte.
806 icr |= ICR_START | ICR_TB;
808 if (i2c->msg->len == 0) {
810 * Device probes have a message length of zero
811 * and need the bus to be reset before it can
816 i2c_pxa_master_complete(i2c, 0);
819 i2c->icrlog[i2c->irqlogidx-1] = icr;
825 static void i2c_pxa_irq_rxfull(struct pxa_i2c *i2c, u32 isr)
827 u32 icr = ICR & ~(ICR_START|ICR_STOP|ICR_ACKNAK|ICR_TB);
832 i2c->msg->buf[i2c->msg_ptr++] = IDBR;
834 if (i2c->msg_ptr < i2c->msg->len) {
836 * If this is the last byte of the last
837 * message, send a STOP.
839 if (i2c->msg_ptr == i2c->msg->len - 1)
840 icr |= ICR_STOP | ICR_ACKNAK;
842 icr |= ICR_ALDIE | ICR_TB;
844 i2c_pxa_master_complete(i2c, 0);
847 i2c->icrlog[i2c->irqlogidx-1] = icr;
852 static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id, struct pt_regs *regs)
854 struct pxa_i2c *i2c = dev_id;
857 if (i2c_debug > 2 && 0) {
858 dev_dbg(&i2c->adap.dev, "%s: ISR=%08x, ICR=%08x, IBMR=%02x\n",
859 __func__, isr, ICR, IBMR);
863 if (i2c->irqlogidx < sizeof(i2c->isrlog)/sizeof(u32))
864 i2c->isrlog[i2c->irqlogidx++] = isr;
869 * Always clear all pending IRQs.
871 ISR = isr & (ISR_SSD|ISR_ALD|ISR_ITE|ISR_IRF|ISR_SAD|ISR_BED);
874 i2c_pxa_slave_start(i2c, isr);
876 i2c_pxa_slave_stop(i2c);
878 if (i2c_pxa_is_slavemode(i2c)) {
880 i2c_pxa_slave_txempty(i2c, isr);
882 i2c_pxa_slave_rxfull(i2c, isr);
883 } else if (i2c->msg) {
885 i2c_pxa_irq_txempty(i2c, isr);
887 i2c_pxa_irq_rxfull(i2c, isr);
889 i2c_pxa_scream_blue_murder(i2c, "spurious irq");
896 static int i2c_pxa_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
898 struct pxa_i2c *i2c = adap->algo_data;
901 for (i = adap->retries; i >= 0; i--) {
902 ret = i2c_pxa_do_xfer(i2c, msgs, num);
903 if (ret != I2C_RETRY)
907 dev_dbg(&adap->dev, "Retrying transmission\n");
910 i2c_pxa_scream_blue_murder(i2c, "exhausted retries");
913 i2c_pxa_set_slave(i2c, ret);
917 static u32 i2c_pxa_functionality(struct i2c_adapter *adap)
919 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
922 static struct i2c_algorithm i2c_pxa_algorithm = {
923 .master_xfer = i2c_pxa_xfer,
924 .functionality = i2c_pxa_functionality,
927 static struct pxa_i2c i2c_pxa = {
928 .lock = SPIN_LOCK_UNLOCKED,
929 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(i2c_pxa.wait),
931 .owner = THIS_MODULE,
932 .algo = &i2c_pxa_algorithm,
933 .name = "pxa2xx-i2c",
938 static int i2c_pxa_probe(struct device *dev)
940 struct pxa_i2c *i2c = &i2c_pxa;
941 struct i2c_pxa_platform_data *plat = dev->platform_data;
945 pxa_gpio_mode(GPIO117_I2CSCL_MD);
946 pxa_gpio_mode(GPIO118_I2CSDA_MD);
950 i2c->slave_addr = I2C_PXA_SLAVE_ADDR;
952 #ifdef CONFIG_I2C_PXA_SLAVE
953 i2c->slave = &eeprom_client;
955 i2c->slave_addr = plat->slave_addr;
957 i2c->slave = plat->slave;
961 pxa_set_cken(CKEN14_I2C, 1);
962 ret = request_irq(IRQ_I2C, i2c_pxa_handler, SA_INTERRUPT,
969 i2c->adap.algo_data = i2c;
970 i2c->adap.dev.parent = dev;
972 ret = i2c_add_adapter(&i2c->adap);
974 printk(KERN_INFO "I2C: Failed to add bus\n");
978 dev_set_drvdata(dev, i2c);
980 #ifdef CONFIG_I2C_PXA_SLAVE
981 printk(KERN_INFO "I2C: %s: PXA I2C adapter, slave address %d\n",
982 i2c->adap.dev.bus_id, i2c->slave_addr);
984 printk(KERN_INFO "I2C: %s: PXA I2C adapter\n",
985 i2c->adap.dev.bus_id);
990 free_irq(IRQ_I2C, i2c);
995 static int i2c_pxa_remove(struct device *dev)
997 struct pxa_i2c *i2c = dev_get_drvdata(dev);
999 dev_set_drvdata(dev, NULL);
1001 i2c_del_adapter(&i2c->adap);
1002 free_irq(IRQ_I2C, i2c);
1003 pxa_set_cken(CKEN14_I2C, 0);
1008 static struct device_driver i2c_pxa_driver = {
1009 .name = "pxa2xx-i2c",
1010 .bus = &platform_bus_type,
1011 .probe = i2c_pxa_probe,
1012 .remove = i2c_pxa_remove,
1015 static int __init i2c_adap_pxa_init(void)
1017 return driver_register(&i2c_pxa_driver);
1020 static void i2c_adap_pxa_exit(void)
1022 return driver_unregister(&i2c_pxa_driver);
1025 module_init(i2c_adap_pxa_init);
1026 module_exit(i2c_adap_pxa_exit);