Skip to content

Commit

Permalink
overlays: Factor out the common i2c bus selection
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pelwell committed Jan 29, 2025
1 parent 9196579 commit 8aba331
Show file tree
Hide file tree
Showing 18 changed files with 202 additions and 903 deletions.
264 changes: 50 additions & 214 deletions arch/arm/boot/dts/overlays/README

Large diffs are not rendered by default.

39 changes: 2 additions & 37 deletions arch/arm/boot/dts/overlays/ads1115-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
/dts-v1/;
/plugin/;

#include "i2c-buses.dtsi"

/ {
compatible = "brcm,bcm2835";

Expand Down Expand Up @@ -81,27 +83,6 @@
};
};

frag100: fragment@100 {
target = <&i2c1>;
i2cbus: __overlay__ {
status = "okay";
};
};

fragment@101 {
target = <&i2c0if>;
__dormant__ {
status = "okay";
};
};

fragment@102 {
target = <&i2c0mux>;
__dormant__ {
status = "okay";
};
};

__overrides__ {
addr = <&ads1115>,"reg:0";
cha_enable = <0>,"=0";
Expand All @@ -120,21 +101,5 @@
chd_cfg = <&channel_d>,"reg:0";
chd_gain = <&channel_d>,"ti,gain:0";
chd_datarate = <&channel_d>,"ti,datarate:0";
i2c0 = <&frag100>, "target:0=",<&i2c0>,
<0>,"+101+102";
i2c_csi_dsi = <&frag100>, "target:0=",<&i2c_csi_dsi>,
<0>,"+101+102";
i2c_csi_dsi0 = <&frag100>, "target:0=",<&i2c_csi_dsi0>,
<0>,"+101+102";
i2c3 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c3";
i2c4 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c4";
i2c5 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c5";
i2c6 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c6";
i2c-path = <&frag100>, "target?=0",
<&frag100>, "target-path";
};
};
39 changes: 6 additions & 33 deletions arch/arm/boot/dts/overlays/edt-ft5406-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,16 @@
/dts-v1/;
/plugin/;

#define ENABLE_I2C0_MUX
#include "i2c-buses.dtsi"
#include "edt-ft5406.dtsi"

/ {
fragment@0 {
target = <&i2c0if>;
__overlay__ {
status = "okay";
};
};

fragment@1 {
target = <&i2c0mux>;
__overlay__ {
status = "okay";
};
};
&busfrag {
target = <&i2c_csi_dsi>;
};

/ {
__overrides__ {
i2c0 = <&ts_i2c_frag>,"target:0=",<&i2c0>;
i2c1 = <&ts_i2c_frag>, "target?=0",
<&ts_i2c_frag>, "target-path=i2c1",
<0>,"-0-1";
i2c3 = <&ts_i2c_frag>, "target?=0",
<&ts_i2c_frag>, "target-path=i2c3",
<0>,"-0-1";
i2c4 = <&ts_i2c_frag>, "target?=0",
<&ts_i2c_frag>, "target-path=i2c4",
<0>,"-0-1";
i2c5 = <&ts_i2c_frag>, "target?=0",
<&ts_i2c_frag>, "target-path=i2c5",
<0>,"-0-1";
i2c6 = <&ts_i2c_frag>, "target?=0",
<&ts_i2c_frag>, "target-path=i2c6",
<0>,"-0-1";
i2c-path = <&ts_i2c_frag>, "target?=0",
<&ts_i2c_frag>, "target-path",
<0>,"-0-1";
addr = <&ft5406>,"reg:0";
};
};
5 changes: 2 additions & 3 deletions arch/arm/boot/dts/overlays/edt-ft5406.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
};
};

ts_i2c_frag: fragment@12 {
target = <&i2c_csi_dsi>;
fragment@12 {
target = <&i2cbus>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";

ft5406: ts@38 {
compatible = "edt,edt-ft5506";
Expand Down
67 changes: 67 additions & 0 deletions arch/arm/boot/dts/overlays/i2c-buses.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Common i2c buses, and dtparams to select them

/ {
compatible = "brcm,bcm2835";

busfrag: fragment@100 {
target = <&i2c_arm>;
i2cbus: __overlay__ {
status = "okay";
};
};

fragment@101 {
target = <&i2c0if>;
#ifdef ENABLE_I2C0_MUX
__overlay__ {
#else
__dormant__ {
#endif
status = "okay";
};
};

fragment@102 {
target = <&i2c0mux>;
#ifdef ENABLE_I2C0_MUX
__overlay__ {
#else
__dormant__ {
#endif
status = "okay";
};
};

__overrides__ {
i2c0 = <&busfrag>,"target:0=",<&i2c0>,
<&busfrag>, "target-path?=0",
<0>,"+101+102";
i2c_csi_dsi = <&busfrag>,"target:0=",<&i2c_csi_dsi>,
<&busfrag>, "target-path?=0",
<0>,"+101+102";
i2c_csi_dsi0 = <&busfrag>, "target:0=",<&i2c_csi_dsi0>,
<&busfrag>, "target-path?=0",
<0>,"+101+102";
i2c1 = <&busfrag>,"target:0=",<&i2c1>,
<&busfrag>, "target-path?=0",
<0>,"-101-102";
i2c2 = <&busfrag>, "target?=0",
<&busfrag>, "target-path=i2c2",
<0>,"-101-102";
i2c3 = <&busfrag>, "target?=0",
<&busfrag>, "target-path=i2c3",
<0>,"-101-102";
i2c4 = <&busfrag>, "target?=0",
<&busfrag>, "target-path=i2c4",
<0>,"-101-102";
i2c5 = <&busfrag>, "target?=0",
<&busfrag>, "target-path=i2c5",
<0>,"-101-102";
i2c6 = <&busfrag>, "target?=0",
<&busfrag>, "target-path=i2c6",
<0>,"-101-102";
i2c-path = <&busfrag>, "target?=0",
<&busfrag>, "target-path",
<0>,"-101-102";
};
};
45 changes: 5 additions & 40 deletions arch/arm/boot/dts/overlays/i2c-fan-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

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

#include "i2c-buses.dtsi"

/ {
compatible = "brcm,bcm2835";

Expand All @@ -22,35 +24,14 @@
};
};

frag100: fragment@100 {
target = <&i2c_arm>;
i2cbus: __overlay__ {
status = "okay";
};
};

fragment@101 {
target = <&i2c0if>;
__dormant__ {
status = "okay";
};
};

fragment@102 {
target = <&i2c0mux>;
__dormant__ {
status = "okay";
};
};

fragment@103 {
fragment@1 {
target = <&cpu_thermal>;
__overlay__ {
polling-delay = <2000>; /* milliseconds */
};
};

fragment@104 {
fragment@2 {
target = <&thermal_trips>;
__overlay__ {
fanmid0: fanmid0 {
Expand All @@ -66,7 +47,7 @@
};
};

fragment@105 {
fragment@3 {
target = <&cooling_maps>;
__overlay__ {
map0: map0 {
Expand All @@ -81,22 +62,6 @@
};

__overrides__ {
i2c0 = <&frag100>,"target:0=",<&i2c0>,
<0>,"+101+102";
i2c_csi_dsi = <&frag100>,"target:0=",<&i2c_csi_dsi>,
<0>,"+101+102";
i2c_csi_dsi0 = <&frag100>, "target:0=",<&i2c_csi_dsi0>,
<0>,"+101+102";
i2c3 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c3";
i2c4 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c4";
i2c5 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c5";
i2c6 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c6";
i2c-path = <&frag100>, "target?=0",
<&frag100>, "target-path";
addr = <&emc2301>,"reg:0";
minpwm = <&emc2301>,"emc2305,pwm-min.0";
maxpwm = <&emc2301>,"emc2305,pwm-max.0";
Expand Down
42 changes: 2 additions & 40 deletions arch/arm/boot/dts/overlays/i2c-mux-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

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

#include "i2c-buses.dtsi"

/{
compatible = "brcm,bcm2835";

Expand All @@ -13,7 +15,6 @@
__dormant__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";

pca9542: mux@70 {
compatible = "nxp,pca9542";
Expand All @@ -40,7 +41,6 @@
__dormant__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";

pca9545: mux@70 {
compatible = "nxp,pca9545";
Expand Down Expand Up @@ -77,7 +77,6 @@
__dormant__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";

pca9548: mux@70 {
compatible = "nxp,pca9548";
Expand Down Expand Up @@ -129,27 +128,6 @@
};
};

frag100: fragment@100 {
target = <&i2c_arm>;
i2cbus: __overlay__ {
status = "okay";
};
};

fragment@101 {
target = <&i2c0if>;
__dormant__ {
status = "okay";
};
};

fragment@102 {
target = <&i2c0mux>;
__dormant__ {
status = "okay";
};
};

__overrides__ {
pca9542 = <0>, "+0";
pca9545 = <0>, "+1";
Expand All @@ -163,22 +141,6 @@
<&pca9545>,"base-nr:0",
<&pca9548>,"base-nr:0";

i2c0 = <&frag100>, "target:0=",<&i2c0>,
<0>,"+101+102";
i2c_csi_dsi = <&frag100>, "target:0=",<&i2c_csi_dsi>,
<0>,"+101+102";
i2c_csi_dsi0 = <&frag100>, "target:0=",<&i2c_csi_dsi0>,
<0>,"+101+102";
i2c3 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c3";
i2c4 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c4";
i2c5 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c5";
i2c6 = <&frag100>, "target?=0",
<&frag100>, "target-path=i2c6";
i2c-path = <&frag100>, "target?=0",
<&frag100>, "target-path";
disconnect_on_idle =
<&pca9542>,"idle-state:0=", <MUX_IDLE_DISCONNECT>,
<&pca9545>,"idle-state:0=", <MUX_IDLE_DISCONNECT>,
Expand Down
Loading

0 comments on commit 8aba331

Please sign in to comment.