Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 101315
b: refs/heads/master
c: 2373c18
h: refs/heads/master
i:
  101313: c256262
  101311: 00b4a66
v: v3
  • Loading branch information
Manuel Lauss authored and Jean Delvare committed Jul 14, 2008
1 parent aa7096a commit 3c14e83
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 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: 392a0408fdc4c9069c32a9a02b0088eae76c4618
refs/heads/master: 2373c1801afd06d3a206376902b39a98458c9cfb
42 changes: 35 additions & 7 deletions trunk/drivers/i2c/busses/i2c-ocores.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct ocores_i2c {
int pos;
int nmsgs;
int state; /* see STATE_ */
int clock_khz;
};

/* registers */
Expand Down Expand Up @@ -173,16 +174,15 @@ static int ocores_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
return -ETIMEDOUT;
}

static void ocores_init(struct ocores_i2c *i2c,
struct ocores_i2c_platform_data *pdata)
static void ocores_init(struct ocores_i2c *i2c)
{
int prescale;
u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL);

/* make sure the device is disabled */
oc_setreg(i2c, OCI2C_CONTROL, ctrl & ~(OCI2C_CTRL_EN|OCI2C_CTRL_IEN));

prescale = (pdata->clock_khz / (5*100)) - 1;
prescale = (i2c->clock_khz / (5*100)) - 1;
oc_setreg(i2c, OCI2C_PRELOW, prescale & 0xff);
oc_setreg(i2c, OCI2C_PREHIGH, prescale >> 8);

Expand Down Expand Up @@ -248,7 +248,8 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
}

i2c->regstep = pdata->regstep;
ocores_init(i2c, pdata);
i2c->clock_khz = pdata->clock_khz;
ocores_init(i2c);

init_waitqueue_head(&i2c->wait);
ret = request_irq(res2->start, ocores_isr, 0, pdev->name, i2c);
Expand Down Expand Up @@ -312,13 +313,40 @@ static int __devexit ocores_i2c_remove(struct platform_device* pdev)
return 0;
}

#ifdef CONFIG_PM
static int ocores_i2c_suspend(struct platform_device *pdev, pm_message_t state)
{
struct ocores_i2c *i2c = platform_get_drvdata(pdev);
u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL);

/* make sure the device is disabled */
oc_setreg(i2c, OCI2C_CONTROL, ctrl & ~(OCI2C_CTRL_EN|OCI2C_CTRL_IEN));

return 0;
}

static int ocores_i2c_resume(struct platform_device *pdev)
{
struct ocores_i2c *i2c = platform_get_drvdata(pdev);

ocores_init(i2c);

return 0;
}
#else
#define ocores_i2c_suspend NULL
#define ocores_i2c_resume NULL
#endif

/* work with hotplug and coldplug */
MODULE_ALIAS("platform:ocores-i2c");

static struct platform_driver ocores_i2c_driver = {
.probe = ocores_i2c_probe,
.remove = __devexit_p(ocores_i2c_remove),
.driver = {
.probe = ocores_i2c_probe,
.remove = __devexit_p(ocores_i2c_remove),
.suspend = ocores_i2c_suspend,
.resume = ocores_i2c_resume,
.driver = {
.owner = THIS_MODULE,
.name = "ocores-i2c",
},
Expand Down

0 comments on commit 3c14e83

Please sign in to comment.