[PATCH v2] ARM: dts: Add i2cmux-pinctrl config to Raspberry Pi BSC0
Dave Stevenson
dave.stevenson at raspberrypi.org
Tue Dec 12 07:18:06 PST 2017
The first i2c controller (BSC0) on the Raspberry Pi family
can be pinmuxed to either GPIOs 0&1, 28&29, or 44&45.
The default has always been 0&1 as those are exposed on
the 40 pin GPIO header of the more recent models.
GPIOs 28&29 on Pi 0/A+/B+/2 and GPIOs 44&45 on Pi3 are
used for i2c to the DSI display and the camera module.
The i2c-mux-pinctrl driver allows pinctrl setup to be used
to expose the GPIO sets as alternate i2c adapters. This
patch configures that driver to expose two adapters -
i2c0 on GPIOs 0&1, and i2c_csi_dsi on the correct GPIOs for
the camera and display.
(This could be extended to expose all 3 options on the CM
and CM3, but there isn't a pressing case for that at present).
The one quirk with the i2cmux-pinctrl driver is that the
parent controller still exists as an i2c adapter which
will be connnected to whichever pins were last requested
(or an optional idle setting). Without additional configuration
that adapter appears first so would be numbered as adapter 0,
The child ports would end up as adapters 3&4. These have been
renumbered through using DT aliases to retain the ordering of
adapters.
The rev1 model A and B platforms used GPIOs 2&3 (BSC1) for the
camera, whilst rev2 model A and B used 0&1 (no I2C was routed
to the display). Neither exposed any of the alternate pins
that BSC0 can be routed to in a useful manner. For those
platforms the mux is not created, and BSC0 is routed to
GPIOs 0&1 as before.
Signed-off-by: Dave Stevenson <dave.stevenson at raspberrypi.org>
---
Changes from v1 to v2.
- Changed from RFC to Patch as at least Eric appears to consider it worth pursuing.
- Reworked for models A & B where no mux is required.
- Added the aliases so that the bus naming remains the same.
- Renamed the new files to only have dashes and not underscores in them.
- Renamed the i2c controller label from i2c0_parent to bsc0 as it is more accurate,
and more logical for when there is no mux.
- SPDX License header added for the 3 new files.
arch/arm/boot/dts/bcm2835-rpi-a-plus.dts | 1 +
arch/arm/boot/dts/bcm2835-rpi-a.dts | 1 +
arch/arm/boot/dts/bcm2835-rpi-b-plus.dts | 1 +
arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts | 1 +
arch/arm/boot/dts/bcm2835-rpi-b.dts | 1 +
arch/arm/boot/dts/bcm2835-rpi-zero-w.dts | 1 +
arch/arm/boot/dts/bcm2835-rpi-zero.dts | 1 +
arch/arm/boot/dts/bcm2835-rpi.dtsi | 4 +--
arch/arm/boot/dts/bcm2836-rpi-2-b.dts | 1 +
arch/arm/boot/dts/bcm2837-rpi-3-b.dts | 1 +
arch/arm/boot/dts/bcm283x-rpi-i2c0-nomux.dtsi | 12 ++++++++
arch/arm/boot/dts/bcm283x-rpi-i2c0mux-0-28.dtsi | 39 +++++++++++++++++++++++++
arch/arm/boot/dts/bcm283x-rpi-i2c0mux-0-44.dtsi | 39 +++++++++++++++++++++++++
arch/arm/boot/dts/bcm283x.dtsi | 2 +-
14 files changed, 101 insertions(+), 4 deletions(-)
create mode 100644 arch/arm/boot/dts/bcm283x-rpi-i2c0-nomux.dtsi
create mode 100644 arch/arm/boot/dts/bcm283x-rpi-i2c0mux-0-28.dtsi
create mode 100644 arch/arm/boot/dts/bcm283x-rpi-i2c0mux-0-44.dtsi
diff --git a/arch/arm/boot/dts/bcm2835-rpi-a-plus.dts b/arch/arm/boot/dts/bcm2835-rpi-a-plus.dts
index aa1fc7b..8e2e78f 100644
--- a/arch/arm/boot/dts/bcm2835-rpi-a-plus.dts
+++ b/arch/arm/boot/dts/bcm2835-rpi-a-plus.dts
@@ -3,6 +3,7 @@
#include "bcm2835.dtsi"
#include "bcm2835-rpi.dtsi"
#include "bcm283x-rpi-usb-host.dtsi"
+#include "bcm283x-rpi-i2c0mux-0-28.dtsi"
/ {
compatible = "raspberrypi,model-a-plus", "brcm,bcm2835";
diff --git a/arch/arm/boot/dts/bcm2835-rpi-a.dts b/arch/arm/boot/dts/bcm2835-rpi-a.dts
index 425f6b0..e7cb947 100644
--- a/arch/arm/boot/dts/bcm2835-rpi-a.dts
+++ b/arch/arm/boot/dts/bcm2835-rpi-a.dts
@@ -3,6 +3,7 @@
#include "bcm2835.dtsi"
#include "bcm2835-rpi.dtsi"
#include "bcm283x-rpi-usb-host.dtsi"
+#include "bcm283x-rpi-i2c0-nomux.dtsi"
/ {
compatible = "raspberrypi,model-a", "brcm,bcm2835";
diff --git a/arch/arm/boot/dts/bcm2835-rpi-b-plus.dts b/arch/arm/boot/dts/bcm2835-rpi-b-plus.dts
index effa195..2587262 100644
--- a/arch/arm/boot/dts/bcm2835-rpi-b-plus.dts
+++ b/arch/arm/boot/dts/bcm2835-rpi-b-plus.dts
@@ -4,6 +4,7 @@
#include "bcm2835-rpi.dtsi"
#include "bcm283x-rpi-smsc9514.dtsi"
#include "bcm283x-rpi-usb-host.dtsi"
+#include "bcm283x-rpi-i2c0mux-0-28.dtsi"
/ {
compatible = "raspberrypi,model-b-plus", "brcm,bcm2835";
diff --git a/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts b/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts
index 772ec3b..1e6195b 100644
--- a/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts
+++ b/arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts
@@ -4,6 +4,7 @@
#include "bcm2835-rpi.dtsi"
#include "bcm283x-rpi-smsc9512.dtsi"
#include "bcm283x-rpi-usb-host.dtsi"
+#include "bcm283x-rpi-i2c0-nomux.dtsi"
/ {
compatible = "raspberrypi,model-b-rev2", "brcm,bcm2835";
diff --git a/arch/arm/boot/dts/bcm2835-rpi-b.dts b/arch/arm/boot/dts/bcm2835-rpi-b.dts
index 434483d..82128f6 100644
--- a/arch/arm/boot/dts/bcm2835-rpi-b.dts
+++ b/arch/arm/boot/dts/bcm2835-rpi-b.dts
@@ -4,6 +4,7 @@
#include "bcm2835-rpi.dtsi"
#include "bcm283x-rpi-smsc9512.dtsi"
#include "bcm283x-rpi-usb-host.dtsi"
+#include "bcm283x-rpi-i2c0-nomux.dtsi"
/ {
compatible = "raspberrypi,model-b", "brcm,bcm2835";
diff --git a/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
index b8565fc..7eb1eac 100644
--- a/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
+++ b/arch/arm/boot/dts/bcm2835-rpi-zero-w.dts
@@ -13,6 +13,7 @@
#include "bcm2835.dtsi"
#include "bcm2835-rpi.dtsi"
#include "bcm283x-rpi-usb-host.dtsi"
+#include "bcm283x-rpi-i2c0mux-0-28.dtsi"
/ {
compatible = "raspberrypi,model-zero-w", "brcm,bcm2835";
diff --git a/arch/arm/boot/dts/bcm2835-rpi-zero.dts b/arch/arm/boot/dts/bcm2835-rpi-zero.dts
index 7036240..02e2e50 100644
--- a/arch/arm/boot/dts/bcm2835-rpi-zero.dts
+++ b/arch/arm/boot/dts/bcm2835-rpi-zero.dts
@@ -13,6 +13,7 @@
#include "bcm2835.dtsi"
#include "bcm2835-rpi.dtsi"
#include "bcm283x-rpi-usb-otg.dtsi"
+#include "bcm283x-rpi-i2c0mux-0-28.dtsi"
/ {
compatible = "raspberrypi,model-zero", "brcm,bcm2835";
diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi b/arch/arm/boot/dts/bcm2835-rpi.dtsi
index e36c392..907f3c6 100644
--- a/arch/arm/boot/dts/bcm2835-rpi.dtsi
+++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi
@@ -44,9 +44,7 @@
};
};
-&i2c0 {
- pinctrl-names = "default";
- pinctrl-0 = <&i2c0_gpio0>;
+&bsc0 {
status = "okay";
clock-frequency = <100000>;
};
diff --git a/arch/arm/boot/dts/bcm2836-rpi-2-b.dts b/arch/arm/boot/dts/bcm2836-rpi-2-b.dts
index 5c339ad..db72667 100644
--- a/arch/arm/boot/dts/bcm2836-rpi-2-b.dts
+++ b/arch/arm/boot/dts/bcm2836-rpi-2-b.dts
@@ -4,6 +4,7 @@
#include "bcm2835-rpi.dtsi"
#include "bcm283x-rpi-smsc9514.dtsi"
#include "bcm283x-rpi-usb-host.dtsi"
+#include "bcm283x-rpi-i2c0mux-0-28.dtsi"
/ {
compatible = "raspberrypi,2-model-b", "brcm,bcm2836";
diff --git a/arch/arm/boot/dts/bcm2837-rpi-3-b.dts b/arch/arm/boot/dts/bcm2837-rpi-3-b.dts
index 3e4ed7c..4828ea4 100644
--- a/arch/arm/boot/dts/bcm2837-rpi-3-b.dts
+++ b/arch/arm/boot/dts/bcm2837-rpi-3-b.dts
@@ -4,6 +4,7 @@
#include "bcm2835-rpi.dtsi"
#include "bcm283x-rpi-smsc9514.dtsi"
#include "bcm283x-rpi-usb-host.dtsi"
+#include "bcm283x-rpi-i2c0mux-0-44.dtsi"
/ {
compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
diff --git a/arch/arm/boot/dts/bcm283x-rpi-i2c0-nomux.dtsi b/arch/arm/boot/dts/bcm283x-rpi-i2c0-nomux.dtsi
new file mode 100644
index 0000000..8ef9c3ea
--- /dev/null
+++ b/arch/arm/boot/dts/bcm283x-rpi-i2c0-nomux.dtsi
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+&bsc0 {
+ pinctrl-0 = <&i2c0_gpio0>;
+};
+
+/ {
+ aliases {
+ i2c0 = &bsc0;
+ i2c1 = &i2c1;
+ i2c2 = &i2c2;
+ };
+};
diff --git a/arch/arm/boot/dts/bcm283x-rpi-i2c0mux-0-28.dtsi b/arch/arm/boot/dts/bcm283x-rpi-i2c0mux-0-28.dtsi
new file mode 100644
index 0000000..ae152e5
--- /dev/null
+++ b/arch/arm/boot/dts/bcm283x-rpi-i2c0mux-0-28.dtsi
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+&{/soc} {
+ i2c0_mux: i2c0_mux {
+ compatible = "i2c-mux-pinctrl";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ i2c-parent = <&bsc0>;
+
+ pinctrl-names = "i2c0", "i2c_csi_dsi";
+ pinctrl-0 = <&i2c0_gpio0>;
+ pinctrl-1 = <&i2c0_gpio28>;
+
+ i2c0: i2c at 0 {
+ reg = <0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ pinctrl-0 = <&i2c0_gpio0>;
+ };
+
+ i2c_csi_dsi: i2c at 1 {
+ reg = <1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ pinctrl-1 = <&i2c0_gpio28>;
+ };
+ };
+
+};
+
+/ {
+ aliases {
+ i2c10 = &bsc0;
+ i2c0 = &i2c0;
+ i2c1 = &i2c1;
+ i2c2 = &i2c2;
+ i2c4 = &i2c_csi_dsi;
+ };
+};
diff --git a/arch/arm/boot/dts/bcm283x-rpi-i2c0mux-0-44.dtsi b/arch/arm/boot/dts/bcm283x-rpi-i2c0mux-0-44.dtsi
new file mode 100644
index 0000000..7680127
--- /dev/null
+++ b/arch/arm/boot/dts/bcm283x-rpi-i2c0mux-0-44.dtsi
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+&{/soc} {
+ i2c0_mux: i2c0_mux {
+ compatible = "i2c-mux-pinctrl";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ i2c-parent = <&bsc0>;
+
+ pinctrl-names = "i2c0", "i2c_csi_dsi";
+ pinctrl-0 = <&i2c0_gpio0>;
+ pinctrl-1 = <&i2c0_gpio44>;
+
+ i2c0: i2c at 0 {
+ reg = <0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ pinctrl-0 = <&i2c0_gpio0>;
+ };
+
+ i2c_csi_dsi: i2c at 1 {
+ reg = <1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ pinctrl-1 = <&i2c0_gpio44>;
+ };
+ };
+
+};
+
+/ {
+ aliases {
+ i2c10 = &bsc0;
+ i2c0 = &i2c0;
+ i2c1 = &i2c1;
+ i2c2 = &i2c2;
+ i2c4 = &i2c_csi_dsi;
+ };
+};
diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
index 013431e..3d6294f 100644
--- a/arch/arm/boot/dts/bcm283x.dtsi
+++ b/arch/arm/boot/dts/bcm283x.dtsi
@@ -415,7 +415,7 @@
status = "disabled";
};
- i2c0: i2c at 7e205000 {
+ bsc0: i2c at 7e205000 {
compatible = "brcm,bcm2835-i2c";
reg = <0x7e205000 0x1000>;
interrupts = <2 21>;
--
2.7.4
More information about the linux-rpi-kernel
mailing list