Skip to content

Commit 60c089b

Browse files
committed
Merge remote-tracking branch 'andi/i2c/andi-for-next' into i2c/for-mergewindow
Pull the patches Andi kindly collected while I was on hiatus. Thanks, Andi!
2 parents 3253f69 + 7a34bab commit 60c089b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+324
-434
lines changed

Documentation/devicetree/bindings/i2c/cdns,i2c-r1p10.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ properties:
4848
default: 16
4949
enum: [2, 4, 8, 16, 32, 64, 128, 256]
5050

51+
power-domains:
52+
maxItems: 1
53+
5154
required:
5255
- compatible
5356
- reg

Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/i2c/i2c-arb-gpio-challenge.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: GPIO-based I2C Arbitration Using a Challenge & Response Mechanism
8+
9+
maintainers:
10+
- Doug Anderson <dianders@chromium.org>
11+
- Peter Rosin <peda@axentia.se>
12+
13+
description: |
14+
This uses GPIO lines and a challenge & response mechanism to arbitrate who is
15+
the master of an I2C bus in a multimaster situation.
16+
17+
In many cases using GPIOs to arbitrate is not needed and a design can use the
18+
standard I2C multi-master rules. Using GPIOs is generally useful in the case
19+
where there is a device on the bus that has errata and/or bugs that makes
20+
standard multimaster mode not feasible.
21+
22+
Note that this scheme works well enough but has some downsides:
23+
* It is nonstandard (not using standard I2C multimaster)
24+
* Having two masters on a bus in general makes it relatively hard to debug
25+
problems (hard to tell if i2c issues were caused by one master, another,
26+
or some device on the bus).
27+
28+
Algorithm:
29+
All masters on the bus have a 'bus claim' line which is an output that the
30+
others can see. These are all active low with pull-ups enabled. We'll
31+
describe these lines as:
32+
* OUR_CLAIM: output from us signaling to other hosts that we want the bus
33+
* THEIR_CLAIMS: output from others signaling that they want the bus
34+
35+
The basic algorithm is to assert your line when you want the bus, then make
36+
sure that the other side doesn't want it also. A detailed explanation is
37+
best done with an example.
38+
39+
Let's say we want to claim the bus. We:
40+
1. Assert OUR_CLAIM.
41+
2. Waits a little bit for the other sides to notice (slew time, say 10
42+
microseconds).
43+
3. Check THEIR_CLAIMS. If none are asserted then the we have the bus and we
44+
are done.
45+
4. Otherwise, wait for a few milliseconds and see if THEIR_CLAIMS are released.
46+
5. If not, back off, release the claim and wait for a few more milliseconds.
47+
6. Go back to 1 (until retry time has expired).
48+
49+
properties:
50+
compatible:
51+
const: i2c-arb-gpio-challenge
52+
53+
i2c-parent:
54+
$ref: /schemas/types.yaml#/definitions/phandle
55+
description:
56+
The I2C bus that this multiplexer's master-side port is connected to.
57+
58+
our-claim-gpios:
59+
maxItems: 1
60+
description:
61+
The GPIO that we use to claim the bus.
62+
63+
slew-delay-us:
64+
default: 10
65+
description:
66+
Time to wait for a GPIO to go high.
67+
68+
their-claim-gpios:
69+
minItems: 1
70+
maxItems: 8
71+
description:
72+
The GPIOs that the other sides use to claim the bus. Note that some
73+
implementations may only support a single other master.
74+
75+
wait-free-us:
76+
default: 50000
77+
description:
78+
We'll give up after this many microseconds.
79+
80+
wait-retry-us:
81+
default: 3000
82+
description:
83+
We'll attempt another claim after this many microseconds.
84+
85+
i2c-arb:
86+
type: object
87+
$ref: /schemas/i2c/i2c-controller.yaml
88+
unevaluatedProperties: false
89+
description:
90+
I2C arbitration bus node.
91+
92+
required:
93+
- compatible
94+
- i2c-arb
95+
- our-claim-gpios
96+
- their-claim-gpios
97+
98+
additionalProperties: false
99+
100+
examples:
101+
- |
102+
#include <dt-bindings/gpio/gpio.h>
103+
#include <dt-bindings/interrupt-controller/irq.h>
104+
105+
i2c-arbitrator {
106+
compatible = "i2c-arb-gpio-challenge";
107+
i2c-parent = <&i2c_4>;
108+
109+
our-claim-gpios = <&gpf0 3 GPIO_ACTIVE_LOW>;
110+
their-claim-gpios = <&gpe0 4 GPIO_ACTIVE_LOW>;
111+
slew-delay-us = <10>;
112+
wait-retry-us = <3000>;
113+
wait-free-us = <50000>;
114+
115+
i2c-arb {
116+
#address-cells = <1>;
117+
#size-cells = <0>;
118+
119+
sbs-battery@b {
120+
compatible = "sbs,sbs-battery";
121+
reg = <0xb>;
122+
sbs,poll-retry-count = <1>;
123+
};
124+
125+
embedded-controller@1e {
126+
compatible = "google,cros-ec-i2c";
127+
reg = <0x1e>;
128+
interrupts = <6 IRQ_TYPE_LEVEL_HIGH>;
129+
interrupt-parent = <&gpx1>;
130+
pinctrl-names = "default";
131+
pinctrl-0 = <&ec_irq>;
132+
wakeup-source;
133+
};
134+
};
135+
};

Documentation/devicetree/bindings/i2c/i2c-arb.txt

Lines changed: 0 additions & 35 deletions
This file was deleted.

Documentation/devicetree/bindings/i2c/nxp,pca9541.txt

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/i2c/nxp,pca9541.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: NXP PCA9541 I2C bus master selector
8+
9+
maintainers:
10+
- Peter Rosin <peda@axentia.se>
11+
12+
properties:
13+
compatible:
14+
const: nxp,pca9541
15+
16+
reg:
17+
maxItems: 1
18+
19+
i2c-arb:
20+
type: object
21+
$ref: /schemas/i2c/i2c-controller.yaml
22+
unevaluatedProperties: false
23+
description:
24+
I2C arbitration bus node.
25+
26+
required:
27+
- compatible
28+
- reg
29+
- i2c-arb
30+
31+
additionalProperties: false
32+
33+
examples:
34+
- |
35+
#include <dt-bindings/gpio/gpio.h>
36+
#include <dt-bindings/interrupt-controller/irq.h>
37+
38+
i2c {
39+
#address-cells = <1>;
40+
#size-cells = <0>;
41+
42+
i2c-arbitrator@74 {
43+
compatible = "nxp,pca9541";
44+
reg = <0x74>;
45+
46+
i2c-arb {
47+
#address-cells = <1>;
48+
#size-cells = <0>;
49+
50+
eeprom@54 {
51+
compatible = "atmel,24c08";
52+
reg = <0x54>;
53+
};
54+
};
55+
};
56+
};

drivers/i2c/busses/i2c-au1550.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ static void i2c_au1550_remove(struct platform_device *pdev)
342342
i2c_au1550_disable(priv);
343343
}
344344

345-
#ifdef CONFIG_PM
346345
static int i2c_au1550_suspend(struct device *dev)
347346
{
348347
struct i2c_au1550_data *priv = dev_get_drvdata(dev);
@@ -361,21 +360,13 @@ static int i2c_au1550_resume(struct device *dev)
361360
return 0;
362361
}
363362

364-
static const struct dev_pm_ops i2c_au1550_pmops = {
365-
.suspend = i2c_au1550_suspend,
366-
.resume = i2c_au1550_resume,
367-
};
368-
369-
#define AU1XPSC_SMBUS_PMOPS (&i2c_au1550_pmops)
370-
371-
#else
372-
#define AU1XPSC_SMBUS_PMOPS NULL
373-
#endif
363+
static DEFINE_SIMPLE_DEV_PM_OPS(i2c_au1550_pmops,
364+
i2c_au1550_suspend, i2c_au1550_resume);
374365

375366
static struct platform_driver au1xpsc_smbus_driver = {
376367
.driver = {
377368
.name = "au1xpsc_smbus",
378-
.pm = AU1XPSC_SMBUS_PMOPS,
369+
.pm = pm_sleep_ptr(&i2c_au1550_pmops),
379370
},
380371
.probe = i2c_au1550_probe,
381372
.remove_new = i2c_au1550_remove,

0 commit comments

Comments
 (0)