linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Conditionals in dtsi files
@ 2015-11-13  9:33 Mason
  2015-11-13  9:43 ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Mason @ 2015-11-13  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

I'm wondering how much C preprocessor syntax one can use in DT files.

Suppose I have 2 board DTS (both including common.dtsi)

board_A.dts (1-core), board_B.dts (2-core)

Can I have in common.dtsi something along these lines:

	cpus {
		enable-method = "foo,bar";
		#address-cells = <1>;
		#size-cells = <0>;

		cpu0: cpu at 0 {
			compatible = "arm,cortex-a9";
			device_type = "cpu";
			reg = <0>;
		};

#if CORE_COUNT > 1
		cpu1: cpu at 1 {
			compatible = "arm,cortex-a9";
			device_type = "cpu";
			reg = <1>;
		};
#endif
	};


board_A.dts would have
#define CORE_COUNT 1
#include "common.dtsi"

board_B.dts would have
#define CORE_COUNT 2
#include "common.dtsi"

Regards.

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

* Conditionals in dtsi files
  2015-11-13  9:33 Conditionals in dtsi files Mason
@ 2015-11-13  9:43 ` Arnd Bergmann
  2015-11-13 11:15   ` Mark Rutland
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2015-11-13  9:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 13 November 2015 10:33:50 Mason wrote:
> Hello,
> 
> I'm wondering how much C preprocessor syntax one can use in DT files.
> 
> Suppose I have 2 board DTS (both including common.dtsi)
> 
> board_A.dts (1-core), board_B.dts (2-core)
> 
> Can I have in common.dtsi something along these lines:
> 
> 	cpus {
> 		enable-method = "foo,bar";
> 		#address-cells = <1>;
> 		#size-cells = <0>;
> 
> 		cpu0: cpu at 0 {
> 			compatible = "arm,cortex-a9";
> 			device_type = "cpu";
> 			reg = <0>;
> 		};
> 
> #if CORE_COUNT > 1
> 		cpu1: cpu at 1 {
> 			compatible = "arm,cortex-a9";
> 			device_type = "cpu";
> 			reg = <1>;
> 		};
> #endif
> 	};
> 
> 
> board_A.dts would have
> #define CORE_COUNT 1
> #include "common.dtsi"
> 
> board_B.dts would have
> #define CORE_COUNT 2
> #include "common.dtsi"

I would prefer not using any preprocessor statements other than
#include in .dts files. It's easy enough to have a per-soc
.dtsi file that defines the CPU nodes and goes on to include another
.dtsi file with the common parts that are present on all SoCs.

Have a look at how the armada-*.dtsi files handle this.

	Arnd

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

* Conditionals in dtsi files
  2015-11-13  9:43 ` Arnd Bergmann
@ 2015-11-13 11:15   ` Mark Rutland
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Rutland @ 2015-11-13 11:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Nov 13, 2015 at 10:43:11AM +0100, Arnd Bergmann wrote:
> On Friday 13 November 2015 10:33:50 Mason wrote:
> > Hello,
> > 
> > I'm wondering how much C preprocessor syntax one can use in DT files.
> > 
> > Suppose I have 2 board DTS (both including common.dtsi)
> > 
> > board_A.dts (1-core), board_B.dts (2-core)
> > 
> > Can I have in common.dtsi something along these lines:
> > 
> > 	cpus {
> > 		enable-method = "foo,bar";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 
> > 		cpu0: cpu at 0 {
> > 			compatible = "arm,cortex-a9";
> > 			device_type = "cpu";
> > 			reg = <0>;
> > 		};
> > 
> > #if CORE_COUNT > 1
> > 		cpu1: cpu at 1 {
> > 			compatible = "arm,cortex-a9";
> > 			device_type = "cpu";
> > 			reg = <1>;
> > 		};
> > #endif
> > 	};
> > 
> > 
> > board_A.dts would have
> > #define CORE_COUNT 1
> > #include "common.dtsi"
> > 
> > board_B.dts would have
> > #define CORE_COUNT 2
> > #include "common.dtsi"
> 
> I would prefer not using any preprocessor statements other than
> #include in .dts files.

I very much agree with this.

We should only have (simple) macros for symbolic names, and #includes
required for those to work.

Thanks,
Mark.

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

end of thread, other threads:[~2015-11-13 11:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-13  9:33 Conditionals in dtsi files Mason
2015-11-13  9:43 ` Arnd Bergmann
2015-11-13 11:15   ` Mark Rutland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).