Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 250832
b: refs/heads/master
c: 81f8115
h: refs/heads/master
v: v3
  • Loading branch information
Magnus Damm authored and Ben Dooks committed May 11, 2011
1 parent 3f7c47c commit 3bffb60
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 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: 1082d5d29d9a71f43b969b89ce613374602a6946
refs/heads/master: 81f8115305f821335cf9e16110bf0806f7b93283
13 changes: 11 additions & 2 deletions trunk/drivers/i2c/busses/i2c-sh_mobile.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/i2c/i2c-sh_mobile.h>

/* Transmit operation: */
/* */
Expand Down Expand Up @@ -117,7 +118,7 @@ struct sh_mobile_i2c_data {
struct device *dev;
void __iomem *reg;
struct i2c_adapter adap;

unsigned long bus_speed;
struct clk *clk;
u_int8_t icic;
u_int8_t iccl;
Expand Down Expand Up @@ -205,7 +206,7 @@ static void activate_ch(struct sh_mobile_i2c_data *pd)
* We also round off the result.
*/
num = i2c_clk * 5;
denom = NORMAL_SPEED * 9;
denom = pd->bus_speed * 9;
tmp = num * 10 / denom;
if (tmp % 10 >= 5)
pd->iccl = (u_int8_t)((num/denom) + 1);
Expand Down Expand Up @@ -574,6 +575,7 @@ static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook)

static int sh_mobile_i2c_probe(struct platform_device *dev)
{
struct i2c_sh_mobile_platform_data *pdata = dev->dev.platform_data;
struct sh_mobile_i2c_data *pd;
struct i2c_adapter *adap;
struct resource *res;
Expand Down Expand Up @@ -618,6 +620,11 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
goto err_irq;
}

/* Use platformd data bus speed or NORMAL_SPEED */
pd->bus_speed = NORMAL_SPEED;
if (pdata && pdata->bus_speed)
pd->bus_speed = pdata->bus_speed;

/* The IIC blocks on SH-Mobile ARM processors
* come with two new bits in ICIC.
*/
Expand Down Expand Up @@ -658,6 +665,8 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
goto err_all;
}

dev_info(&dev->dev, "I2C adapter %d with bus speed %lu Hz\n",
adap->nr, pd->bus_speed);
return 0;

err_all:
Expand Down
10 changes: 10 additions & 0 deletions trunk/include/linux/i2c/i2c-sh_mobile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __I2C_SH_MOBILE_H__
#define __I2C_SH_MOBILE_H__

#include <linux/platform_device.h>

struct i2c_sh_mobile_platform_data {
unsigned long bus_speed;
};

#endif /* __I2C_SH_MOBILE_H__ */

0 comments on commit 3bffb60

Please sign in to comment.