Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitda69003

Browse files
committed
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "Some more driver bugfixes for I2C. Including a revert - the updated series for it will come during the next merge window"* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: owl: Clear NACK and BUS error bits Revert "i2c: imx: Fix reset of I2SR_IAL flag" i2c: meson: fixup rate calculation with filter delay i2c: meson: keep peripheral clock enabled i2c: meson: fix clock setting overwrite i2c: imx: Fix reset of I2SR_IAL flag
2 parents64b7f67 +f5b3f43 commitda69003

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

‎drivers/i2c/busses/i2c-meson.c‎

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com>
66
*/
77

8+
#include<linux/bitfield.h>
89
#include<linux/clk.h>
910
#include<linux/completion.h>
1011
#include<linux/i2c.h>
@@ -33,12 +34,17 @@
3334
#defineREG_CTRL_ACK_IGNOREBIT(1)
3435
#defineREG_CTRL_STATUSBIT(2)
3536
#defineREG_CTRL_ERRORBIT(3)
36-
#defineREG_CTRL_CLKDIV_SHIFT12
37-
#defineREG_CTRL_CLKDIV_MASKGENMASK(21, 12)
38-
#defineREG_CTRL_CLKDIVEXT_SHIFT 28
39-
#defineREG_CTRL_CLKDIVEXT_MASKGENMASK(29, 28)
37+
#defineREG_CTRL_CLKDIVGENMASK(21, 12)
38+
#defineREG_CTRL_CLKDIVEXTGENMASK(29, 28)
39+
40+
#defineREG_SLV_ADDRGENMASK(7, 0)
41+
#defineREG_SLV_SDA_FILTERGENMASK(10, 8)
42+
#defineREG_SLV_SCL_FILTERGENMASK(13, 11)
43+
#defineREG_SLV_SCL_LOWGENMASK(27, 16)
44+
#defineREG_SLV_SCL_LOW_ENBIT(28)
4045

4146
#defineI2C_TIMEOUT_MS500
47+
#defineFILTER_DELAY15
4248

4349
enum {
4450
TOKEN_END=0,
@@ -133,19 +139,24 @@ static void meson_i2c_set_clk_div(struct meson_i2c *i2c, unsigned int freq)
133139
unsigned longclk_rate=clk_get_rate(i2c->clk);
134140
unsignedintdiv;
135141

136-
div=DIV_ROUND_UP(clk_rate,freq*i2c->data->div_factor);
142+
div=DIV_ROUND_UP(clk_rate,freq);
143+
div-=FILTER_DELAY;
144+
div=DIV_ROUND_UP(div,i2c->data->div_factor);
137145

138146
/* clock divider has 12 bits */
139-
if (div >= (1 <<12)) {
147+
if (div>GENMASK(11,0)) {
140148
dev_err(i2c->dev,"requested bus frequency too low\n");
141-
div=(1 <<12)-1;
149+
div=GENMASK(11,0);
142150
}
143151

144-
meson_i2c_set_mask(i2c,REG_CTRL,REG_CTRL_CLKDIV_MASK,
145-
(div&GENMASK(9,0)) <<REG_CTRL_CLKDIV_SHIFT);
152+
meson_i2c_set_mask(i2c,REG_CTRL,REG_CTRL_CLKDIV,
153+
FIELD_PREP(REG_CTRL_CLKDIV,div&GENMASK(9,0)));
154+
155+
meson_i2c_set_mask(i2c,REG_CTRL,REG_CTRL_CLKDIVEXT,
156+
FIELD_PREP(REG_CTRL_CLKDIVEXT,div >>10));
146157

147-
meson_i2c_set_mask(i2c,REG_CTRL,REG_CTRL_CLKDIVEXT_MASK,
148-
(div >>10) <<REG_CTRL_CLKDIVEXT_SHIFT);
158+
/* Disable HIGH/LOW mode */
159+
meson_i2c_set_mask(i2c,REG_SLAVE_ADDR,REG_SLV_SCL_LOW_EN,0);
149160

150161
dev_dbg(i2c->dev,"%s: clk %lu, freq %u, div %u\n",__func__,
151162
clk_rate,freq,div);
@@ -280,7 +291,10 @@ static void meson_i2c_do_start(struct meson_i2c *i2c, struct i2c_msg *msg)
280291
token= (msg->flags&I2C_M_RD) ?TOKEN_SLAVE_ADDR_READ :
281292
TOKEN_SLAVE_ADDR_WRITE;
282293

283-
writel(msg->addr <<1,i2c->regs+REG_SLAVE_ADDR);
294+
295+
meson_i2c_set_mask(i2c,REG_SLAVE_ADDR,REG_SLV_ADDR,
296+
FIELD_PREP(REG_SLV_ADDR,msg->addr <<1));
297+
284298
meson_i2c_add_token(i2c,TOKEN_START);
285299
meson_i2c_add_token(i2c,token);
286300
}
@@ -357,16 +371,12 @@ static int meson_i2c_xfer_messages(struct i2c_adapter *adap,
357371
structmeson_i2c*i2c=adap->algo_data;
358372
inti,ret=0;
359373

360-
clk_enable(i2c->clk);
361-
362374
for (i=0;i<num;i++) {
363375
ret=meson_i2c_xfer_msg(i2c,msgs+i,i==num-1,atomic);
364376
if (ret)
365377
break;
366378
}
367379

368-
clk_disable(i2c->clk);
369-
370380
returnret ?:i;
371381
}
372382

@@ -435,7 +445,7 @@ static int meson_i2c_probe(struct platform_device *pdev)
435445
returnret;
436446
}
437447

438-
ret=clk_prepare(i2c->clk);
448+
ret=clk_prepare_enable(i2c->clk);
439449
if (ret<0) {
440450
dev_err(&pdev->dev,"can't prepare clock\n");
441451
returnret;
@@ -457,10 +467,14 @@ static int meson_i2c_probe(struct platform_device *pdev)
457467

458468
ret=i2c_add_adapter(&i2c->adap);
459469
if (ret<0) {
460-
clk_unprepare(i2c->clk);
470+
clk_disable_unprepare(i2c->clk);
461471
returnret;
462472
}
463473

474+
/* Disable filtering */
475+
meson_i2c_set_mask(i2c,REG_SLAVE_ADDR,
476+
REG_SLV_SDA_FILTER |REG_SLV_SCL_FILTER,0);
477+
464478
meson_i2c_set_clk_div(i2c,timings.bus_freq_hz);
465479

466480
return0;
@@ -471,7 +485,7 @@ static int meson_i2c_remove(struct platform_device *pdev)
471485
structmeson_i2c*i2c=platform_get_drvdata(pdev);
472486

473487
i2c_del_adapter(&i2c->adap);
474-
clk_unprepare(i2c->clk);
488+
clk_disable_unprepare(i2c->clk);
475489

476490
return0;
477491
}

‎drivers/i2c/busses/i2c-owl.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,19 @@ static irqreturn_t owl_i2c_interrupt(int irq, void *_dev)
176176
fifostat=readl(i2c_dev->base+OWL_I2C_REG_FIFOSTAT);
177177
if (fifostat&OWL_I2C_FIFOSTAT_RNB) {
178178
i2c_dev->err=-ENXIO;
179+
/* Clear NACK error bit by writing "1" */
180+
owl_i2c_update_reg(i2c_dev->base+OWL_I2C_REG_FIFOSTAT,
181+
OWL_I2C_FIFOSTAT_RNB, true);
179182
gotostop;
180183
}
181184

182185
/* Handle bus error */
183186
stat=readl(i2c_dev->base+OWL_I2C_REG_STAT);
184187
if (stat&OWL_I2C_STAT_BEB) {
185188
i2c_dev->err=-EIO;
189+
/* Clear BUS error bit by writing "1" */
190+
owl_i2c_update_reg(i2c_dev->base+OWL_I2C_REG_STAT,
191+
OWL_I2C_STAT_BEB, true);
186192
gotostop;
187193
}
188194

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp