Add a devicetree overlay to support the official Raspberry Pi 7inch touchscreen.
This also demuxes the i2c0 controller to support both pinctrls.
Changes in v2:
* The device tree in now an overlay
* The i2c demux patch is kept for now to have a working patch set. It has
not been merged yet in [1].
* The device tree overlay doesn't use fragments. It is working as is
but not enough literature was found to go one way or the other.
[1] https://www.spinics.net/lists/arm-kernel/msg944330.html
Detlev Casanova (3):
ARM: dts: bcm2*: Demux i2c0 with a pinctrl
of: Add support for -@ when compiling overlays
ARM: dto: Add bcm2711-rpi-7-inches-ts.dts overlay
arch/arm/boot/dts/Makefile | 4 +
arch/arm/boot/dts/bcm2711-rpi-4-b.dts | 1 +
arch/arm/boot/dts/bcm2711.dtsi | 2 +-
arch/arm/boot/dts/bcm2835-rpi.dtsi | 9 +-
.../boot/dts/bcm283x-rpi-i2c0mux_0_44.dtsi | 4 +
arch/arm/boot/dts/bcm283x.dtsi | 26 +++-
arch/arm/boot/dts/overlays/Makefile | 3 +
.../dts/overlays/bcm2711-rpi-7-inches-ts.dts | 125 ++++++++++++++++++
arch/arm64/boot/dts/broadcom/Makefile | 4 +
.../arm64/boot/dts/broadcom/overlays/Makefile | 3 +
.../overlays/bcm2711-rpi-7-inches-ts.dts | 2 +
drivers/of/Kconfig | 8 ++
scripts/Makefile.lib | 9 +-
13 files changed, 193 insertions(+), 7 deletions(-)
create mode 100644 arch/arm/boot/dts/bcm283x-rpi-i2c0mux_0_44.dtsi
create mode 100644 arch/arm/boot/dts/overlays/Makefile
create mode 100644 arch/arm/boot/dts/overlays/bcm2711-rpi-7-inches-ts.dts
create mode 100644 arch/arm64/boot/dts/broadcom/overlays/Makefile
create mode 100644 arch/arm64/boot/dts/broadcom/overlays/bcm2711-rpi-7-inches-ts.dts
--
2.36.0
This commit adds an option to compile all device trees with -@ to add the
symbol table to the Device Tree Blobs.
It prepares the introduction of device tree overlays that are
not applied on device trees at compile time (dtbo files.)
These device tree overlays will be used by either a bootloader or a
linux userspace tool to extend the base device tree.
This is used e.g. for drivers that need device tree nodes for optional
non plug and play devices, like an external DSI touchscreen panel that
embeds different i2c devices to control it.
Signed-off-by: Detlev Casanova <[email protected]>
---
drivers/of/Kconfig | 8 ++++++++
scripts/Makefile.lib | 9 +++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 80b5fd44ab1c..28cf8d18ac45 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -76,11 +76,19 @@ config OF_RESERVED_MEM
config OF_RESOLVE
bool
+config OF_SYMBOLS
+ bool "Include device tree symbols"
+ help
+ Loading a device tree overlay dynamically can require the base
+ device tree symbols to be present.
+ If this is enabled, the device tree blobs will be bigger.
+
config OF_OVERLAY
bool "Device Tree overlays"
select OF_DYNAMIC
select OF_FLATTREE
select OF_RESOLVE
+ select OF_SYMBOLS
help
Overlays are a method to dynamically modify part of the kernel's
device tree with dynamically loaded data.
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 79be57fdd32a..4c330e565297 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -319,8 +319,13 @@ endif
DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
-# Set -@ if the target is a base DTB that overlay is applied onto
-DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@)
+ifeq ($(CONFIG_OF_SYMBOLS),y)
+ # Add symbols in all devicetrees
+ DTC_FLAGS += -@
+else
+ # Set -@ if the target is a base DTB that overlay is applied onto
+ DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@)
+endif
# Generate an assembly file to wrap the output of the device tree compiler
quiet_cmd_dt_S_dtb= DTB $@
--
2.36.0
The i2c0 device has 2 different busses controlled by a pinctrl.
This commit separates the device node into 2 i2c devices:
* pin 0: Base i2c bus
* pin 44: DSI i2c bus
i2c0 is renamed to i2c0if so that device-trees referencing i2c0 don't
break and use the i2c0 node defined in i2c0mux node.
i2c_csi_dsi can be used to control devices via the DSI i2c bus, used for
DSI displays.
Signed-off-by: Detlev Casanova <[email protected]>
---
arch/arm/boot/dts/bcm2711-rpi-4-b.dts | 1 +
arch/arm/boot/dts/bcm2711.dtsi | 2 +-
arch/arm/boot/dts/bcm2835-rpi.dtsi | 9 ++++---
.../boot/dts/bcm283x-rpi-i2c0mux_0_44.dtsi | 4 +++
arch/arm/boot/dts/bcm283x.dtsi | 26 ++++++++++++++++++-
5 files changed, 37 insertions(+), 5 deletions(-)
create mode 100644 arch/arm/boot/dts/bcm283x-rpi-i2c0mux_0_44.dtsi
diff --git a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
index 4432412044de..5dcce58817e6 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
@@ -4,6 +4,7 @@
#include "bcm2711-rpi.dtsi"
#include "bcm283x-rpi-usb-peripheral.dtsi"
#include "bcm283x-rpi-wifi-bt.dtsi"
+#include "bcm283x-rpi-i2c0mux_0_44.dtsi"
/ {
compatible = "raspberrypi,4-model-b", "brcm,bcm2711";
diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
index dff18fc9a906..96209ed89c36 100644
--- a/arch/arm/boot/dts/bcm2711.dtsi
+++ b/arch/arm/boot/dts/bcm2711.dtsi
@@ -1045,7 +1045,7 @@ &cma {
alloc-ranges = <0x0 0x00000000 0x40000000>;
};
-&i2c0 {
+&i2c0if {
compatible = "brcm,bcm2711-i2c", "brcm,bcm2835-i2c";
interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
};
diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi b/arch/arm/boot/dts/bcm2835-rpi.dtsi
index 87ddcad76083..1e38f9f0e80e 100644
--- a/arch/arm/boot/dts/bcm2835-rpi.dtsi
+++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi
@@ -49,13 +49,16 @@ alt0: alt0 {
};
};
-&i2c0 {
- pinctrl-names = "default";
- pinctrl-0 = <&i2c0_gpio0>;
+&i2c0if {
status = "okay";
clock-frequency = <100000>;
};
+&i2c0mux {
+ pinctrl-0 = <&i2c0_gpio0>;
+ status = "okay";
+};
+
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_gpio2>;
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 000000000000..119946d878db
--- /dev/null
+++ b/arch/arm/boot/dts/bcm283x-rpi-i2c0mux_0_44.dtsi
@@ -0,0 +1,4 @@
+&i2c0mux {
+ pinctrl-0 = <&i2c0_gpio0>;
+ pinctrl-1 = <&i2c0_gpio44>;
+};
diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
index c113661a6668..62d7ee513549 100644
--- a/arch/arm/boot/dts/bcm283x.dtsi
+++ b/arch/arm/boot/dts/bcm283x.dtsi
@@ -336,7 +336,7 @@ spi: spi@7e204000 {
status = "disabled";
};
- i2c0: i2c@7e205000 {
+ i2c0if: i2c@7e205000 {
compatible = "brcm,bcm2835-i2c";
reg = <0x7e205000 0x200>;
interrupts = <2 21>;
@@ -346,6 +346,30 @@ i2c0: i2c@7e205000 {
status = "disabled";
};
+ i2c0mux: i2c0mux {
+ compatible = "i2c-mux-pinctrl";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ i2c-parent = <&i2c0if>;
+
+ pinctrl-names = "i2c0", "i2c_csi_dsi";
+
+ status = "disabled";
+
+ i2c0: i2c@0 {
+ reg = <0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
+
+ i2c_csi_dsi: i2c@1 {
+ reg = <1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
+ };
+
dpi: dpi@7e208000 {
compatible = "brcm,bcm2835-dpi";
reg = <0x7e208000 0x8c>;
--
2.36.0
On Wed, Apr 27, 2022 at 02:52:42PM -0400, Detlev Casanova wrote:
> This commit adds an option to compile all device trees with -@ to add the
> symbol table to the Device Tree Blobs.
Why would we want to tie this to the kernel config?
Globally enabling it has already been discussed and rejected.
> It prepares the introduction of device tree overlays that are
> not applied on device trees at compile time (dtbo files.)
>
> These device tree overlays will be used by either a bootloader or a
> linux userspace tool to extend the base device tree.
>
> This is used e.g. for drivers that need device tree nodes for optional
> non plug and play devices, like an external DSI touchscreen panel that
> embeds different i2c devices to control it.
You can already set DTC_FLAGS per directory (and target?), so enable it
for the dtbs that have overlays.
>
> Signed-off-by: Detlev Casanova <[email protected]>
> ---
> drivers/of/Kconfig | 8 ++++++++
> scripts/Makefile.lib | 9 +++++++--
> 2 files changed, 15 insertions(+), 2 deletions(-)
On 4/27/2022 2:24 PM, Rob Herring wrote:
> On Wed, Apr 27, 2022 at 02:52:42PM -0400, Detlev Casanova wrote:
>> This commit adds an option to compile all device trees with -@ to add the
>> symbol table to the Device Tree Blobs.
>
> Why would we want to tie this to the kernel config?
>
> Globally enabling it has already been discussed and rejected.
>
>> It prepares the introduction of device tree overlays that are
>> not applied on device trees at compile time (dtbo files.)
>>
>> These device tree overlays will be used by either a bootloader or a
>> linux userspace tool to extend the base device tree.
>>
>> This is used e.g. for drivers that need device tree nodes for optional
>> non plug and play devices, like an external DSI touchscreen panel that
>> embeds different i2c devices to control it.
>
> You can already set DTC_FLAGS per directory (and target?), so enable it
> for the dtbs that have overlays.
Looks like this patch series from Aurelien should take care of that:
https://lore.kernel.org/linux-arm-kernel/20220427233607.1225419-1-
[email protected]/
--
Florian