Skip to content

Commit 99e4472

Browse files
committed
Merge tag 'i2c-for-7.0-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull more i2c updates from Wolfram Sang: "Designware: - refactor the transfer path to support I2C_M_STOP - handle pm runtime by using the active auto try macros - handle controllers lacking explicit START and STOP conditions - general cleanups Other i2c drivers: - qualcomm: add support for qcs8300-cci - amd8111: general cleanups - cp2112: add DT bindings" * tag 'i2c-for-7.0-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: dt-bindings: i2c: Add CP2112 HID USB to SMBus Bridge i2c: amd8111: switch to devm_ functions i2c: amd8111: Remove spaces in MODULE_* macros i2c: designware-platdrv: fix cleanup on probe failure i2c: designware-platdrv: simplify reset control dt-bindings: i2c: qcom-cci: Document qcs8300 compatible i2c: designware: Remove dead code in AMD ISP case i2c: designware: Support of controller with IC_EMPTYFIFO_HOLD_MASTER disabled i2c: designware: Use runtime PM macro for auto-cleanup i2c: designware: Implement I2C_M_STOP support
2 parents bc1d4e7 + 709cc48 commit 99e4472

8 files changed

Lines changed: 266 additions & 106 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ properties:
2828
- enum:
2929
- qcom,kaanapali-cci
3030
- qcom,qcm2290-cci
31+
- qcom,qcs8300-cci
3132
- qcom,sa8775p-cci
3233
- qcom,sc7280-cci
3334
- qcom,sc8280xp-cci
@@ -133,6 +134,7 @@ allOf:
133134
enum:
134135
- qcom,kaanapali-cci
135136
- qcom,qcm2290-cci
137+
- qcom,qcs8300-cci
136138
- qcom,sm8750-cci
137139
then:
138140
properties:
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/i2c/silabs,cp2112.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: CP2112 HID USB to SMBus/I2C Bridge
8+
9+
maintainers:
10+
- Danny Kaehn <danny.kaehn@plexus.com>
11+
12+
description:
13+
The CP2112 is a USB HID device which includes an integrated I2C controller
14+
and 8 GPIO pins. Its GPIO pins can each be configured as inputs, open-drain
15+
outputs, or push-pull outputs.
16+
17+
properties:
18+
compatible:
19+
const: usb10c4,ea90
20+
21+
reg:
22+
maxItems: 1
23+
description: The USB port number
24+
25+
interrupt-controller: true
26+
"#interrupt-cells":
27+
const: 2
28+
29+
gpio-controller: true
30+
"#gpio-cells":
31+
const: 2
32+
33+
gpio-line-names:
34+
minItems: 1
35+
maxItems: 8
36+
37+
i2c:
38+
description: The SMBus/I2C controller node for the CP2112
39+
$ref: /schemas/i2c/i2c-controller.yaml#
40+
unevaluatedProperties: false
41+
42+
properties:
43+
clock-frequency:
44+
minimum: 10000
45+
default: 100000
46+
maximum: 400000
47+
48+
patternProperties:
49+
"-hog(-[0-9]+)?$":
50+
type: object
51+
52+
required:
53+
- gpio-hog
54+
55+
required:
56+
- compatible
57+
- reg
58+
59+
additionalProperties: false
60+
61+
examples:
62+
- |
63+
#include <dt-bindings/interrupt-controller/irq.h>
64+
#include <dt-bindings/gpio/gpio.h>
65+
66+
usb {
67+
#address-cells = <1>;
68+
#size-cells = <0>;
69+
70+
cp2112: device@1 {
71+
compatible = "usb10c4,ea90";
72+
reg = <1>;
73+
74+
gpio-controller;
75+
interrupt-controller;
76+
#interrupt-cells = <2>;
77+
#gpio-cells = <2>;
78+
gpio-line-names = "CP2112_SDA", "CP2112_SCL", "TEST2",
79+
"TEST3","TEST4", "TEST5", "TEST6";
80+
81+
fan-rst-hog {
82+
gpio-hog;
83+
gpios = <7 GPIO_ACTIVE_HIGH>;
84+
output-high;
85+
line-name = "FAN_RST";
86+
};
87+
88+
i2c {
89+
#address-cells = <1>;
90+
#size-cells = <0>;
91+
sda-gpios = <&cp2112 0 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
92+
scl-gpios = <&cp2112 1 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
93+
94+
temp@48 {
95+
compatible = "national,lm75";
96+
reg = <0x48>;
97+
};
98+
};
99+
};
100+
};

drivers/i2c/busses/i2c-amd8111.c

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <linux/io.h>
1818

1919
MODULE_LICENSE("GPL");
20-
MODULE_AUTHOR ("Vojtech Pavlik <vojtech@suse.cz>");
20+
MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
2121
MODULE_DESCRIPTION("AMD8111 SMBus 2.0 driver");
2222

2323
struct amd_smbus {
@@ -417,7 +417,7 @@ static const struct pci_device_id amd8111_ids[] = {
417417
{ 0, }
418418
};
419419

420-
MODULE_DEVICE_TABLE (pci, amd8111_ids);
420+
MODULE_DEVICE_TABLE(pci, amd8111_ids);
421421

422422
static int amd8111_probe(struct pci_dev *dev, const struct pci_device_id *id)
423423
{
@@ -427,7 +427,7 @@ static int amd8111_probe(struct pci_dev *dev, const struct pci_device_id *id)
427427
if (!(pci_resource_flags(dev, 0) & IORESOURCE_IO))
428428
return -ENODEV;
429429

430-
smbus = kzalloc(sizeof(struct amd_smbus), GFP_KERNEL);
430+
smbus = devm_kzalloc(&dev->dev, sizeof(struct amd_smbus), GFP_KERNEL);
431431
if (!smbus)
432432
return -ENOMEM;
433433

@@ -436,19 +436,15 @@ static int amd8111_probe(struct pci_dev *dev, const struct pci_device_id *id)
436436
smbus->size = pci_resource_len(dev, 0);
437437

438438
error = acpi_check_resource_conflict(&dev->resource[0]);
439-
if (error) {
440-
error = -ENODEV;
441-
goto out_kfree;
442-
}
439+
if (error)
440+
return -ENODEV;
443441

444-
if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) {
445-
error = -EBUSY;
446-
goto out_kfree;
447-
}
442+
if (!devm_request_region(&dev->dev, smbus->base, smbus->size, amd8111_driver.name))
443+
return -EBUSY;
448444

449445
smbus->adapter.owner = THIS_MODULE;
450446
snprintf(smbus->adapter.name, sizeof(smbus->adapter.name),
451-
"SMBus2 AMD8111 adapter at %04x", smbus->base);
447+
"SMBus2 AMD8111 adapter at %04x", smbus->base);
452448
smbus->adapter.class = I2C_CLASS_HWMON;
453449
smbus->adapter.algo = &smbus_algorithm;
454450
smbus->adapter.algo_data = smbus;
@@ -459,25 +455,17 @@ static int amd8111_probe(struct pci_dev *dev, const struct pci_device_id *id)
459455
pci_write_config_dword(smbus->dev, AMD_PCI_MISC, 0);
460456
error = i2c_add_adapter(&smbus->adapter);
461457
if (error)
462-
goto out_release_region;
458+
return error;
463459

464460
pci_set_drvdata(dev, smbus);
465461
return 0;
466-
467-
out_release_region:
468-
release_region(smbus->base, smbus->size);
469-
out_kfree:
470-
kfree(smbus);
471-
return error;
472462
}
473463

474464
static void amd8111_remove(struct pci_dev *dev)
475465
{
476466
struct amd_smbus *smbus = pci_get_drvdata(dev);
477467

478468
i2c_del_adapter(&smbus->adapter);
479-
release_region(smbus->base, smbus->size);
480-
kfree(smbus);
481469
}
482470

483471
static struct pci_driver amd8111_driver = {

drivers/i2c/busses/i2c-designware-amdisp.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
static void amd_isp_dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *i2c_dev)
1919
{
2020
pm_runtime_disable(i2c_dev->dev);
21-
22-
if (i2c_dev->shared_with_punit)
23-
pm_runtime_put_noidle(i2c_dev->dev);
2421
}
2522

2623
static inline u32 amd_isp_dw_i2c_get_clk_rate(struct dw_i2c_dev *i2c_dev)
@@ -79,9 +76,6 @@ static int amd_isp_dw_i2c_plat_probe(struct platform_device *pdev)
7976

8077
device_enable_async_suspend(&pdev->dev);
8178

82-
if (isp_i2c_dev->shared_with_punit)
83-
pm_runtime_get_noresume(&pdev->dev);
84-
8579
pm_runtime_enable(&pdev->dev);
8680
pm_runtime_get_sync(&pdev->dev);
8781

@@ -130,9 +124,6 @@ static int amd_isp_dw_i2c_plat_runtime_suspend(struct device *dev)
130124
{
131125
struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
132126

133-
if (i_dev->shared_with_punit)
134-
return 0;
135-
136127
i2c_dw_disable(i_dev);
137128
i2c_dw_prepare_clk(i_dev, false);
138129

@@ -161,9 +152,7 @@ static int amd_isp_dw_i2c_plat_runtime_resume(struct device *dev)
161152
if (!i_dev)
162153
return -ENODEV;
163154

164-
if (!i_dev->shared_with_punit)
165-
i2c_dw_prepare_clk(i_dev, true);
166-
155+
i2c_dw_prepare_clk(i_dev, true);
167156
i2c_dw_init(i_dev);
168157

169158
return 0;

drivers/i2c/busses/i2c-designware-common.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,12 @@ int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev)
492492

493493
dev->clk_freq_optimized = device_property_read_bool(device, "snps,clk-freq-optimized");
494494

495+
/* Mobileye controllers do not hold the clock on empty FIFO */
496+
if (device_is_compatible(device, "mobileye,eyeq6lplus-i2c"))
497+
dev->emptyfifo_hold_master = false;
498+
else
499+
dev->emptyfifo_hold_master = true;
500+
495501
i2c_dw_adjust_bus_speed(dev);
496502

497503
if (is_of_node(fwnode))
@@ -918,6 +924,20 @@ int i2c_dw_probe(struct dw_i2c_dev *dev)
918924
else
919925
irq_flags = IRQF_SHARED | IRQF_COND_SUSPEND;
920926

927+
/*
928+
* The first writing to TX FIFO buffer causes transmission start.
929+
* If IC_EMPTYFIFO_HOLD_MASTER_EN is not set, when TX FIFO gets
930+
* empty, I2C controller finishes the transaction. If writing to
931+
* FIFO is interrupted, FIFO can get empty and the transaction will
932+
* be finished prematurely. FIFO buffer is filled in IRQ handler,
933+
* but in PREEMPT_RT kernel IRQ handler by default is executed
934+
* in thread that can be preempted with another higher priority
935+
* thread or an interrupt. So, IRQF_NO_THREAD flag is required in
936+
* order to prevent any preemption when filling the FIFO.
937+
*/
938+
if (!dev->emptyfifo_hold_master)
939+
irq_flags |= IRQF_NO_THREAD;
940+
921941
ret = i2c_dw_acquire_lock(dev);
922942
if (ret)
923943
return ret;

drivers/i2c/busses/i2c-designware-core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ struct reset_control;
260260
* @clk_freq_optimized: if this value is true, it means the hardware reduces
261261
* its internal clock frequency by reducing the internal latency required
262262
* to generate the high period and low period of SCL line.
263+
* @emptyfifo_hold_master: true if the controller acting as master holds
264+
* the clock when the Tx FIFO is empty instead of emitting a stop.
263265
*
264266
* HCNT and LCNT parameters can be used if the platform knows more accurate
265267
* values than the one computed based only on the input clock frequency.
@@ -318,6 +320,7 @@ struct dw_i2c_dev {
318320
struct i2c_bus_recovery_info rinfo;
319321
u32 bus_capacitance_pF;
320322
bool clk_freq_optimized;
323+
bool emptyfifo_hold_master;
321324
};
322325

323326
#define ACCESS_INTR_MASK BIT(0)

0 commit comments

Comments
 (0)