Skip to content

Commit c9b4717

Browse files
committed
Merge tag 'i2c-for-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang: - general cleanups in bcm2835, designware, pcf8584, and stm32 - amd-mp2: fix device refcount - designware: avoid interrupt storms caused by bad firmware - spacemit: fix device detection failures - new devices: Intel Diamond Rapids, Rockchip RK3506, Qualcomm Kaanapali and MSM8953 - minor fixes to i801, core documentation, elektor Kconfig dependencies - at24 updates: add new compatible for Belling BL24S64 * tag 'i2c-for-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (21 commits) i2c: qcom-cci: Add msm8953 compatible i2c: spacemit: fix detect issue i2c: amd-mp2: fix reference leak in MP2 PCI device i2c: i2c.h: fix a bad kernel-doc line i2c: i2c-elektor: Allow building on SMP kernels dt-bindings: i2c: qcom-cci: Document Kaanapali compatible dt-bindings: i2c: qcom-cci: Document msm8953 compatible dt-bindings: eeprom: at24: Add compatible for Belling BL24S64 i2c: i801: Fix the Intel Diamond Rapids features i2c: pcf8584: Change pcf_doAdress() to pcf_send_address() i2c: pcf8584: Make pcf_doAddress() function void i2c: pcf8584: Move 'ret' variable inside for loop, goto out if ret < 0. i2c: designware: Disable SMBus interrupts to prevent storms from mis-configured firmware dt-bindings: i2c: i2c-rk3x: Add compatible string for RK3506 i2c: i801: Add support for Intel Diamond Rapids i2c: stm32: Omit two variable reassignments in stm32_i2c_dma_request() i2c: designware: Omit a variable reassignment in dw_i2c_plat_probe() i2c: pcf8584: Fix do not use assignment inside if conditional i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c i2c: busses: bcm2835: convert from round_rate() to determine_rate() ...
2 parents 9d588a1 + d202341 commit c9b4717

16 files changed

Lines changed: 120 additions & 111 deletions

File tree

Documentation/devicetree/bindings/eeprom/at24.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ properties:
131131
- const: atmel,24c32
132132
- items:
133133
- enum:
134+
- belling,bl24s64
134135
- onnn,n24s64b
135136
- puya,p24c64f
136137
- const: atmel,24c64

Documentation/devicetree/bindings/i2c/i2c-rk3x.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ properties:
3737
- rockchip,px30-i2c
3838
- rockchip,rk3308-i2c
3939
- rockchip,rk3328-i2c
40+
- rockchip,rk3506-i2c
4041
- rockchip,rk3528-i2c
4142
- rockchip,rk3562-i2c
4243
- rockchip,rk3568-i2c

Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ properties:
1515
oneOf:
1616
- enum:
1717
- qcom,msm8226-cci
18+
- qcom,msm8953-cci
1819
- qcom,msm8974-cci
1920
- qcom,msm8996-cci
2021

@@ -25,6 +26,7 @@ properties:
2526

2627
- items:
2728
- enum:
29+
- qcom,kaanapali-cci
2830
- qcom,qcm2290-cci
2931
- qcom,sa8775p-cci
3032
- qcom,sc7280-cci
@@ -128,6 +130,7 @@ allOf:
128130
compatible:
129131
contains:
130132
enum:
133+
- qcom,kaanapali-cci
131134
- qcom,qcm2290-cci
132135
then:
133136
properties:
@@ -146,6 +149,7 @@ allOf:
146149
- contains:
147150
enum:
148151
- qcom,msm8916-cci
152+
- qcom,msm8953-cci
149153

150154
- const: qcom,msm8996-cci
151155
then:

Documentation/i2c/busses/i2c-i801.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Supported adapters:
5151
* Intel Arrow Lake (SOC)
5252
* Intel Panther Lake (SOC)
5353
* Intel Wildcat Lake (SOC)
54+
* Intel Diamond Rapids (SOC)
5455

5556
Datasheets: Publicly available at the Intel website
5657

drivers/i2c/algos/i2c-algo-pcf.c

Lines changed: 25 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,8 @@
2323
#include "i2c-algo-pcf.h"
2424

2525

26-
#define DEB2(x) if (i2c_debug >= 2) x
27-
#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
28-
#define DEBPROTO(x) if (i2c_debug >= 9) x;
29-
/* debug the protocol by showing transferred bits */
3026
#define DEF_TIMEOUT 16
3127

32-
/*
33-
* module parameters:
34-
*/
35-
static int i2c_debug;
36-
3728
/* setting states on the bus with the right timing: */
3829

3930
#define set_pcf(adap, ctl, val) adap->setpcf(adap->data, ctl, val)
@@ -47,27 +38,21 @@ static int i2c_debug;
4738

4839
static void i2c_start(struct i2c_algo_pcf_data *adap)
4940
{
50-
DEBPROTO(printk(KERN_DEBUG "S "));
5141
set_pcf(adap, 1, I2C_PCF_START);
5242
}
5343

5444
static void i2c_repstart(struct i2c_algo_pcf_data *adap)
5545
{
56-
DEBPROTO(printk(" Sr "));
5746
set_pcf(adap, 1, I2C_PCF_REPSTART);
5847
}
5948

6049
static void i2c_stop(struct i2c_algo_pcf_data *adap)
6150
{
62-
DEBPROTO(printk("P\n"));
6351
set_pcf(adap, 1, I2C_PCF_STOP);
6452
}
6553

6654
static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
6755
{
68-
DEB2(printk(KERN_INFO
69-
"i2c-algo-pcf.o: lost arbitration (CSR 0x%02x)\n",
70-
*status));
7156
/*
7257
* Cleanup from LAB -- reset and enable ESO.
7358
* This resets the PCF8584; since we've lost the bus, no
@@ -88,9 +73,6 @@ static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
8873
if (adap->lab_mdelay)
8974
mdelay(adap->lab_mdelay);
9075

91-
DEB2(printk(KERN_INFO
92-
"i2c-algo-pcf.o: reset LAB condition (CSR 0x%02x)\n",
93-
get_pcf(adap, 1)));
9476
}
9577

9678
static int wait_for_bb(struct i2c_algo_pcf_data *adap)
@@ -147,56 +129,48 @@ static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status)
147129
*
148130
* vdovikin: added detect code for PCF8584
149131
*/
150-
static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
132+
static int pcf_init_8584(struct i2c_algo_pcf_data *adap)
151133
{
152134
unsigned char temp;
153135

154-
DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: PCF state 0x%02x\n",
155-
get_pcf(adap, 1)));
156-
157136
/* S1=0x80: S0 selected, serial interface off */
158137
set_pcf(adap, 1, I2C_PCF_PIN);
159138
/*
160139
* check to see S1 now used as R/W ctrl -
161140
* PCF8584 does that when ESO is zero
162141
*/
163-
if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
164-
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
142+
temp = get_pcf(adap, 1);
143+
if ((temp & 0x7f) != 0)
165144
return -ENXIO; /* definitely not PCF8584 */
166-
}
167145

168146
/* load own address in S0, effective address is (own << 1) */
169147
i2c_outb(adap, get_own(adap));
170148
/* check it's really written */
171-
if ((temp = i2c_inb(adap)) != get_own(adap)) {
172-
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
149+
temp = i2c_inb(adap);
150+
if (temp != get_own(adap))
173151
return -ENXIO;
174-
}
175152

176153
/* S1=0xA0, next byte in S2 */
177154
set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
178155
/* check to see S2 now selected */
179-
if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
180-
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
156+
temp = get_pcf(adap, 1);
157+
if ((temp & 0x7f) != I2C_PCF_ES1)
181158
return -ENXIO;
182-
}
183159

184160
/* load clock register S2 */
185161
i2c_outb(adap, get_clock(adap));
186162
/* check it's really written, the only 5 lowest bits does matter */
187-
if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
188-
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
163+
temp = i2c_inb(adap);
164+
if ((temp & 0x1f) != get_clock(adap))
189165
return -ENXIO;
190-
}
191166

192167
/* Enable serial interface, idle, S0 selected */
193168
set_pcf(adap, 1, I2C_PCF_IDLE);
194169

195170
/* check to see PCF is really idled and we can access status register */
196-
if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
197-
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
171+
temp = get_pcf(adap, 1);
172+
if (temp != (I2C_PCF_PIN | I2C_PCF_BB))
198173
return -ENXIO;
199-
}
200174

201175
printk(KERN_DEBUG "i2c-algo-pcf.o: detected and initialized PCF8584.\n");
202176

@@ -209,9 +183,7 @@ static int pcf_sendbytes(struct i2c_adapter *i2c_adap, const char *buf,
209183
struct i2c_algo_pcf_data *adap = i2c_adap->algo_data;
210184
int wrcount, status, timeout;
211185

212-
for (wrcount=0; wrcount<count; ++wrcount) {
213-
DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
214-
buf[wrcount] & 0xff));
186+
for (wrcount = 0; wrcount < count; ++wrcount) {
215187
i2c_outb(adap, buf[wrcount]);
216188
timeout = wait_for_pin(adap, &status);
217189
if (timeout) {
@@ -246,7 +218,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
246218
/* increment number of bytes to read by one -- read dummy byte */
247219
for (i = 0; i <= count; i++) {
248220

249-
if ((wfp = wait_for_pin(adap, &status))) {
221+
wfp = wait_for_pin(adap, &status);
222+
if (wfp) {
250223
if (wfp == -EINTR)
251224
return -EINTR; /* arbitration lost */
252225

@@ -280,16 +253,14 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
280253
}
281254

282255

283-
static int pcf_doAddress(struct i2c_algo_pcf_data *adap,
256+
static void pcf_send_address(struct i2c_algo_pcf_data *adap,
284257
struct i2c_msg *msg)
285258
{
286259
unsigned char addr = i2c_8bit_addr_from_msg(msg);
287260

288261
if (msg->flags & I2C_M_REV_DIR_ADDR)
289262
addr ^= 1;
290263
i2c_outb(adap, addr);
291-
292-
return 0;
293264
}
294265

295266
static int pcf_xfer(struct i2c_adapter *i2c_adap,
@@ -299,28 +270,23 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
299270
struct i2c_algo_pcf_data *adap = i2c_adap->algo_data;
300271
struct i2c_msg *pmsg;
301272
int i;
302-
int ret=0, timeout, status;
273+
int timeout, status;
303274

304275
if (adap->xfer_begin)
305276
adap->xfer_begin(adap->data);
306277

307278
/* Check for bus busy */
308279
timeout = wait_for_bb(adap);
309280
if (timeout) {
310-
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: "
311-
"Timeout waiting for BB in pcf_xfer\n");)
312281
i = -EIO;
313282
goto out;
314283
}
315284

316-
for (i = 0;ret >= 0 && i < num; i++) {
317-
pmsg = &msgs[i];
318-
319-
DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
320-
str_read_write(pmsg->flags & I2C_M_RD),
321-
pmsg->len, pmsg->addr, i + 1, num);)
285+
for (i = 0; i < num; i++) {
286+
int ret;
322287

323-
ret = pcf_doAddress(adap, pmsg);
288+
pmsg = &msgs[i];
289+
pcf_send_address(adap, pmsg);
324290

325291
/* Send START */
326292
if (i == 0)
@@ -335,44 +301,28 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
335301
goto out;
336302
}
337303
i2c_stop(adap);
338-
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
339-
"for PIN(1) in pcf_xfer\n");)
340304
i = -EREMOTEIO;
341305
goto out;
342306
}
343307

344308
/* Check LRB (last rcvd bit - slave ack) */
345309
if (status & I2C_PCF_LRB) {
346310
i2c_stop(adap);
347-
DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)
348311
i = -EREMOTEIO;
349312
goto out;
350313
}
351314

352-
DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
353-
i, msgs[i].addr, msgs[i].flags, msgs[i].len);)
354315

355316
if (pmsg->flags & I2C_M_RD) {
356317
ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len,
357318
(i + 1 == num));
358-
359-
if (ret != pmsg->len) {
360-
DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
361-
"only read %d bytes.\n",ret));
362-
} else {
363-
DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
364-
}
365319
} else {
366320
ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
367321
(i + 1 == num));
368-
369-
if (ret != pmsg->len) {
370-
DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
371-
"only wrote %d bytes.\n",ret));
372-
} else {
373-
DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
374-
}
375322
}
323+
324+
if (ret < 0)
325+
goto out;
376326
}
377327

378328
out:
@@ -401,12 +351,11 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
401351
struct i2c_algo_pcf_data *pcf_adap = adap->algo_data;
402352
int rval;
403353

404-
DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
405-
406354
/* register new adapter to i2c module... */
407355
adap->algo = &pcf_algo;
408356

409-
if ((rval = pcf_init_8584(pcf_adap)))
357+
rval = pcf_init_8584(pcf_adap);
358+
if (rval)
410359
return rval;
411360

412361
rval = i2c_add_adapter(adap);
@@ -418,7 +367,3 @@ EXPORT_SYMBOL(i2c_pcf_add_bus);
418367
MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
419368
MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm");
420369
MODULE_LICENSE("GPL");
421-
422-
module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
423-
MODULE_PARM_DESC(i2c_debug,
424-
"debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol");

drivers/i2c/busses/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ config I2C_I801
166166
Arrow Lake (SOC)
167167
Panther Lake (SOC)
168168
Wildcat Lake (SOC)
169+
Diamond Rapids (SOC)
169170

170171
This driver can also be built as a module. If so, the module
171172
will be called i2c-i801.
@@ -1474,7 +1475,7 @@ config I2C_ACORN
14741475

14751476
config I2C_ELEKTOR
14761477
tristate "Elektor ISA card"
1477-
depends on ISA && HAS_IOPORT_MAP && BROKEN_ON_SMP
1478+
depends on ISA && HAS_IOPORT_MAP
14781479
select I2C_ALGOPCF
14791480
help
14801481
This supports the PCF8584 ISA bus I2C adapter. Say Y if you own

drivers/i2c/busses/i2c-amd-mp2-pci.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,16 @@ struct amd_mp2_dev *amd_mp2_find_device(void)
458458
{
459459
struct device *dev;
460460
struct pci_dev *pci_dev;
461+
struct amd_mp2_dev *mp2_dev;
461462

462463
dev = driver_find_next_device(&amd_mp2_pci_driver.driver, NULL);
463464
if (!dev)
464465
return NULL;
465466

466467
pci_dev = to_pci_dev(dev);
467-
return (struct amd_mp2_dev *)pci_get_drvdata(pci_dev);
468+
mp2_dev = (struct amd_mp2_dev *)pci_get_drvdata(pci_dev);
469+
put_device(dev);
470+
return mp2_dev;
468471
}
469472
EXPORT_SYMBOL_GPL(amd_mp2_find_device);
470473

drivers/i2c/busses/i2c-bcm2835.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@ static int clk_bcm2835_i2c_set_rate(struct clk_hw *hw, unsigned long rate,
137137
return 0;
138138
}
139139

140-
static long clk_bcm2835_i2c_round_rate(struct clk_hw *hw, unsigned long rate,
141-
unsigned long *parent_rate)
140+
static int clk_bcm2835_i2c_determine_rate(struct clk_hw *hw,
141+
struct clk_rate_request *req)
142142
{
143-
u32 divider = clk_bcm2835_i2c_calc_divider(rate, *parent_rate);
143+
u32 divider = clk_bcm2835_i2c_calc_divider(req->rate, req->best_parent_rate);
144144

145-
return DIV_ROUND_UP(*parent_rate, divider);
145+
req->rate = DIV_ROUND_UP(req->best_parent_rate, divider);
146+
147+
return 0;
146148
}
147149

148150
static unsigned long clk_bcm2835_i2c_recalc_rate(struct clk_hw *hw,
@@ -156,7 +158,7 @@ static unsigned long clk_bcm2835_i2c_recalc_rate(struct clk_hw *hw,
156158

157159
static const struct clk_ops clk_bcm2835_i2c_ops = {
158160
.set_rate = clk_bcm2835_i2c_set_rate,
159-
.round_rate = clk_bcm2835_i2c_round_rate,
161+
.determine_rate = clk_bcm2835_i2c_determine_rate,
160162
.recalc_rate = clk_bcm2835_i2c_recalc_rate,
161163
};
162164

0 commit comments

Comments
 (0)