Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 272466
b: refs/heads/master
c: 4fd81eb
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Abraham authored and Ben Dooks committed Oct 29, 2011
1 parent f3e091e commit c3644f6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 51 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8abf6fbbd22bc777fd4027cbc55e99cdfb7a8324
refs/heads/master: 4fd81eb2d64295ab038a3ea9d44e0eac85a6648c
89 changes: 43 additions & 46 deletions trunk/drivers/i2c/busses/i2c-nomadik.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@
/* Master controller (MCR) register */
#define I2C_MCR_OP (0x1 << 0) /* Operation */
#define I2C_MCR_A7 (0x7f << 1) /* 7-bit address */
#define I2C_MCR_EA10 (0x7 << 8) /* 10-bit Extended address */
#define I2C_MCR_EA10 (0x7 << 8) /* 10-bit Extended address */
#define I2C_MCR_SB (0x1 << 11) /* Extended address */
#define I2C_MCR_AM (0x3 << 12) /* Address type */
#define I2C_MCR_STOP (0x1 << 14) /* Stop condition */
#define I2C_MCR_LENGTH (0x7ff << 15) /* Transaction length */
#define I2C_MCR_STOP (0x1 << 14) /* Stop condition */
#define I2C_MCR_LENGTH (0x7ff << 15) /* Transaction length */

/* Status register (SR) */
#define I2C_SR_OP (0x3 << 0) /* Operation */
Expand All @@ -77,7 +77,7 @@
#define I2C_SR_LENGTH (0x7ff << 9) /* Transfer length */

/* Interrupt mask set/clear (IMSCR) bits */
#define I2C_IT_TXFE (0x1 << 0)
#define I2C_IT_TXFE (0x1 << 0)
#define I2C_IT_TXFNE (0x1 << 1)
#define I2C_IT_TXFF (0x1 << 2)
#define I2C_IT_TXFOVR (0x1 << 3)
Expand Down Expand Up @@ -135,31 +135,31 @@ struct i2c_nmk_client {
};

/**
* struct nmk_i2c_dev - private data structure of the controller.
* @pdev: parent platform device.
* @adap: corresponding I2C adapter.
* @irq: interrupt line for the controller.
* @virtbase: virtual io memory area.
* @clk: hardware i2c block clock.
* @cfg: machine provided controller configuration.
* @cli: holder of client specific data.
* @stop: stop condition.
* @xfer_complete: acknowledge completion for a I2C message.
* @result: controller propogated result.
* @regulator: pointer to i2c regulator.
* @busy: Busy doing transfer.
* struct nmk_i2c_dev - private data structure of the controller
* @pdev: parent platform device
* @adap: corresponding I2C adapter
* @irq: interrupt line for the controller
* @virtbase: virtual io memory area
* @clk: hardware i2c block clock
* @cfg: machine provided controller configuration
* @cli: holder of client specific data
* @stop: stop condition
* @xfer_complete: acknowledge completion for a I2C message
* @result: controller propogated result
* @regulator: pointer to i2c regulator
* @busy: Busy doing transfer
*/
struct nmk_i2c_dev {
struct platform_device *pdev;
struct i2c_adapter adap;
int irq;
struct i2c_adapter adap;
int irq;
void __iomem *virtbase;
struct clk *clk;
struct nmk_i2c_controller cfg;
struct i2c_nmk_client cli;
int stop;
int stop;
struct completion xfer_complete;
int result;
int result;
struct regulator *regulator;
bool busy;
};
Expand Down Expand Up @@ -217,9 +217,8 @@ static int flush_i2c_fifo(struct nmk_i2c_dev *dev)
}
}

dev_err(&dev->pdev->dev,
"flushing operation timed out giving up after %d attempts",
LOOP_ATTEMPTS);
dev_err(&dev->pdev->dev, "flushing operation timed out "
"giving up after %d attempts", LOOP_ATTEMPTS);

return -ETIMEDOUT;
}
Expand Down Expand Up @@ -271,7 +270,7 @@ static int init_hw(struct nmk_i2c_dev *dev)
}

/* enable peripheral, master mode operation */
#define DEFAULT_I2C_REG_CR ((1 << 1) | I2C_CR_PE)
#define DEFAULT_I2C_REG_CR ((1 << 1) | I2C_CR_PE)

/**
* load_i2c_mcr_reg() - load the MCR register
Expand Down Expand Up @@ -364,8 +363,8 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev)
* and high speed (up to 3.4 Mb/s)
*/
if (dev->cfg.sm > I2C_FREQ_MODE_FAST) {
dev_err(&dev->pdev->dev,
"do not support this mode defaulting to std. mode\n");
dev_err(&dev->pdev->dev, "do not support this mode "
"defaulting to std. mode\n");
brcr2 = i2c_clk/(100000 * 2) & 0xffff;
writel((brcr1 | brcr2), dev->virtbase + I2C_BRCR);
writel(I2C_FREQ_MODE_STANDARD << 4,
Expand Down Expand Up @@ -424,7 +423,7 @@ static int read_i2c(struct nmk_i2c_dev *dev)

if (timeout < 0) {
dev_err(&dev->pdev->dev,
"wait_for_completion_timeout "
"wait_for_completion_timeout"
"returned %d waiting for event\n", timeout);
status = timeout;
}
Expand Down Expand Up @@ -557,8 +556,8 @@ static int nmk_i2c_xfer_one(struct nmk_i2c_dev *dev, u16 flags)
if (((i2c_sr >> 2) & 0x3) == 0x3) {
/* get the abort cause */
cause = (i2c_sr >> 4) & 0x7;
dev_err(&dev->pdev->dev, "%s\n",
cause >= ARRAY_SIZE(abort_causes) ?
dev_err(&dev->pdev->dev, "%s\n", cause
>= ARRAY_SIZE(abort_causes) ?
"unknown reason" :
abort_causes[cause]);
}
Expand All @@ -583,13 +582,13 @@ static int nmk_i2c_xfer_one(struct nmk_i2c_dev *dev, u16 flags)
*
* NOTE:
* READ TRANSFER : We impose a restriction of the first message to be the
* index message for any read transaction.
* - a no index is coded as '0',
* - 2byte big endian index is coded as '3'
* !!! msg[0].buf holds the actual index.
* This is compatible with generic messages of smbus emulator
* that send a one byte index.
* eg. a I2C transation to read 2 bytes from index 0
* index message for any read transaction.
* - a no index is coded as '0',
* - 2byte big endian index is coded as '3'
* !!! msg[0].buf holds the actual index.
* This is compatible with generic messages of smbus emulator
* that send a one byte index.
* eg. a I2C transation to read 2 bytes from index 0
* idx = 0;
* msg[0].addr = client->addr;
* msg[0].flags = 0x0;
Expand Down Expand Up @@ -645,8 +644,8 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,

for (i = 0; i < num_msgs; i++) {
if (unlikely(msgs[i].flags & I2C_M_TEN)) {
dev_err(&dev->pdev->dev,
"10 bit addressing not supported\n");
dev_err(&dev->pdev->dev, "10 bit addressing"
"not supported\n");

status = -EINVAL;
goto out;
Expand Down Expand Up @@ -790,9 +789,8 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg)

if (dev->cli.count) {
dev->result = -EIO;
dev_err(&dev->pdev->dev,
"%lu bytes still remain to be xfered\n",
dev->cli.count);
dev_err(&dev->pdev->dev, "%lu bytes still remain to be"
"xfered\n", dev->cli.count);
(void) init_hw(dev);
}
complete(&dev->xfer_complete);
Expand Down Expand Up @@ -925,7 +923,7 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev)
}

if (request_mem_region(res->start, resource_size(res),
DRIVER_NAME "I/O region") == NULL) {
DRIVER_NAME "I/O region") == NULL) {
ret = -EBUSY;
goto err_no_region;
}
Expand Down Expand Up @@ -982,9 +980,8 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev)

i2c_set_adapdata(adap, dev);

dev_info(&pdev->dev,
"initialize %s on virtual base %p\n",
adap->name, dev->virtbase);
dev_info(&pdev->dev, "initialize %s on virtual "
"base %p\n", adap->name, dev->virtbase);

ret = i2c_add_numbered_adapter(adap);
if (ret) {
Expand Down
18 changes: 14 additions & 4 deletions trunk/drivers/i2c/busses/i2c-s3c2410.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ struct s3c24xx_i2c {
struct resource *ioarea;
struct i2c_adapter adap;

struct s3c2410_platform_i2c *pdata;
#ifdef CONFIG_CPU_FREQ
struct notifier_block freq_transition;
#endif
Expand Down Expand Up @@ -625,7 +626,7 @@ static int s3c24xx_i2c_calcdivisor(unsigned long clkin, unsigned int wanted,

static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
{
struct s3c2410_platform_i2c *pdata = i2c->dev->platform_data;
struct s3c2410_platform_i2c *pdata = i2c->pdata;
unsigned long clkin = clk_get_rate(i2c->clk);
unsigned int divs, div1;
unsigned long target_frequency;
Expand Down Expand Up @@ -754,7 +755,7 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)

/* get the plafrom data */

pdata = i2c->dev->platform_data;
pdata = i2c->pdata;

/* inititalise the gpio */

Expand Down Expand Up @@ -793,7 +794,7 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
static int s3c24xx_i2c_probe(struct platform_device *pdev)
{
struct s3c24xx_i2c *i2c;
struct s3c2410_platform_i2c *pdata;
struct s3c2410_platform_i2c *pdata = NULL;
struct resource *res;
int ret;

Expand All @@ -809,6 +810,15 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
return -ENOMEM;
}

i2c->pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!i2c->pdata) {
ret = -ENOMEM;
goto err_noclk;
}

if (pdata)
memcpy(i2c->pdata, pdata, sizeof(*pdata));

strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name));
i2c->adap.owner = THIS_MODULE;
i2c->adap.algo = &s3c24xx_i2c_algorithm;
Expand Down Expand Up @@ -903,7 +913,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
* being bus 0.
*/

i2c->adap.nr = pdata->bus_num;
i2c->adap.nr = i2c->pdata->bus_num;

ret = i2c_add_numbered_adapter(&i2c->adap);
if (ret < 0) {
Expand Down

0 comments on commit c3644f6

Please sign in to comment.