Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 208654
b: refs/heads/master
c: 962b603
h: refs/heads/master
v: v3
  • Loading branch information
Magnus Damm authored and Paul Mundt committed Apr 7, 2010
1 parent 134c0bc commit 19ac001
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 12a55f2db71e0a1474ba56ab1c93287600b915be
refs/heads/master: 962b6032c889ed9a5f0bdb7052d9318067a75bda
31 changes: 31 additions & 0 deletions trunk/drivers/i2c/busses/i2c-sh_mobile.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ struct sh_mobile_i2c_data {
struct i2c_adapter adap;

struct clk *clk;
u_int8_t icic;
u_int8_t iccl;
u_int8_t icch;
u_int8_t flags;

spinlock_t lock;
wait_queue_head_t wait;
Expand All @@ -129,6 +131,8 @@ struct sh_mobile_i2c_data {
int sr;
};

#define IIC_FLAG_HAS_ICIC67 (1 << 0)

#define NORMAL_SPEED 100000 /* FAST_SPEED 400000 */

/* Register offsets */
Expand All @@ -155,13 +159,18 @@ struct sh_mobile_i2c_data {
#define ICSR_WAIT 0x02
#define ICSR_DTE 0x01

#define ICIC_ICCLB8 0x80
#define ICIC_ICCHB8 0x40
#define ICIC_ALE 0x08
#define ICIC_TACKE 0x04
#define ICIC_WAITE 0x02
#define ICIC_DTEE 0x01

static void iic_wr(struct sh_mobile_i2c_data *pd, int offs, unsigned char data)
{
if (offs == ICIC)
data |= pd->icic;

iowrite8(data, pd->reg + offs);
}

Expand Down Expand Up @@ -203,6 +212,14 @@ static void activate_ch(struct sh_mobile_i2c_data *pd)
else
pd->iccl = (u_int8_t)(num/denom);

/* one more bit of ICCL in ICIC */
if (pd->flags & IIC_FLAG_HAS_ICIC67) {
if ((num/denom) > 0xff)
pd->icic |= ICIC_ICCLB8;
else
pd->icic &= ~ICIC_ICCLB8;
}

/* Calculate the value for icch. From the data sheet:
icch = (p clock / transfer rate) * (H / (L + H)) */
num = i2c_clk * 4;
Expand All @@ -212,6 +229,14 @@ static void activate_ch(struct sh_mobile_i2c_data *pd)
else
pd->icch = (u_int8_t)(num/denom);

/* one more bit of ICCH in ICIC */
if (pd->flags & IIC_FLAG_HAS_ICIC67) {
if ((num/denom) > 0xff)
pd->icic |= ICIC_ICCHB8;
else
pd->icic &= ~ICIC_ICCHB8;
}

/* Enable channel and configure rx ack */
iic_set_clr(pd, ICCR, ICCR_ICE, 0);

Expand Down Expand Up @@ -592,6 +617,12 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
goto err_irq;
}

/* The IIC blocks on SH-Mobile ARM processors
* come with two new bits in ICIC.
*/
if (size > 0x17)
pd->flags |= IIC_FLAG_HAS_ICIC67;

/* Enable Runtime PM for this device.
*
* Also tell the Runtime PM core to ignore children
Expand Down

0 comments on commit 19ac001

Please sign in to comment.