Commit 217bcec4 authored by Stefan Roese's avatar Stefan Roese Committed by Jean Delvare

i2c-ibm_iic: Whitespace cleanup

Signed-off-by: default avatarStefan Roese <sr@denx.de>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent ccf60d85
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright (c) 2003, 2004 Zultys Technologies. * Copyright (c) 2003, 2004 Zultys Technologies.
* Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
* *
* Based on original work by * Based on original work by
* Ian DaSilva <idasilva@mvista.com> * Ian DaSilva <idasilva@mvista.com>
* Armin Kuster <akuster@mvista.com> * Armin Kuster <akuster@mvista.com>
* Matt Porter <mporter@mvista.com> * Matt Porter <mporter@mvista.com>
...@@ -86,8 +86,8 @@ static void dump_iic_regs(const char* header, struct ibm_iic_private* dev) ...@@ -86,8 +86,8 @@ static void dump_iic_regs(const char* header, struct ibm_iic_private* dev)
KERN_DEBUG " sts = 0x%02x, extsts = 0x%02x\n" KERN_DEBUG " sts = 0x%02x, extsts = 0x%02x\n"
KERN_DEBUG " clkdiv = 0x%02x, xfrcnt = 0x%02x\n" KERN_DEBUG " clkdiv = 0x%02x, xfrcnt = 0x%02x\n"
KERN_DEBUG " xtcntlss = 0x%02x, directcntl = 0x%02x\n", KERN_DEBUG " xtcntlss = 0x%02x, directcntl = 0x%02x\n",
in_8(&iic->cntl), in_8(&iic->mdcntl), in_8(&iic->sts), in_8(&iic->cntl), in_8(&iic->mdcntl), in_8(&iic->sts),
in_8(&iic->extsts), in_8(&iic->clkdiv), in_8(&iic->xfrcnt), in_8(&iic->extsts), in_8(&iic->clkdiv), in_8(&iic->xfrcnt),
in_8(&iic->xtcntlss), in_8(&iic->directcntl)); in_8(&iic->xtcntlss), in_8(&iic->directcntl));
} }
# define DUMP_REGS(h,dev) dump_iic_regs((h),(dev)) # define DUMP_REGS(h,dev) dump_iic_regs((h),(dev))
...@@ -125,7 +125,7 @@ static inline void iic_interrupt_mode(struct ibm_iic_private* dev, int enable) ...@@ -125,7 +125,7 @@ static inline void iic_interrupt_mode(struct ibm_iic_private* dev, int enable)
{ {
out_8(&dev->vaddr->intmsk, enable ? INTRMSK_EIMTC : 0); out_8(&dev->vaddr->intmsk, enable ? INTRMSK_EIMTC : 0);
} }
/* /*
* Initialize IIC interface. * Initialize IIC interface.
*/ */
...@@ -134,7 +134,7 @@ static void iic_dev_init(struct ibm_iic_private* dev) ...@@ -134,7 +134,7 @@ static void iic_dev_init(struct ibm_iic_private* dev)
volatile struct iic_regs __iomem *iic = dev->vaddr; volatile struct iic_regs __iomem *iic = dev->vaddr;
DBG("%d: init\n", dev->idx); DBG("%d: init\n", dev->idx);
/* Clear master address */ /* Clear master address */
out_8(&iic->lmadr, 0); out_8(&iic->lmadr, 0);
out_8(&iic->hmadr, 0); out_8(&iic->hmadr, 0);
...@@ -160,7 +160,7 @@ static void iic_dev_init(struct ibm_iic_private* dev) ...@@ -160,7 +160,7 @@ static void iic_dev_init(struct ibm_iic_private* dev)
/* Clear control register */ /* Clear control register */
out_8(&iic->cntl, 0); out_8(&iic->cntl, 0);
/* Enable interrupts if possible */ /* Enable interrupts if possible */
iic_interrupt_mode(dev, dev->irq >= 0); iic_interrupt_mode(dev, dev->irq >= 0);
...@@ -171,7 +171,7 @@ static void iic_dev_init(struct ibm_iic_private* dev) ...@@ -171,7 +171,7 @@ static void iic_dev_init(struct ibm_iic_private* dev)
DUMP_REGS("iic_init", dev); DUMP_REGS("iic_init", dev);
} }
/* /*
* Reset IIC interface * Reset IIC interface
*/ */
static void iic_dev_reset(struct ibm_iic_private* dev) static void iic_dev_reset(struct ibm_iic_private* dev)
...@@ -179,42 +179,42 @@ static void iic_dev_reset(struct ibm_iic_private* dev) ...@@ -179,42 +179,42 @@ static void iic_dev_reset(struct ibm_iic_private* dev)
volatile struct iic_regs __iomem *iic = dev->vaddr; volatile struct iic_regs __iomem *iic = dev->vaddr;
int i; int i;
u8 dc; u8 dc;
DBG("%d: soft reset\n", dev->idx); DBG("%d: soft reset\n", dev->idx);
DUMP_REGS("reset", dev); DUMP_REGS("reset", dev);
/* Place chip in the reset state */ /* Place chip in the reset state */
out_8(&iic->xtcntlss, XTCNTLSS_SRST); out_8(&iic->xtcntlss, XTCNTLSS_SRST);
/* Check if bus is free */ /* Check if bus is free */
dc = in_8(&iic->directcntl); dc = in_8(&iic->directcntl);
if (!DIRCTNL_FREE(dc)){ if (!DIRCTNL_FREE(dc)){
DBG("%d: trying to regain bus control\n", dev->idx); DBG("%d: trying to regain bus control\n", dev->idx);
/* Try to set bus free state */ /* Try to set bus free state */
out_8(&iic->directcntl, DIRCNTL_SDAC | DIRCNTL_SCC); out_8(&iic->directcntl, DIRCNTL_SDAC | DIRCNTL_SCC);
/* Wait until we regain bus control */ /* Wait until we regain bus control */
for (i = 0; i < 100; ++i){ for (i = 0; i < 100; ++i){
dc = in_8(&iic->directcntl); dc = in_8(&iic->directcntl);
if (DIRCTNL_FREE(dc)) if (DIRCTNL_FREE(dc))
break; break;
/* Toggle SCL line */ /* Toggle SCL line */
dc ^= DIRCNTL_SCC; dc ^= DIRCNTL_SCC;
out_8(&iic->directcntl, dc); out_8(&iic->directcntl, dc);
udelay(10); udelay(10);
dc ^= DIRCNTL_SCC; dc ^= DIRCNTL_SCC;
out_8(&iic->directcntl, dc); out_8(&iic->directcntl, dc);
/* be nice */ /* be nice */
cond_resched(); cond_resched();
} }
} }
/* Remove reset */ /* Remove reset */
out_8(&iic->xtcntlss, 0); out_8(&iic->xtcntlss, 0);
/* Reinitialize interface */ /* Reinitialize interface */
iic_dev_init(dev); iic_dev_init(dev);
} }
...@@ -324,14 +324,14 @@ static irqreturn_t iic_handler(int irq, void *dev_id) ...@@ -324,14 +324,14 @@ static irqreturn_t iic_handler(int irq, void *dev_id)
{ {
struct ibm_iic_private* dev = (struct ibm_iic_private*)dev_id; struct ibm_iic_private* dev = (struct ibm_iic_private*)dev_id;
volatile struct iic_regs __iomem *iic = dev->vaddr; volatile struct iic_regs __iomem *iic = dev->vaddr;
DBG2("%d: irq handler, STS = 0x%02x, EXTSTS = 0x%02x\n", DBG2("%d: irq handler, STS = 0x%02x, EXTSTS = 0x%02x\n",
dev->idx, in_8(&iic->sts), in_8(&iic->extsts)); dev->idx, in_8(&iic->sts), in_8(&iic->extsts));
/* Acknowledge IRQ and wakeup iic_wait_for_tc */ /* Acknowledge IRQ and wakeup iic_wait_for_tc */
out_8(&iic->sts, STS_IRQA | STS_SCMP); out_8(&iic->sts, STS_IRQA | STS_SCMP);
wake_up_interruptible(&dev->wq); wake_up_interruptible(&dev->wq);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -341,19 +341,19 @@ static irqreturn_t iic_handler(int irq, void *dev_id) ...@@ -341,19 +341,19 @@ static irqreturn_t iic_handler(int irq, void *dev_id)
*/ */
static int iic_xfer_result(struct ibm_iic_private* dev) static int iic_xfer_result(struct ibm_iic_private* dev)
{ {
volatile struct iic_regs __iomem *iic = dev->vaddr; volatile struct iic_regs __iomem *iic = dev->vaddr;
if (unlikely(in_8(&iic->sts) & STS_ERR)){ if (unlikely(in_8(&iic->sts) & STS_ERR)){
DBG("%d: xfer error, EXTSTS = 0x%02x\n", dev->idx, DBG("%d: xfer error, EXTSTS = 0x%02x\n", dev->idx,
in_8(&iic->extsts)); in_8(&iic->extsts));
/* Clear errors and possible pending IRQs */ /* Clear errors and possible pending IRQs */
out_8(&iic->extsts, EXTSTS_IRQP | EXTSTS_IRQD | out_8(&iic->extsts, EXTSTS_IRQP | EXTSTS_IRQD |
EXTSTS_LA | EXTSTS_ICT | EXTSTS_XFRA); EXTSTS_LA | EXTSTS_ICT | EXTSTS_XFRA);
/* Flush master data buffer */ /* Flush master data buffer */
out_8(&iic->mdcntl, in_8(&iic->mdcntl) | MDCNTL_FMDB); out_8(&iic->mdcntl, in_8(&iic->mdcntl) | MDCNTL_FMDB);
/* Is bus free? /* Is bus free?
* If error happened during combined xfer * If error happened during combined xfer
* IIC interface is usually stuck in some strange * IIC interface is usually stuck in some strange
...@@ -376,11 +376,11 @@ static void iic_abort_xfer(struct ibm_iic_private* dev) ...@@ -376,11 +376,11 @@ static void iic_abort_xfer(struct ibm_iic_private* dev)
{ {
volatile struct iic_regs __iomem *iic = dev->vaddr; volatile struct iic_regs __iomem *iic = dev->vaddr;
unsigned long x; unsigned long x;
DBG("%d: iic_abort_xfer\n", dev->idx); DBG("%d: iic_abort_xfer\n", dev->idx);
out_8(&iic->cntl, CNTL_HMT); out_8(&iic->cntl, CNTL_HMT);
/* /*
* Wait for the abort command to complete. * Wait for the abort command to complete.
* It's not worth to be optimized, just poll (timeout >= 1 tick) * It's not worth to be optimized, just poll (timeout >= 1 tick)
...@@ -405,13 +405,13 @@ static void iic_abort_xfer(struct ibm_iic_private* dev) ...@@ -405,13 +405,13 @@ static void iic_abort_xfer(struct ibm_iic_private* dev)
* Returns the number of transferred bytes or error (<0) * Returns the number of transferred bytes or error (<0)
*/ */
static int iic_wait_for_tc(struct ibm_iic_private* dev){ static int iic_wait_for_tc(struct ibm_iic_private* dev){
volatile struct iic_regs __iomem *iic = dev->vaddr; volatile struct iic_regs __iomem *iic = dev->vaddr;
int ret = 0; int ret = 0;
if (dev->irq >= 0){ if (dev->irq >= 0){
/* Interrupt mode */ /* Interrupt mode */
ret = wait_event_interruptible_timeout(dev->wq, ret = wait_event_interruptible_timeout(dev->wq,
!(in_8(&iic->sts) & STS_PT), dev->adap.timeout * HZ); !(in_8(&iic->sts) & STS_PT), dev->adap.timeout * HZ);
if (unlikely(ret < 0)) if (unlikely(ret < 0))
...@@ -424,37 +424,37 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){ ...@@ -424,37 +424,37 @@ static int iic_wait_for_tc(struct ibm_iic_private* dev){
else { else {
/* Polling mode */ /* Polling mode */
unsigned long x = jiffies + dev->adap.timeout * HZ; unsigned long x = jiffies + dev->adap.timeout * HZ;
while (in_8(&iic->sts) & STS_PT){ while (in_8(&iic->sts) & STS_PT){
if (unlikely(time_after(jiffies, x))){ if (unlikely(time_after(jiffies, x))){
DBG("%d: poll timeout\n", dev->idx); DBG("%d: poll timeout\n", dev->idx);
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
break; break;
} }
if (unlikely(signal_pending(current))){ if (unlikely(signal_pending(current))){
DBG("%d: poll interrupted\n", dev->idx); DBG("%d: poll interrupted\n", dev->idx);
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
break; break;
} }
schedule(); schedule();
} }
} }
if (unlikely(ret < 0)) if (unlikely(ret < 0))
iic_abort_xfer(dev); iic_abort_xfer(dev);
else else
ret = iic_xfer_result(dev); ret = iic_xfer_result(dev);
DBG2("%d: iic_wait_for_tc -> %d\n", dev->idx, ret); DBG2("%d: iic_wait_for_tc -> %d\n", dev->idx, ret);
return ret; return ret;
} }
/* /*
* Low level master transfer routine * Low level master transfer routine
*/ */
static int iic_xfer_bytes(struct ibm_iic_private* dev, struct i2c_msg* pm, static int iic_xfer_bytes(struct ibm_iic_private* dev, struct i2c_msg* pm,
int combined_xfer) int combined_xfer)
{ {
volatile struct iic_regs __iomem *iic = dev->vaddr; volatile struct iic_regs __iomem *iic = dev->vaddr;
...@@ -465,48 +465,48 @@ static int iic_xfer_bytes(struct ibm_iic_private* dev, struct i2c_msg* pm, ...@@ -465,48 +465,48 @@ static int iic_xfer_bytes(struct ibm_iic_private* dev, struct i2c_msg* pm,
u8 cntl = (in_8(&iic->cntl) & CNTL_AMD) | CNTL_PT; u8 cntl = (in_8(&iic->cntl) & CNTL_AMD) | CNTL_PT;
if (pm->flags & I2C_M_RD) if (pm->flags & I2C_M_RD)
cntl |= CNTL_RW; cntl |= CNTL_RW;
loops = (len + 3) / 4; loops = (len + 3) / 4;
for (i = 0; i < loops; ++i, len -= 4){ for (i = 0; i < loops; ++i, len -= 4){
int count = len > 4 ? 4 : len; int count = len > 4 ? 4 : len;
u8 cmd = cntl | ((count - 1) << CNTL_TCT_SHIFT); u8 cmd = cntl | ((count - 1) << CNTL_TCT_SHIFT);
if (!(cntl & CNTL_RW)) if (!(cntl & CNTL_RW))
for (j = 0; j < count; ++j) for (j = 0; j < count; ++j)
out_8((void __iomem *)&iic->mdbuf, *buf++); out_8((void __iomem *)&iic->mdbuf, *buf++);
if (i < loops - 1) if (i < loops - 1)
cmd |= CNTL_CHT; cmd |= CNTL_CHT;
else if (combined_xfer) else if (combined_xfer)
cmd |= CNTL_RPST; cmd |= CNTL_RPST;
DBG2("%d: xfer_bytes, %d, CNTL = 0x%02x\n", dev->idx, count, cmd); DBG2("%d: xfer_bytes, %d, CNTL = 0x%02x\n", dev->idx, count, cmd);
/* Start transfer */ /* Start transfer */
out_8(&iic->cntl, cmd); out_8(&iic->cntl, cmd);
/* Wait for completion */ /* Wait for completion */
ret = iic_wait_for_tc(dev); ret = iic_wait_for_tc(dev);
if (unlikely(ret < 0)) if (unlikely(ret < 0))
break; break;
else if (unlikely(ret != count)){ else if (unlikely(ret != count)){
DBG("%d: xfer_bytes, requested %d, transfered %d\n", DBG("%d: xfer_bytes, requested %d, transfered %d\n",
dev->idx, count, ret); dev->idx, count, ret);
/* If it's not a last part of xfer, abort it */ /* If it's not a last part of xfer, abort it */
if (combined_xfer || (i < loops - 1)) if (combined_xfer || (i < loops - 1))
iic_abort_xfer(dev); iic_abort_xfer(dev);
ret = -EREMOTEIO; ret = -EREMOTEIO;
break; break;
} }
if (cntl & CNTL_RW) if (cntl & CNTL_RW)
for (j = 0; j < count; ++j) for (j = 0; j < count; ++j)
*buf++ = in_8((void __iomem *)&iic->mdbuf); *buf++ = in_8((void __iomem *)&iic->mdbuf);
} }
return ret > 0 ? 0 : ret; return ret > 0 ? 0 : ret;
} }
...@@ -517,10 +517,10 @@ static inline void iic_address(struct ibm_iic_private* dev, struct i2c_msg* msg) ...@@ -517,10 +517,10 @@ static inline void iic_address(struct ibm_iic_private* dev, struct i2c_msg* msg)
{ {
volatile struct iic_regs __iomem *iic = dev->vaddr; volatile struct iic_regs __iomem *iic = dev->vaddr;
u16 addr = msg->addr; u16 addr = msg->addr;
DBG2("%d: iic_address, 0x%03x (%d-bit)\n", dev->idx, DBG2("%d: iic_address, 0x%03x (%d-bit)\n", dev->idx,
addr, msg->flags & I2C_M_TEN ? 10 : 7); addr, msg->flags & I2C_M_TEN ? 10 : 7);
if (msg->flags & I2C_M_TEN){ if (msg->flags & I2C_M_TEN){
out_8(&iic->cntl, CNTL_AMD); out_8(&iic->cntl, CNTL_AMD);
out_8(&iic->lmadr, addr); out_8(&iic->lmadr, addr);
...@@ -537,15 +537,15 @@ static inline int iic_invalid_address(const struct i2c_msg* p) ...@@ -537,15 +537,15 @@ static inline int iic_invalid_address(const struct i2c_msg* p)
return (p->addr > 0x3ff) || (!(p->flags & I2C_M_TEN) && (p->addr > 0x7f)); return (p->addr > 0x3ff) || (!(p->flags & I2C_M_TEN) && (p->addr > 0x7f));
} }
static inline int iic_address_neq(const struct i2c_msg* p1, static inline int iic_address_neq(const struct i2c_msg* p1,
const struct i2c_msg* p2) const struct i2c_msg* p2)
{ {
return (p1->addr != p2->addr) return (p1->addr != p2->addr)
|| ((p1->flags & I2C_M_TEN) != (p2->flags & I2C_M_TEN)); || ((p1->flags & I2C_M_TEN) != (p2->flags & I2C_M_TEN));
} }
/* /*
* Generic master transfer entrypoint. * Generic master transfer entrypoint.
* Returns the number of processed messages or error (<0) * Returns the number of processed messages or error (<0)
*/ */
static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
...@@ -553,20 +553,20 @@ static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) ...@@ -553,20 +553,20 @@ static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
struct ibm_iic_private* dev = (struct ibm_iic_private*)(i2c_get_adapdata(adap)); struct ibm_iic_private* dev = (struct ibm_iic_private*)(i2c_get_adapdata(adap));
volatile struct iic_regs __iomem *iic = dev->vaddr; volatile struct iic_regs __iomem *iic = dev->vaddr;
int i, ret = 0; int i, ret = 0;
DBG2("%d: iic_xfer, %d msg(s)\n", dev->idx, num); DBG2("%d: iic_xfer, %d msg(s)\n", dev->idx, num);
if (!num) if (!num)
return 0; return 0;
/* Check the sanity of the passed messages. /* Check the sanity of the passed messages.
* Uhh, generic i2c layer is more suitable place for such code... * Uhh, generic i2c layer is more suitable place for such code...
*/ */
if (unlikely(iic_invalid_address(&msgs[0]))){ if (unlikely(iic_invalid_address(&msgs[0]))){
DBG("%d: invalid address 0x%03x (%d-bit)\n", dev->idx, DBG("%d: invalid address 0x%03x (%d-bit)\n", dev->idx,
msgs[0].addr, msgs[0].flags & I2C_M_TEN ? 10 : 7); msgs[0].addr, msgs[0].flags & I2C_M_TEN ? 10 : 7);
return -EINVAL; return -EINVAL;
} }
for (i = 0; i < num; ++i){ for (i = 0; i < num; ++i){
if (unlikely(msgs[i].len <= 0)){ if (unlikely(msgs[i].len <= 0)){
if (num == 1 && !msgs[0].len){ if (num == 1 && !msgs[0].len){
...@@ -576,7 +576,7 @@ static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) ...@@ -576,7 +576,7 @@ static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
*/ */
return iic_smbus_quick(dev, &msgs[0]); return iic_smbus_quick(dev, &msgs[0]);
} }
DBG("%d: invalid len %d in msg[%d]\n", dev->idx, DBG("%d: invalid len %d in msg[%d]\n", dev->idx,
msgs[i].len, i); msgs[i].len, i);
return -EINVAL; return -EINVAL;
} }
...@@ -585,34 +585,34 @@ static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) ...@@ -585,34 +585,34 @@ static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
return -EINVAL; return -EINVAL;
} }
} }
/* Check bus state */ /* Check bus state */
if (unlikely((in_8(&iic->extsts) & EXTSTS_BCS_MASK) != EXTSTS_BCS_FREE)){ if (unlikely((in_8(&iic->extsts) & EXTSTS_BCS_MASK) != EXTSTS_BCS_FREE)){
DBG("%d: iic_xfer, bus is not free\n", dev->idx); DBG("%d: iic_xfer, bus is not free\n", dev->idx);
/* Usually it means something serious has happend. /* Usually it means something serious has happend.
* We *cannot* have unfinished previous transfer * We *cannot* have unfinished previous transfer
* so it doesn't make any sense to try to stop it. * so it doesn't make any sense to try to stop it.
* Probably we were not able to recover from the * Probably we were not able to recover from the
* previous error. * previous error.
* The only *reasonable* thing I can think of here * The only *reasonable* thing I can think of here
* is soft reset. --ebs * is soft reset. --ebs
*/ */
iic_dev_reset(dev); iic_dev_reset(dev);
if ((in_8(&iic->extsts) & EXTSTS_BCS_MASK) != EXTSTS_BCS_FREE){ if ((in_8(&iic->extsts) & EXTSTS_BCS_MASK) != EXTSTS_BCS_FREE){
DBG("%d: iic_xfer, bus is still not free\n", dev->idx); DBG("%d: iic_xfer, bus is still not free\n", dev->idx);
return -EREMOTEIO; return -EREMOTEIO;
} }
} }
else { else {
/* Flush master data buffer (just in case) */ /* Flush master data buffer (just in case) */
out_8(&iic->mdcntl, in_8(&iic->mdcntl) | MDCNTL_FMDB); out_8(&iic->mdcntl, in_8(&iic->mdcntl) | MDCNTL_FMDB);
} }
/* Load slave address */ /* Load slave address */
iic_address(dev, &msgs[0]); iic_address(dev, &msgs[0]);
/* Do real transfer */ /* Do real transfer */
for (i = 0; i < num && !ret; ++i) for (i = 0; i < num && !ret; ++i)
ret = iic_xfer_bytes(dev, &msgs[i], i < num - 1); ret = iic_xfer_bytes(dev, &msgs[i], i < num - 1);
...@@ -648,7 +648,7 @@ static inline u8 iic_clckdiv(unsigned int opb) ...@@ -648,7 +648,7 @@ static inline u8 iic_clckdiv(unsigned int opb)
/* Convert to MHz */ /* Convert to MHz */
opb /= 1000000; opb /= 1000000;
if (opb < 20 || opb > 150){ if (opb < 20 || opb > 150){
printk(KERN_CRIT "ibm-iic: invalid OPB clock frequency %u MHz\n", printk(KERN_CRIT "ibm-iic: invalid OPB clock frequency %u MHz\n",
opb); opb);
...@@ -666,7 +666,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ ...@@ -666,7 +666,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
struct i2c_adapter* adap; struct i2c_adapter* adap;
struct ocp_func_iic_data* iic_data = ocp->def->additions; struct ocp_func_iic_data* iic_data = ocp->def->additions;
int ret; int ret;
if (!iic_data) if (!iic_data)
printk(KERN_WARNING"ibm-iic%d: missing additional data!\n", printk(KERN_WARNING"ibm-iic%d: missing additional data!\n",
ocp->def->index); ocp->def->index);
...@@ -679,7 +679,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ ...@@ -679,7 +679,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
dev->idx = ocp->def->index; dev->idx = ocp->def->index;
ocp_set_drvdata(ocp, dev); ocp_set_drvdata(ocp, dev);
if (!request_mem_region(ocp->def->paddr, sizeof(struct iic_regs), if (!request_mem_region(ocp->def->paddr, sizeof(struct iic_regs),
"ibm_iic")) { "ibm_iic")) {
ret = -EBUSY; ret = -EBUSY;
...@@ -692,7 +692,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ ...@@ -692,7 +692,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
ret = -ENXIO; ret = -ENXIO;
goto fail2; goto fail2;
} }
init_waitqueue_head(&dev->wq); init_waitqueue_head(&dev->wq);
dev->irq = iic_force_poll ? -1 : ocp->def->irq; dev->irq = iic_force_poll ? -1 : ocp->def->irq;
...@@ -702,29 +702,29 @@ static int __devinit iic_probe(struct ocp_device *ocp){ ...@@ -702,29 +702,29 @@ static int __devinit iic_probe(struct ocp_device *ocp){
*/ */
iic_interrupt_mode(dev, 0); iic_interrupt_mode(dev, 0);
if (request_irq(dev->irq, iic_handler, 0, "IBM IIC", dev)){ if (request_irq(dev->irq, iic_handler, 0, "IBM IIC", dev)){
printk(KERN_ERR "ibm-iic%d: request_irq %d failed\n", printk(KERN_ERR "ibm-iic%d: request_irq %d failed\n",
dev->idx, dev->irq); dev->idx, dev->irq);
/* Fallback to the polling mode */ /* Fallback to the polling mode */
dev->irq = -1; dev->irq = -1;
} }
} }
if (dev->irq < 0) if (dev->irq < 0)
printk(KERN_WARNING "ibm-iic%d: using polling mode\n", printk(KERN_WARNING "ibm-iic%d: using polling mode\n",
dev->idx); dev->idx);
/* Board specific settings */ /* Board specific settings */
dev->fast_mode = iic_force_fast ? 1 : (iic_data ? iic_data->fast_mode : 0); dev->fast_mode = iic_force_fast ? 1 : (iic_data ? iic_data->fast_mode : 0);
/* clckdiv is the same for *all* IIC interfaces, /* clckdiv is the same for *all* IIC interfaces,
* but I'd rather make a copy than introduce another global. --ebs * but I'd rather make a copy than introduce another global. --ebs
*/ */
dev->clckdiv = iic_clckdiv(ocp_sys_info.opb_bus_freq); dev->clckdiv = iic_clckdiv(ocp_sys_info.opb_bus_freq);
DBG("%d: clckdiv = %d\n", dev->idx, dev->clckdiv); DBG("%d: clckdiv = %d\n", dev->idx, dev->clckdiv);
/* Initialize IIC interface */ /* Initialize IIC interface */
iic_dev_init(dev); iic_dev_init(dev);
/* Register it with i2c layer */ /* Register it with i2c layer */
adap = &dev->adap; adap = &dev->adap;
adap->dev.parent = &ocp->dev; adap->dev.parent = &ocp->dev;
...@@ -750,24 +750,24 @@ static int __devinit iic_probe(struct ocp_device *ocp){ ...@@ -750,24 +750,24 @@ static int __devinit iic_probe(struct ocp_device *ocp){
dev->idx); dev->idx);
goto fail; goto fail;
} }
printk(KERN_INFO "ibm-iic%d: using %s mode\n", dev->idx, printk(KERN_INFO "ibm-iic%d: using %s mode\n", dev->idx,
dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)"); dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
return 0; return 0;
fail: fail:
if (dev->irq >= 0){ if (dev->irq >= 0){
iic_interrupt_mode(dev, 0); iic_interrupt_mode(dev, 0);
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
} }
iounmap(dev->vaddr); iounmap(dev->vaddr);
fail2: fail2:
release_mem_region(ocp->def->paddr, sizeof(struct iic_regs)); release_mem_region(ocp->def->paddr, sizeof(struct iic_regs));
fail1: fail1:
ocp_set_drvdata(ocp, NULL); ocp_set_drvdata(ocp, NULL);
kfree(dev); kfree(dev);
return ret; return ret;
} }
...@@ -783,13 +783,13 @@ static void __devexit iic_remove(struct ocp_device *ocp) ...@@ -783,13 +783,13 @@ static void __devexit iic_remove(struct ocp_device *ocp)
dev->idx); dev->idx);
/* That's *very* bad, just shutdown IRQ ... */ /* That's *very* bad, just shutdown IRQ ... */
if (dev->irq >= 0){ if (dev->irq >= 0){
iic_interrupt_mode(dev, 0); iic_interrupt_mode(dev, 0);
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
dev->irq = -1; dev->irq = -1;
} }
} else { } else {
if (dev->irq >= 0){ if (dev->irq >= 0){
iic_interrupt_mode(dev, 0); iic_interrupt_mode(dev, 0);
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
} }
iounmap(dev->vaddr); iounmap(dev->vaddr);
...@@ -798,7 +798,7 @@ static void __devexit iic_remove(struct ocp_device *ocp) ...@@ -798,7 +798,7 @@ static void __devexit iic_remove(struct ocp_device *ocp)
} }
} }
static struct ocp_device_id ibm_iic_ids[] __devinitdata = static struct ocp_device_id ibm_iic_ids[] __devinitdata =
{ {
{ .vendor = OCP_VENDOR_IBM, .function = OCP_FUNC_IIC }, { .vendor = OCP_VENDOR_IBM, .function = OCP_FUNC_IIC },
{ .vendor = OCP_VENDOR_INVALID } { .vendor = OCP_VENDOR_INVALID }
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
* drivers/i2c/busses/i2c-ibm_iic.h * drivers/i2c/busses/i2c-ibm_iic.h
* *
* Support for the IIC peripheral on IBM PPC 4xx * Support for the IIC peripheral on IBM PPC 4xx
* *
* Copyright (c) 2003 Zultys Technologies. * Copyright (c) 2003 Zultys Technologies.
* Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
* *
* Based on original work by * Based on original work by
* Ian DaSilva <idasilva@mvista.com> * Ian DaSilva <idasilva@mvista.com>
* Armin Kuster <akuster@mvista.com> * Armin Kuster <akuster@mvista.com>
* Matt Porter <mporter@mvista.com> * Matt Porter <mporter@mvista.com>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#ifndef __I2C_IBM_IIC_H_ #ifndef __I2C_IBM_IIC_H_
#define __I2C_IBM_IIC_H_ #define __I2C_IBM_IIC_H_
#include <linux/i2c.h> #include <linux/i2c.h>
struct iic_regs { struct iic_regs {
u16 mdbuf; u16 mdbuf;
...@@ -58,7 +58,7 @@ struct ibm_iic_private { ...@@ -58,7 +58,7 @@ struct ibm_iic_private {
#define CNTL_TCT_MASK 0x30 #define CNTL_TCT_MASK 0x30
#define CNTL_TCT_SHIFT 4 #define CNTL_TCT_SHIFT 4
#define CNTL_RPST 0x08 #define CNTL_RPST 0x08
#define CNTL_CHT 0x04 #define CNTL_CHT 0x04
#define CNTL_RW 0x02 #define CNTL_RW 0x02
#define CNTL_PT 0x01 #define CNTL_PT 0x01
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment