1 --- a/drivers/i2c/busses/Makefile
2 +++ b/drivers/i2c/busses/Makefile
4 obj-$(CONFIG_I2C_STUB) += i2c-stub.o
5 obj-$(CONFIG_SCx200_ACB) += scx200_acb.o
6 obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o
7 +obj-$(CONFIG_I2C_FALCON) += i2c-falcon.o
9 ifeq ($(CONFIG_I2C_DEBUG_BUS),y)
10 EXTRA_CFLAGS += -DDEBUG
11 --- a/drivers/i2c/busses/Kconfig
12 +++ b/drivers/i2c/busses/Kconfig
15 comment "I2C system bus drivers (mostly embedded / system-on-chip)"
18 + tristate "Falcon I2C interface"
19 +# depends on SOC_FALCON
22 tristate "Atmel AT91 I2C Two-Wire interface (TWI)"
23 depends on ARCH_AT91 && EXPERIMENTAL && BROKEN
25 +++ b/drivers/i2c/busses/i2c-falcon.c
28 + * This program is free software; you can redistribute it and/or modify
29 + * it under the terms of the GNU General Public License as published by
30 + * the Free Software Foundation; either version 2 of the License, or
31 + * (at your option) any later version.
33 + * This program is distributed in the hope that it will be useful,
34 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
35 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 + * GNU General Public License for more details.
38 + * You should have received a copy of the GNU General Public License
39 + * along with this program; if not, write to the Free Software
40 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
45 +#include <linux/module.h>
46 +#include <linux/ioport.h>
47 +#include <linux/init.h>
48 +#include <linux/platform_device.h>
49 +#include <linux/i2c.h>
50 +#include <linux/interrupt.h>
51 +#include <linux/spinlock.h>
52 +#include <linux/io.h>
53 +#include <linux/clk.h>
54 +#include <linux/err.h>
55 +#include <linux/slab.h>
58 + * - no high speed support
59 + * - rx issue with "address mode" & "tx end" interrupts
60 + * - ten bit mode is not tested
63 +/* mapping for access macros */
64 +#define reg_r32(reg) __raw_readl(reg)
65 +#define reg_w32(val, reg) __raw_writel(val, reg)
66 +#define reg_w32_mask(clear, set, reg) \
67 + reg_w32((reg_r32(reg) & ~(clear)) | (set), reg)
68 +#define reg_r32_table(reg, idx) reg_r32(&((uint32_t *)®)[idx])
69 +#define reg_w32_table(val, reg, idx) reg_w32(val, &((uint32_t *)®)[idx])
70 +#define i2c (priv->membase)
71 +#include <falcon/i2c_reg.h>
73 +/* enable hacks to overcome current issue */
74 +#define FALCON_FIX_ME
76 +#define FALCON_I2C_ADDR 0x00
77 +#define FALCON_I2C_READY_TIMEOUT 1000
78 +#define FALCON_I2C_WAIT_TIMEOUT 10
80 +#define DRV_NAME "i2c-falcon"
83 +#define static /* no static functions for better debugging */
86 +#define FALCON_I2C_ARB_LOST (1 << 0)
87 +#define FALCON_I2C_NACK (1 << 1)
88 +#define FALCON_I2C_RX_UFL (1 << 2)
89 +#define FALCON_I2C_RX_OFL (1 << 3)
90 +#define FALCON_I2C_TX_UFL (1 << 4)
91 +#define FALCON_I2C_TX_OFL (1 << 5)
92 +#define FALCON_I2C_BURST_REQ (1 << 6)
93 +#define FALCON_I2C_RX (1 << 7)
94 +#define FALCON_I2C_TX_END (1 << 8)
95 +#define FALCON_I2C_ADDR_MATCH (1 << 9) /* doesn't trigger */
101 + FALCON_I2C_MODE_100 = 1,
102 + FALCON_I2C_MODE_400 = 2,
103 + FALCON_I2C_MODE_3400 = 3
104 + } mode; /* current speed mode */
106 + int ten_bit; /* current address mode */
107 + unsigned long status; /* bus events holder */
108 + struct clk *clk; /* clock input for i2c hardware block */
109 + struct gpon_reg_i2c __iomem *membase; /* base of mapped registers */
110 + int irq_lb, irq_b, irq_err, irq_p; /* last burst, burst, error,
112 + struct completion done;
113 + struct i2c_adapter adap;
114 + struct device *dev;
117 +#define FALCON_I2C_ERROR_MASK (FALCON_I2C_NACK \
118 + | FALCON_I2C_ARB_LOST \
119 + | FALCON_I2C_RX_OFL \
120 + | FALCON_I2C_RX_UFL \
121 + | FALCON_I2C_TX_OFL \
122 + | FALCON_I2C_TX_UFL)
124 +#define FALCON_I2C_ERROR(priv) (priv->status & FALCON_I2C_ERROR_MASK)
125 +#define FALCON_I2C_ERROR_CLEAR(priv) do { \
127 + ~FALCON_I2C_ERROR_MASK; \
130 +static void falcon_addr_configure(struct falcon_i2c *priv, int ten_bit)
132 + u32 ten_bit_mask = ten_bit ? I2C_ADDR_CFG_TBAM_10bit : 0;
134 + /* configure address */
135 + i2c_w32(I2C_ADDR_CFG_SOPE_EN /* generate stop when no more data in the
137 + | I2C_ADDR_CFG_SONA_EN /* generate stop when NA received */
138 + | I2C_ADDR_CFG_MnS_EN /* we are master device */
140 + | FALCON_I2C_ADDR, /* our address */
144 +static irqreturn_t falcon_i2c_isr(int irq, void *dev_id)
146 + u32 i_raw, i_pro, i_err;
147 + struct falcon_i2c *priv = dev_id;
148 + unsigned long flags;
149 + unsigned int old_status;
151 + spin_lock_irqsave(&priv->lock, flags);
153 + old_status = (unsigned int)priv->status;
155 + i_raw = i2c_r32(mis);
157 + /* protocol interrupt */
158 + if (i_raw & I2C_RIS_I2C_P_INT_INTOCC) {
159 + i_pro = i2c_r32(p_irqss);
161 + /* tx -> rx switch */
162 + if (i_pro & I2C_P_IRQSS_RX)
163 + priv->status |= FALCON_I2C_RX;
166 + if (i_pro & I2C_P_IRQSS_TX_END)
167 + priv->status |= FALCON_I2C_TX_END;
169 + /* not acknowledge */
170 + if (i_pro & I2C_P_IRQSS_NACK)
171 + priv->status |= FALCON_I2C_NACK;
173 + /* arbitration lost */
174 + if (i_pro & I2C_P_IRQSS_AL)
175 + priv->status |= FALCON_I2C_ARB_LOST;
177 + /* address match */
178 + if (i_pro & I2C_P_IRQSS_AM)
179 + priv->status |= FALCON_I2C_ADDR_MATCH;
181 + i2c_w32(i_pro, p_irqsc);
184 + /* error interrupt */
185 + if (i_raw & I2C_RIS_I2C_ERR_INT_INTOCC) {
186 + i_err = i2c_r32(err_irqss);
188 + /* tx fifo overflow */
189 + if (i_err & I2C_ERR_IRQSS_TXF_OFL)
190 + priv->status |= FALCON_I2C_TX_OFL;
192 + /* tx fifo underflow */
193 + if (i_err & I2C_ERR_IRQSS_TXF_UFL)
194 + priv->status |= FALCON_I2C_TX_UFL;
196 + /* rx fifo overflow */
197 + if (i_err & I2C_ERR_IRQSS_RXF_OFL)
198 + priv->status |= FALCON_I2C_RX_OFL;
200 + /* rx fifo underflow */
201 + if (i_err & I2C_ERR_IRQSS_RXF_UFL)
202 + priv->status |= FALCON_I2C_RX_UFL;
204 + i2c_w32(i_err, err_irqsc);
207 + /* burst request */
208 + if (i_raw & I2C_RIS_BREQ_INT_INTOCC) {
209 + i2c_w32_mask(I2C_IMSC_BREQ_INT_EN, 0, imsc);
210 + i2c_w32_mask(0, I2C_ICR_BREQ_INT_CLR, icr);
212 + priv->status |= FALCON_I2C_BURST_REQ;
215 + /* last burst request */
216 + if (i_raw & I2C_RIS_LBREQ_INT_INTOCC) {
217 + i2c_w32_mask(I2C_IMSC_LBREQ_INT_EN, 0, imsc);
218 + i2c_w32_mask(0, I2C_ICR_LBREQ_INT_CLR, icr);
220 + priv->status |= FALCON_I2C_BURST_REQ;
223 + if (old_status != (unsigned int)priv->status)
224 + complete(&priv->done);
226 + spin_unlock_irqrestore(&priv->lock, flags);
228 + return IRQ_HANDLED;
231 +static int falcon_i2c_ready(struct falcon_i2c *priv)
235 + unsigned long flags;
238 + for (timeout = 0; timeout < FALCON_I2C_READY_TIMEOUT; timeout++) {
239 + bus_stat = i2c_r32(bus_stat);
241 + if (bus_stat & I2C_BUS_STAT_BS_SC) {
244 + spin_lock_irqsave(&priv->lock, flags);
246 + if (FALCON_I2C_ERROR(priv)) {
247 + ret = priv->status;
249 + dev_dbg(priv->dev, "bus ready wait error 0x%08lx\n", priv->status);
251 + FALCON_I2C_ERROR_CLEAR(priv);
256 + spin_unlock_irqrestore(&priv->lock, flags);
262 + dev_dbg(priv->dev, "bus ready wait timeout\n");
267 +static int falcon_i2c_wait(struct falcon_i2c *priv, unsigned long status)
270 + unsigned long flags;
271 + unsigned int timeout;
273 + spin_lock_irqsave(&priv->lock, flags);
275 + priv->status &= FALCON_I2C_BURST_REQ;
277 + /* check if the event already occurred */
278 + if ((priv->status & status) == status) {
279 + priv->status &= ~status;
280 + spin_unlock_irqrestore(&priv->lock, flags);
285 + spin_unlock_irqrestore(&priv->lock, flags);
287 + /* unmask burst interrupts */
288 + i2c_w32_mask(0, I2C_IMSC_LBREQ_INT_EN | I2C_IMSC_BREQ_INT_EN, imsc);
290 + for (timeout = 0; timeout < FALCON_I2C_WAIT_TIMEOUT; timeout++) {
291 + /* wait for the data request */
292 + wait_for_completion_timeout(&priv->done, HZ / 10);
294 + /* handle errors */
295 + spin_lock_irqsave(&priv->lock, flags);
297 + if (FALCON_I2C_ERROR(priv)) {
298 + dev_dbg(priv->dev, "wait error 0x%08lx (waiting for 0x%08lx)\n",
302 + if (priv->status & FALCON_I2C_NACK)
307 + FALCON_I2C_ERROR_CLEAR(priv);
309 + if ((priv->status & status) == status) {
310 + priv->status &= ~status;
311 + spin_unlock_irqrestore(&priv->lock, flags);
317 + spin_unlock_irqrestore(&priv->lock, flags);
323 + dev_dbg(priv->dev, "wait timeout error 0x%08lx (waiting for 0x%08lx)\n",
330 +static int falcon_i2c_tx(struct falcon_i2c *priv, int ten_bit, u16 addr,
336 + dev_dbg(priv->dev, "%s\n", __func__);
338 + /* tell fifo the number of bytes we are going to send */
339 + i2c_w32(len + (ten_bit ? 2 : 1), tps_ctrl);
341 + /* wait for the data request */
342 + ret = falcon_i2c_wait(priv, FALCON_I2C_BURST_REQ);
346 + /* send slave address */
348 + i2c_w32(0x78 | ((addr >> 7) & 0x7), txd);
349 + i2c_w32(0x78 | ((addr & 0x7f) << 1) | 0, txd);
351 + i2c_w32((addr << 1) | 0, txd);
355 + for (i = 0; i < len; i++) {
356 + ret = falcon_i2c_wait(priv, FALCON_I2C_BURST_REQ);
360 + i2c_w32(buf[i], txd);
363 + return falcon_i2c_wait(priv, FALCON_I2C_TX_END);
366 +static int falcon_i2c_rx(struct falcon_i2c *priv, int ten_bit, u16 addr,
372 + dev_dbg(priv->dev, "%s\n", __func__);
374 + /* we need to transmit address only */
375 + i2c_w32(ten_bit ? 2 : 1, tps_ctrl);
377 + /* set maximum received packet size */
378 + i2c_w32(len, mrps_ctrl);
380 + /* wait for the data request */
381 + ret = falcon_i2c_wait(priv, FALCON_I2C_BURST_REQ);
385 + /* write down the address */
387 + i2c_w32(0x78 | ((addr >> 7) & 0x7), txd);
388 + i2c_w32(0x78 | ((addr & 0x7f) << 1) | 1, txd);
390 + i2c_w32((addr << 1) | 1, txd);
393 + /* wait for the read request */
394 + ret = falcon_i2c_wait(priv, FALCON_I2C_TX_END
395 +#ifndef FALCON_FIX_ME
396 + | FALCON_I2C_ADDR_MATCH
404 + for (i = 0; i < len; i++) {
405 +#ifdef FALCON_FIX_ME
406 + while (i2c_r32(rps_stat) == 0)
409 + ret = falcon_i2c_wait(priv, FALCON_I2C_BURST_REQ);
415 + buf[i] = i2c_r32(rxd);
418 +#ifndef FALCON_FIX_ME
419 + /* wait for transmission end */
420 + return falcon_i2c_wait(priv, FALCON_I2C_TX_END);
426 +static int falcon_i2c_xfer_msg(struct falcon_i2c *priv, struct i2c_msg *msg)
430 + unsigned long flags;
432 + dev_dbg(priv->dev, "%s %u byte(s) %s 0x%02x\n",
433 + (msg->flags & I2C_M_RD) ? "read" : "write", msg->len,
434 + (msg->flags & I2C_M_RD) ? "from" : "to", msg->addr);
436 + if (msg->flags & I2C_M_TEN)
441 + /* reconfigure bus if need to send message in different address mode */
442 + spin_lock_irqsave(&priv->lock, flags);
443 + if (ten_bit != priv->ten_bit) {
446 + i2c_w32_mask(I2C_RUN_CTRL_RUN_EN, 0, run_ctrl);
448 + /* reconfigure address */
449 + falcon_addr_configure(priv, ten_bit);
452 + i2c_w32_mask(0, I2C_RUN_CTRL_RUN_EN, run_ctrl);
454 + priv->ten_bit = ten_bit;
456 + spin_unlock_irqrestore(&priv->lock, flags);
458 + /* read/write actual message */
459 + if (msg->flags & I2C_M_RD)
460 + ret = falcon_i2c_rx(priv, ten_bit, msg->addr, msg->buf,
463 + ret = falcon_i2c_tx(priv, ten_bit, msg->addr, msg->buf,
472 +static int falcon_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
477 + unsigned long flags;
478 + struct falcon_i2c *priv = i2c_get_adapdata(adap);
480 + dev_dbg(priv->dev, "xfer %u messages\n", num);
482 + /* transfer each message */
483 + for (i = 0; i < num; i++) {
484 +#ifdef FALCON_FIX_ME
486 + i2c_w32_mask(I2C_RUN_CTRL_RUN_EN, 0, run_ctrl);
488 + i2c_w32_mask(0, I2C_RUN_CTRL_RUN_EN, run_ctrl);
491 + /* clear bus status */
492 + spin_lock_irqsave(&priv->lock, flags);
494 + spin_unlock_irqrestore(&priv->lock, flags);
496 + /* wait for the bus to become ready */
497 + ret = falcon_i2c_ready(priv);
501 + /* transfer message */
502 + ret = falcon_i2c_xfer_msg(priv, &msg[i]);
507 + /* check for unhandled errors */
508 + spin_lock_irqsave(&priv->lock, flags);
509 + if (FALCON_I2C_ERROR(priv))
510 + ret = priv->status;
511 + spin_unlock_irqrestore(&priv->lock, flags);
514 + dev_warn(priv->dev, "message %u unhandled error 0x%x\n",
524 +static u32 falcon_i2c_func(struct i2c_adapter *adap)
526 + return I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR | I2C_FUNC_SMBUS_EMUL;
529 +static struct i2c_algorithm falcon_i2c_algorithm = {
530 + .master_xfer = falcon_i2c_xfer,
531 + .functionality = falcon_i2c_func,
534 +static int falcon_i2c_hw_init(struct i2c_adapter *adap)
536 + struct falcon_i2c *priv = i2c_get_adapdata(adap);
539 + i2c_w32_mask(I2C_RUN_CTRL_RUN_EN, 0, run_ctrl);
541 + /* set normal operation clock divider */
542 + i2c_w32(1 << I2C_CLC_RMC_OFFSET, clc);
544 + /* set frequency */
545 + if (priv->mode == FALCON_I2C_MODE_100) {
546 + dev_dbg(priv->dev, "set standard mode (100 kHz)\n");
548 + i2c_w32(0, fdiv_high_cfg);
550 + i2c_w32((1 << I2C_FDIV_CFG_INC_OFFSET)
551 + | (499 << I2C_FDIV_CFG_DEC_OFFSET),
553 + } else if (priv->mode == FALCON_I2C_MODE_400) {
554 + dev_dbg(priv->dev, "set fast mode (400 kHz)\n");
556 + i2c_w32(0, fdiv_high_cfg);
558 + i2c_w32((1 << I2C_FDIV_CFG_INC_OFFSET)
559 + | (124 << I2C_FDIV_CFG_DEC_OFFSET),
561 + } else if (priv->mode == FALCON_I2C_MODE_3400) {
562 + dev_dbg(priv->dev, "set high mode (3.4 MHz)\n");
564 + i2c_w32(0, fdiv_cfg);
566 + /* TODO recalculate value for 100MHz input */
567 + i2c_w32((41 << I2C_FDIV_CFG_INC_OFFSET)
568 + | (152 << I2C_FDIV_CFG_DEC_OFFSET),
571 + dev_warn(priv->dev, "unknown mode\n");
576 + /* configure fifo */
577 + i2c_w32(I2C_FIFO_CFG_TXFC /* tx fifo as flow controller */
578 + | I2C_FIFO_CFG_RXFC /* rx fifo as flow controller */
579 + | I2C_FIFO_CFG_TXFA_TXFA2 /* tx fifo 4-byte aligned */
580 + | I2C_FIFO_CFG_RXFA_RXFA2 /* rx fifo 4-byte aligned */
581 + | I2C_FIFO_CFG_TXBS_TXBS0 /* tx fifo burst size is 1 word */
582 + | I2C_FIFO_CFG_RXBS_RXBS0, /* rx fifo burst size is 1 word */
585 + /* configure address */
586 + falcon_addr_configure(priv, priv->ten_bit);
589 + i2c_w32_mask(0, I2C_RUN_CTRL_RUN_EN, run_ctrl);
591 + /* mask burst interrupts */
592 + i2c_w32_mask(I2C_IMSC_LBREQ_INT_EN | I2C_IMSC_BREQ_INT_EN, 0, imsc);
594 + /* enable interrupts */
595 + i2c_w32(I2C_IMSC_LBREQ_INT_EN
596 + | I2C_IMSC_BREQ_INT_EN
597 + | I2C_IMSC_I2C_P_INT_EN
598 + | I2C_IMSC_I2C_ERR_INT_EN,
604 +static int __devinit falcon_i2c_probe(struct platform_device *pdev)
607 + struct falcon_i2c *priv;
608 + struct i2c_adapter *adap;
609 + struct resource *mmres, *ioarea,
610 + *irqres_lb, *irqres_b, *irqres_err, *irqres_p;
613 + dev_dbg(&pdev->dev, "probing\n");
615 + mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
616 + irqres_lb = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
618 + irqres_b = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "i2c_b");
619 + irqres_err = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
621 + irqres_p = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "i2c_p");
623 + if (!mmres || !irqres_lb || !irqres_b || !irqres_err || !irqres_p) {
624 + dev_err(&pdev->dev, "no resources\n");
628 + clk = clk_get(&pdev->dev, "fpi");
630 + dev_err(&pdev->dev, "failed to get fpi clk\n");
634 + if (clk_get_rate(clk) != 100000000) {
635 + dev_err(&pdev->dev, "input clock is not 100MHz\n");
639 + /* allocate private data */
640 + priv = kzalloc(sizeof(*priv), GFP_KERNEL);
642 + dev_err(&pdev->dev, "can't allocate private data\n");
646 + adap = &priv->adap;
647 + i2c_set_adapdata(adap, priv);
648 + adap->owner = THIS_MODULE;
649 + adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
650 + strlcpy(adap->name, DRV_NAME "-adapter", sizeof(adap->name));
651 + adap->algo = &falcon_i2c_algorithm;
654 + priv->mode = FALCON_I2C_MODE_100;
656 + priv->dev = &pdev->dev;
658 + spin_lock_init(&priv->lock);
660 + ioarea = request_mem_region(mmres->start, resource_size(mmres),
663 + if (ioarea == NULL) {
664 + dev_err(&pdev->dev, "I2C region already claimed\n");
666 + goto err_free_priv;
670 + priv->membase = ioremap_nocache(mmres->start & ~KSEG1,
671 + resource_size(mmres));
672 + if (priv->membase == NULL) {
674 + goto err_release_region;
677 + priv->irq_lb = irqres_lb->start;
678 + ret = request_irq(priv->irq_lb, falcon_i2c_isr, IRQF_DISABLED,
679 + irqres_lb->name, priv);
681 + dev_err(&pdev->dev, "can't get last burst IRQ %d\n", irqres_lb->start);
683 + goto err_unmap_mem;
686 + priv->irq_b = irqres_b->start;
687 + ret = request_irq(priv->irq_b, falcon_i2c_isr, IRQF_DISABLED,
688 + irqres_b->name, priv);
690 + dev_err(&pdev->dev, "can't get burst IRQ %d\n", irqres_b->start);
692 + goto err_free_lb_irq;
695 + priv->irq_err = irqres_err->start;
696 + ret = request_irq(priv->irq_err, falcon_i2c_isr, IRQF_DISABLED,
697 + irqres_err->name, priv);
699 + dev_err(&pdev->dev, "can't get error IRQ %d\n", irqres_err->start);
701 + goto err_free_b_irq;
704 + priv->irq_p = irqres_p->start;
705 + ret = request_irq(priv->irq_p, falcon_i2c_isr, IRQF_DISABLED,
706 + irqres_p->name, priv);
708 + dev_err(&pdev->dev, "can't get protocol IRQ %d\n", irqres_p->start);
710 + goto err_free_err_irq;
713 + dev_dbg(&pdev->dev, "mapped io-space to %p\n", priv->membase);
714 + dev_dbg(&pdev->dev, "use IRQs %d, %d, %d, %d\n", irqres_lb->start,
715 + irqres_b->start, irqres_err->start, irqres_p->start);
717 + /* add our adapter to the i2c stack */
718 + ret = i2c_add_numbered_adapter(adap);
720 + dev_err(&pdev->dev, "can't register I2C adapter\n");
721 + goto err_free_p_irq;
724 + platform_set_drvdata(pdev, priv);
725 + i2c_set_adapdata(adap, priv);
727 + /* print module version information */
728 + dev_dbg(&pdev->dev, "module id=%u revision=%u\n",
729 + (i2c_r32(id) & I2C_ID_ID_MASK) >> I2C_ID_ID_OFFSET,
730 + (i2c_r32(id) & I2C_ID_REV_MASK) >> I2C_ID_REV_OFFSET);
732 + init_completion(&priv->done);
734 + /* initialize HW */
735 + ret = falcon_i2c_hw_init(adap);
737 + dev_err(&pdev->dev, "can't configure adapter\n");
738 + goto err_remove_adapter;
744 + i2c_del_adapter(adap);
745 + platform_set_drvdata(pdev, NULL);
748 + free_irq(priv->irq_p, priv);
751 + free_irq(priv->irq_err, priv);
754 + free_irq(priv->irq_b, priv);
757 + free_irq(priv->irq_lb, priv);
760 + iounmap(priv->membase);
763 + release_mem_region(mmres->start, resource_size(mmres));
771 +static int __devexit falcon_i2c_remove(struct platform_device *pdev)
773 + struct falcon_i2c *priv = platform_get_drvdata(pdev);
774 + struct resource *mmres;
777 + i2c_w32_mask(I2C_RUN_CTRL_RUN_EN, 0, run_ctrl);
779 + /* remove driver */
780 + platform_set_drvdata(pdev, NULL);
781 + i2c_del_adapter(&priv->adap);
783 + free_irq(priv->irq_lb, priv);
784 + free_irq(priv->irq_b, priv);
785 + free_irq(priv->irq_err, priv);
786 + free_irq(priv->irq_p, priv);
790 + mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
791 + release_mem_region(mmres->start, resource_size(mmres));
793 + dev_dbg(&pdev->dev, "removed\n");
798 +static struct platform_driver falcon_i2c_driver = {
799 + .probe = falcon_i2c_probe,
800 + .remove = __devexit_p(falcon_i2c_remove),
803 + .owner = THIS_MODULE,
807 +static int __init falcon_i2c_init(void)
811 + ret = platform_driver_register(&falcon_i2c_driver);
814 + printk(KERN_DEBUG DRV_NAME ": can't register platform driver");
819 +static void __exit falcon_i2c_exit(void)
821 + platform_driver_unregister(&falcon_i2c_driver);
824 +module_init(falcon_i2c_init);
825 +module_exit(falcon_i2c_exit);
827 +MODULE_DESCRIPTION("Lantiq FALC(tm) ON - I2C bus adapter");
828 +MODULE_ALIAS("platform:i2c_falcon");
829 +MODULE_LICENSE("GPL");