All of lore.kernel.org
 help / color / mirror / Atom feed
* Is there a reason not to use -@ to compile devicetrees ?
@ 2020-12-21 14:47 Vincent Pelletier
  2021-01-05  0:47 ` Vincent Pelletier
  2021-01-05  2:08 ` Rob Herring
  0 siblings, 2 replies; 6+ messages in thread
From: Vincent Pelletier @ 2020-12-21 14:47 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek; +Cc: Rob Herring, linux-kbuild, linux-kernel

Hello,

Distro: https://raspi.debian.net/ (sid)
Hardware: Raspberry Pi Zero W
Kernel version: 5.9.11 (linux-image-5.9.0-4-rpi)

To access a device connected to my pi, I need the spi0 bus, and would
like to not be doing GPIO bit-banging when there are perfectly good
spi modules capable of using the SPI alternative mode of these pins.

spi0 is declared in the vanilla devicetree for this device:
arch/arm/boot/dts/bcm2835-rpi-zero-w.dts ends up including
arch/arm/boot/dts/bcm283x.dtsi which contains:
                spi: spi@7e204000 {
                        compatible = "brcm,bcm2835-spi";
                        reg = <0x7e204000 0x200>;
                        interrupts = <2 22>;
                        clocks = <&clocks BCM2835_CLOCK_VPU>;
                        #address-cells = <1>;
                        #size-cells = <0>;
                        status = "disabled";
                };
To my new-to-devicetree eye, this looks like this is intended to be
overridden, at least with a
  status = "okay";
property (although a bit more is needed).
As I believe is the correct way, I wrote a devicetree overlay doing
this and a bit more in order to enable this bus and one of its device
(the one matching the chip-select monitored by the board I connected).

To confirm that I had no typo in my symbol names I ran fdtoverlay with
the packaged device tree binary, plus my overlay, but could not get it
to work, until I took a closer look at the packaged device tree and
realised it lacks a __symbols__ section.
So I pulled the source, added "-@" to the cmd_dtc rule in
scripts/Makefile.lib, built the dtb, tested fdtoverlay against it and
voila, it worked. I could then reboot with this devicetree, load my
overlay and use spi0 with no further change.

So now I wonder why this option is not enabled while there are these
sections which seem to not be usable without an overlay ?
And further, why it does not seem to be possible to enable with a
kernel config option ?

I must be missing something obvious, but I'm still failing to see it.

Regards,
-- 
Vincent Pelletier

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is there a reason not to use -@ to compile devicetrees ?
  2020-12-21 14:47 Is there a reason not to use -@ to compile devicetrees ? Vincent Pelletier
@ 2021-01-05  0:47 ` Vincent Pelletier
  2021-01-05  2:08 ` Rob Herring
  1 sibling, 0 replies; 6+ messages in thread
From: Vincent Pelletier @ 2021-01-05  0:47 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek; +Cc: Rob Herring, linux-kbuild, linux-kernel

Ping ?

On Mon, 21 Dec 2020 14:47:07 +0000, Vincent Pelletier <plr.vincent@gmail.com> wrote:
> Distro: https://raspi.debian.net/ (sid)
> Hardware: Raspberry Pi Zero W
> Kernel version: 5.9.11 (linux-image-5.9.0-4-rpi)
> 
> To access a device connected to my pi, I need the spi0 bus, and would
> like to not be doing GPIO bit-banging when there are perfectly good
> spi modules capable of using the SPI alternative mode of these pins.
> 
> spi0 is declared in the vanilla devicetree for this device:
> arch/arm/boot/dts/bcm2835-rpi-zero-w.dts ends up including
> arch/arm/boot/dts/bcm283x.dtsi which contains:
>                 spi: spi@7e204000 {
>                         compatible = "brcm,bcm2835-spi";
>                         reg = <0x7e204000 0x200>;
>                         interrupts = <2 22>;
>                         clocks = <&clocks BCM2835_CLOCK_VPU>;
>                         #address-cells = <1>;
>                         #size-cells = <0>;
>                         status = "disabled";
>                 };
> To my new-to-devicetree eye, this looks like this is intended to be
> overridden, at least with a
>   status = "okay";
> property (although a bit more is needed).
> As I believe is the correct way, I wrote a devicetree overlay doing
> this and a bit more in order to enable this bus and one of its device
> (the one matching the chip-select monitored by the board I connected).
> 
> To confirm that I had no typo in my symbol names I ran fdtoverlay with
> the packaged device tree binary, plus my overlay, but could not get it
> to work, until I took a closer look at the packaged device tree and
> realised it lacks a __symbols__ section.
> So I pulled the source, added "-@" to the cmd_dtc rule in
> scripts/Makefile.lib, built the dtb, tested fdtoverlay against it and
> voila, it worked. I could then reboot with this devicetree, load my
> overlay and use spi0 with no further change.
> 
> So now I wonder why this option is not enabled while there are these
> sections which seem to not be usable without an overlay ?
> And further, why it does not seem to be possible to enable with a
> kernel config option ?
> 
> I must be missing something obvious, but I'm still failing to see it.
-- 
Vincent Pelletier

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is there a reason not to use -@ to compile devicetrees ?
  2020-12-21 14:47 Is there a reason not to use -@ to compile devicetrees ? Vincent Pelletier
  2021-01-05  0:47 ` Vincent Pelletier
@ 2021-01-05  2:08 ` Rob Herring
  2021-01-06  1:09   ` Vincent Pelletier
  1 sibling, 1 reply; 6+ messages in thread
From: Rob Herring @ 2021-01-05  2:08 UTC (permalink / raw)
  To: Vincent Pelletier
  Cc: Masahiro Yamada, Michal Marek, Linux Kbuild mailing list, linux-kernel

On Mon, Dec 21, 2020 at 7:47 AM Vincent Pelletier <plr.vincent@gmail.com> wrote:
>
> Hello,
>
> Distro: https://raspi.debian.net/ (sid)
> Hardware: Raspberry Pi Zero W
> Kernel version: 5.9.11 (linux-image-5.9.0-4-rpi)
>
> To access a device connected to my pi, I need the spi0 bus, and would
> like to not be doing GPIO bit-banging when there are perfectly good
> spi modules capable of using the SPI alternative mode of these pins.
>
> spi0 is declared in the vanilla devicetree for this device:
> arch/arm/boot/dts/bcm2835-rpi-zero-w.dts ends up including
> arch/arm/boot/dts/bcm283x.dtsi which contains:
>                 spi: spi@7e204000 {
>                         compatible = "brcm,bcm2835-spi";
>                         reg = <0x7e204000 0x200>;
>                         interrupts = <2 22>;
>                         clocks = <&clocks BCM2835_CLOCK_VPU>;
>                         #address-cells = <1>;
>                         #size-cells = <0>;
>                         status = "disabled";
>                 };
> To my new-to-devicetree eye, this looks like this is intended to be
> overridden, at least with a
>   status = "okay";
> property (although a bit more is needed).
> As I believe is the correct way, I wrote a devicetree overlay doing
> this and a bit more in order to enable this bus and one of its device
> (the one matching the chip-select monitored by the board I connected).
>
> To confirm that I had no typo in my symbol names I ran fdtoverlay with
> the packaged device tree binary, plus my overlay, but could not get it
> to work, until I took a closer look at the packaged device tree and
> realised it lacks a __symbols__ section.
> So I pulled the source, added "-@" to the cmd_dtc rule in
> scripts/Makefile.lib, built the dtb, tested fdtoverlay against it and
> voila, it worked. I could then reboot with this devicetree, load my
> overlay and use spi0 with no further change.
>
> So now I wonder why this option is not enabled while there are these
> sections which seem to not be usable without an overlay ?
> And further, why it does not seem to be possible to enable with a
> kernel config option ?
>
> I must be missing something obvious, but I'm still failing to see it.

Read the last time this came up:

https://lore.kernel.org/linux-devicetree/71fb0ff289e84c55bd92ecd96bc9aa76@svr-chch-ex1.atlnz.lc/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is there a reason not to use -@ to compile devicetrees ?
  2021-01-05  2:08 ` Rob Herring
@ 2021-01-06  1:09   ` Vincent Pelletier
  2021-01-06  1:09     ` of: Add OF_SYMBOLS Vincent Pelletier
  0 siblings, 1 reply; 6+ messages in thread
From: Vincent Pelletier @ 2021-01-06  1:09 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, devicetree

Hello,

> Read the last time this came up:
> 
> https://lore.kernel.org/linux-devicetree/71fb0ff289e84c55bd92ecd96bc9aa76@svr-chch-ex1.atlnz.lc/

Thanks a lot, this answers my question.

In my case, I do not expect the kernel to apply the overlay, so I believe
I avoid 99% of the complexity mentionned in that thread.

Would the following patch (in reply) be acceptable ?

Especially:
- Is it fine to add such config option without selecting it anywhere ?
- DTC_FLAGS_overlay* and DTC_FLAGS_testcases can contain -@, should I try
  to figure a way out to make them select this option ?

Regards,
Vincent Pelletier



^ permalink raw reply	[flat|nested] 6+ messages in thread

* of: Add OF_SYMBOLS
  2021-01-06  1:09   ` Vincent Pelletier
@ 2021-01-06  1:09     ` Vincent Pelletier
  2021-01-06 15:47       ` Rob Herring
  0 siblings, 1 reply; 6+ messages in thread
From: Vincent Pelletier @ 2021-01-06  1:09 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, devicetree

Allows telling dtc to emit the __symbols__ section in produced Device Tree
Blobs, which in turn allows using overlay Device Tree Blobs which reference
nodes from the base Device Tree using such symbols.
This does not presume of what will apply the overlay (bootloader, kernel,
fdtoverlay...).

Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
---
 drivers/of/Kconfig   | 8 ++++++++
 scripts/Makefile.lib | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 18450437d5d5..2f3db2241561 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -93,6 +93,14 @@ config OF_OVERLAY
 	  While this option is selected automatically when needed, you can
 	  enable it manually to improve device tree unit test coverage.
 
+config OF_SYMBOLS
+	bool "Include symbols in generated Device Tree Blobs"
+	help
+	  This option tells the Device Tree compiler to generate __symbols__
+	  sections in all produced Device Tree Blobs.
+	  Useful for Device Tree overlays, be they applied by the kernel or by
+	  a bootloader, at a slight increase in file size.
+
 config OF_NUMA
 	bool
 
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 213677a5ed33..402c2a5158db 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -299,6 +299,10 @@ endif
 
 DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
 
+ifeq ($(CONFIG_OF_SYMBOLS),y)
+DTC_FLAGS += -@
+endif
+
 # Generate an assembly file to wrap the output of the device tree compiler
 quiet_cmd_dt_S_dtb= DTB     $@
 cmd_dt_S_dtb=						\
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: of: Add OF_SYMBOLS
  2021-01-06  1:09     ` of: Add OF_SYMBOLS Vincent Pelletier
@ 2021-01-06 15:47       ` Rob Herring
  0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2021-01-06 15:47 UTC (permalink / raw)
  To: Vincent Pelletier; +Cc: Frank Rowand, devicetree

On Tue, Jan 5, 2021 at 6:10 PM Vincent Pelletier <plr.vincent@gmail.com> wrote:
>
> Allows telling dtc to emit the __symbols__ section in produced Device Tree
> Blobs, which in turn allows using overlay Device Tree Blobs which reference
> nodes from the base Device Tree using such symbols.
> This does not presume of what will apply the overlay (bootloader, kernel,
> fdtoverlay...).

A global option is not something we're going to accept. It needs to be
per dtb or soc family at least.

IIRC, you can just set DTC_FLAGS on the make command line if you want
to enable symbols globally.

Also, note that Viresh is working on adding overlay support[1].

Rob

[1] https://lore.kernel.org/linux-devicetree/cover.1609844956.git.viresh.kumar@linaro.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-06 15:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21 14:47 Is there a reason not to use -@ to compile devicetrees ? Vincent Pelletier
2021-01-05  0:47 ` Vincent Pelletier
2021-01-05  2:08 ` Rob Herring
2021-01-06  1:09   ` Vincent Pelletier
2021-01-06  1:09     ` of: Add OF_SYMBOLS Vincent Pelletier
2021-01-06 15:47       ` Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.