Skip to content

Commit a320d39

Browse files
committed
overlays: Factor out the common i2c bus selection
Create an i2c-buses.dtsi to hold all of the common I2C bus selection logic, and refactor existing overlays to use it. This patch should have no functional change overall except to increase the range of options for some overlays. There is a slightly ugly mechanism for overriding the default bus, where the mux nodes may or may not need to be enabled. Signed-off-by: Phil Elwell <[email protected]>
1 parent fa71765 commit a320d39

18 files changed

+202
-903
lines changed

arch/arm/boot/dts/overlays/README

+50-214
Large diffs are not rendered by default.

arch/arm/boot/dts/overlays/ads1115-overlay.dts

+2-37
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
/dts-v1/;
66
/plugin/;
77

8+
#include "i2c-buses.dtsi"
9+
810
/ {
911
compatible = "brcm,bcm2835";
1012

@@ -81,27 +83,6 @@
8183
};
8284
};
8385

84-
frag100: fragment@100 {
85-
target = <&i2c1>;
86-
i2cbus: __overlay__ {
87-
status = "okay";
88-
};
89-
};
90-
91-
fragment@101 {
92-
target = <&i2c0if>;
93-
__dormant__ {
94-
status = "okay";
95-
};
96-
};
97-
98-
fragment@102 {
99-
target = <&i2c0mux>;
100-
__dormant__ {
101-
status = "okay";
102-
};
103-
};
104-
10586
__overrides__ {
10687
addr = <&ads1115>,"reg:0";
10788
cha_enable = <0>,"=0";
@@ -120,21 +101,5 @@
120101
chd_cfg = <&channel_d>,"reg:0";
121102
chd_gain = <&channel_d>,"ti,gain:0";
122103
chd_datarate = <&channel_d>,"ti,datarate:0";
123-
i2c0 = <&frag100>, "target:0=",<&i2c0>,
124-
<0>,"+101+102";
125-
i2c_csi_dsi = <&frag100>, "target:0=",<&i2c_csi_dsi>,
126-
<0>,"+101+102";
127-
i2c_csi_dsi0 = <&frag100>, "target:0=",<&i2c_csi_dsi0>,
128-
<0>,"+101+102";
129-
i2c3 = <&frag100>, "target?=0",
130-
<&frag100>, "target-path=i2c3";
131-
i2c4 = <&frag100>, "target?=0",
132-
<&frag100>, "target-path=i2c4";
133-
i2c5 = <&frag100>, "target?=0",
134-
<&frag100>, "target-path=i2c5";
135-
i2c6 = <&frag100>, "target?=0",
136-
<&frag100>, "target-path=i2c6";
137-
i2c-path = <&frag100>, "target?=0",
138-
<&frag100>, "target-path";
139104
};
140105
};

arch/arm/boot/dts/overlays/edt-ft5406-overlay.dts

+6-33
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,16 @@
77
/dts-v1/;
88
/plugin/;
99

10+
#define ENABLE_I2C0_MUX
11+
#include "i2c-buses.dtsi"
1012
#include "edt-ft5406.dtsi"
1113

12-
/ {
13-
fragment@0 {
14-
target = <&i2c0if>;
15-
__overlay__ {
16-
status = "okay";
17-
};
18-
};
19-
20-
fragment@1 {
21-
target = <&i2c0mux>;
22-
__overlay__ {
23-
status = "okay";
24-
};
25-
};
14+
&busfrag {
15+
target = <&i2c_csi_dsi>;
16+
};
2617

18+
/ {
2719
__overrides__ {
28-
i2c0 = <&ts_i2c_frag>,"target:0=",<&i2c0>;
29-
i2c1 = <&ts_i2c_frag>, "target?=0",
30-
<&ts_i2c_frag>, "target-path=i2c1",
31-
<0>,"-0-1";
32-
i2c3 = <&ts_i2c_frag>, "target?=0",
33-
<&ts_i2c_frag>, "target-path=i2c3",
34-
<0>,"-0-1";
35-
i2c4 = <&ts_i2c_frag>, "target?=0",
36-
<&ts_i2c_frag>, "target-path=i2c4",
37-
<0>,"-0-1";
38-
i2c5 = <&ts_i2c_frag>, "target?=0",
39-
<&ts_i2c_frag>, "target-path=i2c5",
40-
<0>,"-0-1";
41-
i2c6 = <&ts_i2c_frag>, "target?=0",
42-
<&ts_i2c_frag>, "target-path=i2c6",
43-
<0>,"-0-1";
44-
i2c-path = <&ts_i2c_frag>, "target?=0",
45-
<&ts_i2c_frag>, "target-path",
46-
<0>,"-0-1";
4720
addr = <&ft5406>,"reg:0";
4821
};
4922
};

arch/arm/boot/dts/overlays/edt-ft5406.dtsi

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222
};
2323
};
2424

25-
ts_i2c_frag: fragment@12 {
26-
target = <&i2c_csi_dsi>;
25+
fragment@12 {
26+
target = <&i2cbus>;
2727
__overlay__ {
2828
#address-cells = <1>;
2929
#size-cells = <0>;
30-
status = "okay";
3130

3231
ft5406: ts@38 {
3332
compatible = "edt,edt-ft5506";
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Common i2c buses, and dtparams to select them
2+
3+
/ {
4+
compatible = "brcm,bcm2835";
5+
6+
busfrag: fragment@100 {
7+
target = <&i2c_arm>;
8+
i2cbus: __overlay__ {
9+
status = "okay";
10+
};
11+
};
12+
13+
fragment@101 {
14+
target = <&i2c0if>;
15+
#ifdef ENABLE_I2C0_MUX
16+
__overlay__ {
17+
#else
18+
__dormant__ {
19+
#endif
20+
status = "okay";
21+
};
22+
};
23+
24+
fragment@102 {
25+
target = <&i2c0mux>;
26+
#ifdef ENABLE_I2C0_MUX
27+
__overlay__ {
28+
#else
29+
__dormant__ {
30+
#endif
31+
status = "okay";
32+
};
33+
};
34+
35+
__overrides__ {
36+
i2c0 = <&busfrag>,"target:0=",<&i2c0>,
37+
<&busfrag>, "target-path?=0",
38+
<0>,"+101+102";
39+
i2c_csi_dsi = <&busfrag>,"target:0=",<&i2c_csi_dsi>,
40+
<&busfrag>, "target-path?=0",
41+
<0>,"+101+102";
42+
i2c_csi_dsi0 = <&busfrag>, "target:0=",<&i2c_csi_dsi0>,
43+
<&busfrag>, "target-path?=0",
44+
<0>,"+101+102";
45+
i2c1 = <&busfrag>,"target:0=",<&i2c1>,
46+
<&busfrag>, "target-path?=0",
47+
<0>,"-101-102";
48+
i2c2 = <&busfrag>, "target?=0",
49+
<&busfrag>, "target-path=i2c2",
50+
<0>,"-101-102";
51+
i2c3 = <&busfrag>, "target?=0",
52+
<&busfrag>, "target-path=i2c3",
53+
<0>,"-101-102";
54+
i2c4 = <&busfrag>, "target?=0",
55+
<&busfrag>, "target-path=i2c4",
56+
<0>,"-101-102";
57+
i2c5 = <&busfrag>, "target?=0",
58+
<&busfrag>, "target-path=i2c5",
59+
<0>,"-101-102";
60+
i2c6 = <&busfrag>, "target?=0",
61+
<&busfrag>, "target-path=i2c6",
62+
<0>,"-101-102";
63+
i2c-path = <&busfrag>, "target?=0",
64+
<&busfrag>, "target-path",
65+
<0>,"-101-102";
66+
};
67+
};

arch/arm/boot/dts/overlays/i2c-fan-overlay.dts

+5-40
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <dt-bindings/thermal/thermal.h>
66

7+
#include "i2c-buses.dtsi"
8+
79
/ {
810
compatible = "brcm,bcm2835";
911

@@ -22,35 +24,14 @@
2224
};
2325
};
2426

25-
frag100: fragment@100 {
26-
target = <&i2c_arm>;
27-
i2cbus: __overlay__ {
28-
status = "okay";
29-
};
30-
};
31-
32-
fragment@101 {
33-
target = <&i2c0if>;
34-
__dormant__ {
35-
status = "okay";
36-
};
37-
};
38-
39-
fragment@102 {
40-
target = <&i2c0mux>;
41-
__dormant__ {
42-
status = "okay";
43-
};
44-
};
45-
46-
fragment@103 {
27+
fragment@1 {
4728
target = <&cpu_thermal>;
4829
__overlay__ {
4930
polling-delay = <2000>; /* milliseconds */
5031
};
5132
};
5233

53-
fragment@104 {
34+
fragment@2 {
5435
target = <&thermal_trips>;
5536
__overlay__ {
5637
fanmid0: fanmid0 {
@@ -66,7 +47,7 @@
6647
};
6748
};
6849

69-
fragment@105 {
50+
fragment@3 {
7051
target = <&cooling_maps>;
7152
__overlay__ {
7253
map0: map0 {
@@ -81,22 +62,6 @@
8162
};
8263

8364
__overrides__ {
84-
i2c0 = <&frag100>,"target:0=",<&i2c0>,
85-
<0>,"+101+102";
86-
i2c_csi_dsi = <&frag100>,"target:0=",<&i2c_csi_dsi>,
87-
<0>,"+101+102";
88-
i2c_csi_dsi0 = <&frag100>, "target:0=",<&i2c_csi_dsi0>,
89-
<0>,"+101+102";
90-
i2c3 = <&frag100>, "target?=0",
91-
<&frag100>, "target-path=i2c3";
92-
i2c4 = <&frag100>, "target?=0",
93-
<&frag100>, "target-path=i2c4";
94-
i2c5 = <&frag100>, "target?=0",
95-
<&frag100>, "target-path=i2c5";
96-
i2c6 = <&frag100>, "target?=0",
97-
<&frag100>, "target-path=i2c6";
98-
i2c-path = <&frag100>, "target?=0",
99-
<&frag100>, "target-path";
10065
addr = <&emc2301>,"reg:0";
10166
minpwm = <&emc2301>,"emc2305,pwm-min.0";
10267
maxpwm = <&emc2301>,"emc2305,pwm-max.0";

arch/arm/boot/dts/overlays/i2c-mux-overlay.dts

+2-40
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include <dt-bindings/mux/mux.h>
77

8+
#include "i2c-buses.dtsi"
9+
810
/{
911
compatible = "brcm,bcm2835";
1012

@@ -13,7 +15,6 @@
1315
__dormant__ {
1416
#address-cells = <1>;
1517
#size-cells = <0>;
16-
status = "okay";
1718

1819
pca9542: mux@70 {
1920
compatible = "nxp,pca9542";
@@ -40,7 +41,6 @@
4041
__dormant__ {
4142
#address-cells = <1>;
4243
#size-cells = <0>;
43-
status = "okay";
4444

4545
pca9545: mux@70 {
4646
compatible = "nxp,pca9545";
@@ -77,7 +77,6 @@
7777
__dormant__ {
7878
#address-cells = <1>;
7979
#size-cells = <0>;
80-
status = "okay";
8180

8281
pca9548: mux@70 {
8382
compatible = "nxp,pca9548";
@@ -129,27 +128,6 @@
129128
};
130129
};
131130

132-
frag100: fragment@100 {
133-
target = <&i2c_arm>;
134-
i2cbus: __overlay__ {
135-
status = "okay";
136-
};
137-
};
138-
139-
fragment@101 {
140-
target = <&i2c0if>;
141-
__dormant__ {
142-
status = "okay";
143-
};
144-
};
145-
146-
fragment@102 {
147-
target = <&i2c0mux>;
148-
__dormant__ {
149-
status = "okay";
150-
};
151-
};
152-
153131
__overrides__ {
154132
pca9542 = <0>, "+0";
155133
pca9545 = <0>, "+1";
@@ -163,22 +141,6 @@
163141
<&pca9545>,"base-nr:0",
164142
<&pca9548>,"base-nr:0";
165143

166-
i2c0 = <&frag100>, "target:0=",<&i2c0>,
167-
<0>,"+101+102";
168-
i2c_csi_dsi = <&frag100>, "target:0=",<&i2c_csi_dsi>,
169-
<0>,"+101+102";
170-
i2c_csi_dsi0 = <&frag100>, "target:0=",<&i2c_csi_dsi0>,
171-
<0>,"+101+102";
172-
i2c3 = <&frag100>, "target?=0",
173-
<&frag100>, "target-path=i2c3";
174-
i2c4 = <&frag100>, "target?=0",
175-
<&frag100>, "target-path=i2c4";
176-
i2c5 = <&frag100>, "target?=0",
177-
<&frag100>, "target-path=i2c5";
178-
i2c6 = <&frag100>, "target?=0",
179-
<&frag100>, "target-path=i2c6";
180-
i2c-path = <&frag100>, "target?=0",
181-
<&frag100>, "target-path";
182144
disconnect_on_idle =
183145
<&pca9542>,"idle-state:0=", <MUX_IDLE_DISCONNECT>,
184146
<&pca9545>,"idle-state:0=", <MUX_IDLE_DISCONNECT>,

0 commit comments

Comments
 (0)