1 /* linux/drivers/i2c/busses/i2c-s3c2410.c
3 * Copyright (C) 2004,2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * S3C2410 I2C Controller
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/kernel.h>
24 #include <linux/module.h>
26 #include <linux/i2c.h>
27 #include <linux/i2c-id.h>
28 #include <linux/init.h>
29 #include <linux/time.h>
30 #include <linux/interrupt.h>
31 #include <linux/delay.h>
32 #include <linux/errno.h>
33 #include <linux/err.h>
34 #include <linux/platform_device.h>
35 #include <linux/clk.h>
36 #include <linux/cpufreq.h>
38 #include <mach/hardware.h>
42 #include <mach/regs-gpio.h>
43 #include <asm/plat-s3c/regs-iic.h>
44 #include <asm/plat-s3c/iic.h>
46 /* i2c controller state */
48 enum s3c24xx_i2c_state {
58 wait_queue_head_t wait;
59 unsigned int suspended:1;
66 unsigned int tx_setup;
68 enum s3c24xx_i2c_state state;
69 unsigned long clkrate;
75 struct resource *ioarea;
76 struct i2c_adapter adap;
78 #ifdef CONFIG_CPU_FREQ
79 struct notifier_block freq_transition;
83 /* default platform data to use if not supplied in the platform_device
86 static struct s3c2410_platform_i2c s3c24xx_i2c_default_platform = {
91 .sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON,
94 /* s3c24xx_i2c_is2440()
96 * return true is this is an s3c2440
99 static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
101 struct platform_device *pdev = to_platform_device(i2c->dev);
103 return !strcmp(pdev->name, "s3c2440-i2c");
107 /* s3c24xx_i2c_get_platformdata
109 * get the platform data associated with the given device, or return
110 * the default if there is none
113 static inline struct s3c2410_platform_i2c *s3c24xx_i2c_get_platformdata(struct device *dev)
115 if (dev->platform_data != NULL)
116 return (struct s3c2410_platform_i2c *)dev->platform_data;
118 return &s3c24xx_i2c_default_platform;
121 /* s3c24xx_i2c_master_complete
123 * complete the message and wake up the caller, using the given return code,
124 * or zero to mean ok.
127 static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret)
129 dev_dbg(i2c->dev, "master_complete %d\n", ret);
141 static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c)
145 tmp = readl(i2c->regs + S3C2410_IICCON);
146 writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);
150 static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c)
154 tmp = readl(i2c->regs + S3C2410_IICCON);
155 writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);
159 /* irq enable/disable functions */
161 static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c)
165 tmp = readl(i2c->regs + S3C2410_IICCON);
166 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
169 static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c)
173 tmp = readl(i2c->regs + S3C2410_IICCON);
174 writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
178 /* s3c24xx_i2c_message_start
180 * put the start of a message onto the bus
183 static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
186 unsigned int addr = (msg->addr & 0x7f) << 1;
188 unsigned long iiccon;
191 stat |= S3C2410_IICSTAT_TXRXEN;
193 if (msg->flags & I2C_M_RD) {
194 stat |= S3C2410_IICSTAT_MASTER_RX;
197 stat |= S3C2410_IICSTAT_MASTER_TX;
199 if (msg->flags & I2C_M_REV_DIR_ADDR)
202 // todo - check for wether ack wanted or not
203 s3c24xx_i2c_enable_ack(i2c);
205 iiccon = readl(i2c->regs + S3C2410_IICCON);
206 writel(stat, i2c->regs + S3C2410_IICSTAT);
208 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr);
209 writeb(addr, i2c->regs + S3C2410_IICDS);
211 /* delay here to ensure the data byte has gotten onto the bus
212 * before the transaction is started */
214 ndelay(i2c->tx_setup);
216 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon);
217 writel(iiccon, i2c->regs + S3C2410_IICCON);
219 stat |= S3C2410_IICSTAT_START;
220 writel(stat, i2c->regs + S3C2410_IICSTAT);
223 static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret)
225 unsigned long iicstat = readl(i2c->regs + S3C2410_IICSTAT);
227 dev_dbg(i2c->dev, "STOP\n");
229 /* stop the transfer */
230 iicstat &= ~ S3C2410_IICSTAT_START;
231 writel(iicstat, i2c->regs + S3C2410_IICSTAT);
233 i2c->state = STATE_STOP;
235 s3c24xx_i2c_master_complete(i2c, ret);
236 s3c24xx_i2c_disable_irq(i2c);
239 /* helper functions to determine the current state in the set of
240 * messages we are sending */
244 * returns TRUE if the current message is the last in the set
247 static inline int is_lastmsg(struct s3c24xx_i2c *i2c)
249 return i2c->msg_idx >= (i2c->msg_num - 1);
254 * returns TRUE if we this is the last byte in the current message
257 static inline int is_msglast(struct s3c24xx_i2c *i2c)
259 return i2c->msg_ptr == i2c->msg->len-1;
264 * returns TRUE if we reached the end of the current message
267 static inline int is_msgend(struct s3c24xx_i2c *i2c)
269 return i2c->msg_ptr >= i2c->msg->len;
272 /* i2s_s3c_irq_nextbyte
274 * process an interrupt and work out what to do
277 static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
283 switch (i2c->state) {
286 dev_err(i2c->dev, "%s: called in STATE_IDLE\n", __func__);
291 dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__);
292 s3c24xx_i2c_disable_irq(i2c);
296 /* last thing we did was send a start condition on the
297 * bus, or started a new i2c message
300 if (iicstat & S3C2410_IICSTAT_LASTBIT &&
301 !(i2c->msg->flags & I2C_M_IGNORE_NAK)) {
302 /* ack was not received... */
304 dev_dbg(i2c->dev, "ack was not received\n");
305 s3c24xx_i2c_stop(i2c, -ENXIO);
309 if (i2c->msg->flags & I2C_M_RD)
310 i2c->state = STATE_READ;
312 i2c->state = STATE_WRITE;
314 /* terminate the transfer if there is nothing to do
315 * as this is used by the i2c probe to find devices. */
317 if (is_lastmsg(i2c) && i2c->msg->len == 0) {
318 s3c24xx_i2c_stop(i2c, 0);
322 if (i2c->state == STATE_READ)
325 /* fall through to the write state, as we will need to
326 * send a byte as well */
329 /* we are writing data to the device... check for the
330 * end of the message, and if so, work out what to do
333 if (!(i2c->msg->flags & I2C_M_IGNORE_NAK)) {
334 if (iicstat & S3C2410_IICSTAT_LASTBIT) {
335 dev_dbg(i2c->dev, "WRITE: No Ack\n");
337 s3c24xx_i2c_stop(i2c, -ECONNREFUSED);
344 if (!is_msgend(i2c)) {
345 byte = i2c->msg->buf[i2c->msg_ptr++];
346 writeb(byte, i2c->regs + S3C2410_IICDS);
348 /* delay after writing the byte to allow the
349 * data setup time on the bus, as writing the
350 * data to the register causes the first bit
351 * to appear on SDA, and SCL will change as
352 * soon as the interrupt is acknowledged */
354 ndelay(i2c->tx_setup);
356 } else if (!is_lastmsg(i2c)) {
357 /* we need to go to the next i2c message */
359 dev_dbg(i2c->dev, "WRITE: Next Message\n");
365 /* check to see if we need to do another message */
366 if (i2c->msg->flags & I2C_M_NOSTART) {
368 if (i2c->msg->flags & I2C_M_RD) {
369 /* cannot do this, the controller
370 * forces us to send a new START
371 * when we change direction */
373 s3c24xx_i2c_stop(i2c, -EINVAL);
379 /* send the new start */
380 s3c24xx_i2c_message_start(i2c, i2c->msg);
381 i2c->state = STATE_START;
387 s3c24xx_i2c_stop(i2c, 0);
392 /* we have a byte of data in the data register, do
393 * something with it, and then work out wether we are
394 * going to do any more read/write
397 byte = readb(i2c->regs + S3C2410_IICDS);
398 i2c->msg->buf[i2c->msg_ptr++] = byte;
401 if (is_msglast(i2c)) {
402 /* last byte of buffer */
405 s3c24xx_i2c_disable_ack(i2c);
407 } else if (is_msgend(i2c)) {
408 /* ok, we've read the entire buffer, see if there
409 * is anything else we need to do */
411 if (is_lastmsg(i2c)) {
412 /* last message, send stop and complete */
413 dev_dbg(i2c->dev, "READ: Send Stop\n");
415 s3c24xx_i2c_stop(i2c, 0);
417 /* go to the next transfer */
418 dev_dbg(i2c->dev, "READ: Next Transfer\n");
429 /* acknowlegde the IRQ and get back on with the work */
432 tmp = readl(i2c->regs + S3C2410_IICCON);
433 tmp &= ~S3C2410_IICCON_IRQPEND;
434 writel(tmp, i2c->regs + S3C2410_IICCON);
441 * top level IRQ servicing routine
444 static irqreturn_t s3c24xx_i2c_irq(int irqno, void *dev_id)
446 struct s3c24xx_i2c *i2c = dev_id;
447 unsigned long status;
450 status = readl(i2c->regs + S3C2410_IICSTAT);
452 if (status & S3C2410_IICSTAT_ARBITR) {
453 // deal with arbitration loss
454 dev_err(i2c->dev, "deal with arbitration loss\n");
457 if (i2c->state == STATE_IDLE) {
458 dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n");
460 tmp = readl(i2c->regs + S3C2410_IICCON);
461 tmp &= ~S3C2410_IICCON_IRQPEND;
462 writel(tmp, i2c->regs + S3C2410_IICCON);
466 /* pretty much this leaves us with the fact that we've
467 * transmitted or received whatever byte we last sent */
469 i2s_s3c_irq_nextbyte(i2c, status);
476 /* s3c24xx_i2c_set_master
478 * get the i2c bus for a master transaction
481 static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
483 unsigned long iicstat;
486 while (timeout-- > 0) {
487 iicstat = readl(i2c->regs + S3C2410_IICSTAT);
489 if (!(iicstat & S3C2410_IICSTAT_BUSBUSY))
495 dev_dbg(i2c->dev, "timeout: GPEDAT is %08x\n",
496 __raw_readl(S3C2410_GPEDAT));
501 /* s3c24xx_i2c_doxfer
503 * this starts an i2c transfer
506 static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int num)
508 unsigned long timeout;
514 ret = s3c24xx_i2c_set_master(i2c);
516 dev_err(i2c->dev, "cannot get bus (error %d)\n", ret);
521 spin_lock_irq(&i2c->lock);
527 i2c->state = STATE_START;
529 s3c24xx_i2c_enable_irq(i2c);
530 s3c24xx_i2c_message_start(i2c, msgs);
531 spin_unlock_irq(&i2c->lock);
533 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
537 /* having these next two as dev_err() makes life very
538 * noisy when doing an i2cdetect */
541 dev_dbg(i2c->dev, "timeout\n");
543 dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret);
545 /* ensure the stop has been through the bus */
555 * first port of call from the i2c bus code when an message needs
556 * transferring across the i2c bus.
559 static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
560 struct i2c_msg *msgs, int num)
562 struct s3c24xx_i2c *i2c = (struct s3c24xx_i2c *)adap->algo_data;
566 for (retry = 0; retry < adap->retries; retry++) {
568 ret = s3c24xx_i2c_doxfer(i2c, msgs, num);
573 dev_dbg(i2c->dev, "Retrying transmission (%d)\n", retry);
581 /* declare our i2c functionality */
582 static u32 s3c24xx_i2c_func(struct i2c_adapter *adap)
584 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING;
587 /* i2c bus registration info */
589 static const struct i2c_algorithm s3c24xx_i2c_algorithm = {
590 .master_xfer = s3c24xx_i2c_xfer,
591 .functionality = s3c24xx_i2c_func,
594 static struct s3c24xx_i2c s3c24xx_i2c = {
595 .lock = __SPIN_LOCK_UNLOCKED(s3c24xx_i2c.lock),
596 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s3c24xx_i2c.wait),
599 .name = "s3c2410-i2c",
600 .owner = THIS_MODULE,
601 .algo = &s3c24xx_i2c_algorithm,
603 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
607 /* s3c24xx_i2c_calcdivisor
609 * return the divisor settings for a given frequency
612 static int s3c24xx_i2c_calcdivisor(unsigned long clkin, unsigned int wanted,
613 unsigned int *div1, unsigned int *divs)
615 unsigned int calc_divs = clkin / wanted;
616 unsigned int calc_div1;
618 if (calc_divs > (16*16))
623 calc_divs += calc_div1-1;
624 calc_divs /= calc_div1;
634 return clkin / (calc_divs * calc_div1);
639 * test wether a frequency is within the acceptable range of error
642 static inline int freq_acceptable(unsigned int freq, unsigned int wanted)
644 int diff = freq - wanted;
646 return (diff >= -2 && diff <= 2);
649 /* s3c24xx_i2c_clockrate
651 * work out a divisor for the user requested frequency setting,
652 * either by the requested frequency, or scanning the acceptable
653 * range of frequencies until something is found
656 static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
658 struct s3c2410_platform_i2c *pdata;
659 unsigned long clkin = clk_get_rate(i2c->clk);
660 unsigned int divs, div1;
665 i2c->clkrate = clkin;
667 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent);
668 clkin /= 1000; /* clkin now in KHz */
670 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n",
671 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq);
673 if (pdata->bus_freq != 0) {
674 freq = s3c24xx_i2c_calcdivisor(clkin, pdata->bus_freq/1000,
676 if (freq_acceptable(freq, pdata->bus_freq/1000))
680 /* ok, we may have to search for something suitable... */
682 start = (pdata->max_freq == 0) ? pdata->bus_freq : pdata->max_freq;
683 end = pdata->min_freq;
690 for (; start > end; start--) {
691 freq = s3c24xx_i2c_calcdivisor(clkin, start, &div1, &divs);
692 if (freq_acceptable(freq, start))
696 /* cannot find frequency spec */
703 iiccon = readl(i2c->regs + S3C2410_IICCON);
704 iiccon &= ~(S3C2410_IICCON_SCALEMASK | S3C2410_IICCON_TXDIV_512);
708 iiccon |= S3C2410_IICCON_TXDIV_512;
710 writel(iiccon, i2c->regs + S3C2410_IICCON);
715 #ifdef CONFIG_CPU_FREQ
717 #define freq_to_i2c(_n) container_of(_n, struct s3c24xx_i2c, freq_transition)
719 static int s3c24xx_i2c_cpufreq_transition(struct notifier_block *nb,
720 unsigned long val, void *data)
722 struct s3c24xx_i2c *i2c = freq_to_i2c(nb);
728 delta_f = clk_get_rate(i2c->clk) - i2c->clkrate;
730 /* if we're post-change and the input clock has slowed down
731 * or at pre-change and the clock is about to speed up, then
732 * adjust our clock rate. <0 is slow, >0 speedup.
735 if ((val == CPUFREQ_POSTCHANGE && delta_f < 0) ||
736 (val == CPUFREQ_PRECHANGE && delta_f > 0)) {
737 spin_lock_irqsave(&i2c->lock, flags);
738 ret = s3c24xx_i2c_clockrate(i2c, &got);
739 spin_unlock_irqrestore(&i2c->lock, flags);
742 dev_err(i2c->dev, "cannot find frequency\n");
744 dev_info(i2c->dev, "setting freq %d\n", got);
750 static inline int s3c24xx_i2c_register_cpufreq(struct s3c24xx_i2c *i2c)
752 i2c->freq_transition.notifier_call = s3c24xx_i2c_cpufreq_transition;
754 return cpufreq_register_notifier(&i2c->freq_transition,
755 CPUFREQ_TRANSITION_NOTIFIER);
758 static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c)
760 cpufreq_unregister_notifier(&i2c->freq_transition,
761 CPUFREQ_TRANSITION_NOTIFIER);
765 static inline int s3c24xx_i2c_register_cpufreq(struct s3c24xx_i2c *i2c)
770 static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c)
777 * initialise the controller, set the IO lines and frequency
780 static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
782 unsigned long iicon = S3C2410_IICCON_IRQEN | S3C2410_IICCON_ACKEN;
783 struct s3c2410_platform_i2c *pdata;
786 /* get the plafrom data */
788 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent);
790 /* inititalise the gpio */
792 s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_IICSDA);
793 s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_IICSCL);
795 /* write slave address */
797 writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD);
799 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr);
801 writel(iicon, i2c->regs + S3C2410_IICCON);
803 /* we need to work out the divisors for the clock... */
805 if (s3c24xx_i2c_clockrate(i2c, &freq) != 0) {
806 writel(0, i2c->regs + S3C2410_IICCON);
807 dev_err(i2c->dev, "cannot meet bus frequency required\n");
811 /* todo - check that the i2c lines aren't being dragged anywhere */
813 dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq);
814 dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02lx\n", iicon);
816 /* check for s3c2440 i2c controller */
818 if (s3c24xx_i2c_is2440(i2c)) {
819 dev_dbg(i2c->dev, "S3C2440_IICLC=%08x\n", pdata->sda_delay);
821 writel(pdata->sda_delay, i2c->regs + S3C2440_IICLC);
829 * called by the bus driver when a suitable device is found
832 static int s3c24xx_i2c_probe(struct platform_device *pdev)
834 struct s3c24xx_i2c *i2c = &s3c24xx_i2c;
835 struct s3c2410_platform_i2c *pdata;
836 struct resource *res;
839 pdata = s3c24xx_i2c_get_platformdata(&pdev->dev);
841 /* find the clock and enable it */
843 i2c->dev = &pdev->dev;
844 i2c->clk = clk_get(&pdev->dev, "i2c");
845 if (IS_ERR(i2c->clk)) {
846 dev_err(&pdev->dev, "cannot get clock\n");
851 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
853 clk_enable(i2c->clk);
855 /* map the registers */
857 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
859 dev_err(&pdev->dev, "cannot find IO resource\n");
864 i2c->ioarea = request_mem_region(res->start, (res->end-res->start)+1,
867 if (i2c->ioarea == NULL) {
868 dev_err(&pdev->dev, "cannot request IO\n");
873 i2c->regs = ioremap(res->start, (res->end-res->start)+1);
875 if (i2c->regs == NULL) {
876 dev_err(&pdev->dev, "cannot map IO\n");
881 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res);
883 /* setup info block for the i2c core */
885 i2c->adap.algo_data = i2c;
886 i2c->adap.dev.parent = &pdev->dev;
888 /* initialise the i2c controller */
890 ret = s3c24xx_i2c_init(i2c);
894 /* find the IRQ for this unit (note, this relies on the init call to
895 * ensure no current IRQs pending
898 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
900 dev_err(&pdev->dev, "cannot find IRQ\n");
905 ret = request_irq(res->start, s3c24xx_i2c_irq, IRQF_DISABLED,
909 dev_err(&pdev->dev, "cannot claim IRQ\n");
915 dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res,
916 (unsigned long)res->start);
918 ret = s3c24xx_i2c_register_cpufreq(i2c);
920 dev_err(&pdev->dev, "failed to register cpufreq notifier\n");
924 /* Note, previous versions of the driver used i2c_add_adapter()
925 * to add the bus at any number. We now pass the bus number via
926 * the platform data, so if unset it will now default to always
930 i2c->adap.nr = pdata->bus_num;
932 ret = i2c_add_numbered_adapter(&i2c->adap);
934 dev_err(&pdev->dev, "failed to add bus to i2c core\n");
938 platform_set_drvdata(pdev, i2c);
940 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id);
944 s3c24xx_i2c_deregister_cpufreq(i2c);
947 free_irq(i2c->irq->start, i2c);
953 release_resource(i2c->ioarea);
957 clk_disable(i2c->clk);
964 /* s3c24xx_i2c_remove
966 * called when device is removed from the bus
969 static int s3c24xx_i2c_remove(struct platform_device *pdev)
971 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
973 s3c24xx_i2c_deregister_cpufreq(i2c);
975 i2c_del_adapter(&i2c->adap);
976 free_irq(i2c->irq->start, i2c);
978 clk_disable(i2c->clk);
983 release_resource(i2c->ioarea);
990 static int s3c24xx_i2c_suspend_late(struct platform_device *dev,
993 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
998 static int s3c24xx_i2c_resume(struct platform_device *dev)
1000 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
1003 s3c24xx_i2c_init(i2c);
1009 #define s3c24xx_i2c_suspend_late NULL
1010 #define s3c24xx_i2c_resume NULL
1013 /* device driver for platform bus bits */
1015 static struct platform_driver s3c2410_i2c_driver = {
1016 .probe = s3c24xx_i2c_probe,
1017 .remove = s3c24xx_i2c_remove,
1018 .suspend_late = s3c24xx_i2c_suspend_late,
1019 .resume = s3c24xx_i2c_resume,
1021 .owner = THIS_MODULE,
1022 .name = "s3c2410-i2c",
1026 static struct platform_driver s3c2440_i2c_driver = {
1027 .probe = s3c24xx_i2c_probe,
1028 .remove = s3c24xx_i2c_remove,
1029 .suspend_late = s3c24xx_i2c_suspend_late,
1030 .resume = s3c24xx_i2c_resume,
1032 .owner = THIS_MODULE,
1033 .name = "s3c2440-i2c",
1037 static int __init i2c_adap_s3c_init(void)
1041 ret = platform_driver_register(&s3c2410_i2c_driver);
1043 ret = platform_driver_register(&s3c2440_i2c_driver);
1045 platform_driver_unregister(&s3c2410_i2c_driver);
1051 static void __exit i2c_adap_s3c_exit(void)
1053 platform_driver_unregister(&s3c2410_i2c_driver);
1054 platform_driver_unregister(&s3c2440_i2c_driver);
1057 module_init(i2c_adap_s3c_init);
1058 module_exit(i2c_adap_s3c_exit);
1060 MODULE_DESCRIPTION("S3C24XX I2C Bus driver");
1061 MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
1062 MODULE_LICENSE("GPL");
1063 MODULE_ALIAS("platform:s3c2410-i2c");
1064 MODULE_ALIAS("platform:s3c2440-i2c");