linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Using device tree overlays in Linux
@ 2019-04-04  1:50 Chris Packham
  2019-04-06  6:07 ` Rob Herring
  2019-04-08  1:05 ` Frank Rowand
  0 siblings, 2 replies; 8+ messages in thread
From: Chris Packham @ 2019-04-04  1:50 UTC (permalink / raw)
  To: pantelis.antoniou, frowand.list, robh+dt
  Cc: devicetree, linux-kernel, Hamish Martin

Hi,

I'm implementing support for some modular Linux based systems using 
device tree overlays. The code is working but it seems a little more 
fiddly that than it should be so I'm wondering if I'm doing it right.

An example of what I'm doing is


arch/arm/boot/dts/Makefile:
DTC_FLAGS_myboard += -@

drivers/foo/Makefile:
obj-y += myplugin.dtb.o
obj-y += mydriver.o

drivers/foo/myplugin.dts:
/dts-v1/;
/plugin/;
/{
	fragment@0 {
		target = <&i2c0>;
		__overlay__ {
			gpio@74 {
				compatible = "nxp,pca9539";
				reg = <0x74>
			};
		};
	};
};

drivers/foo/mydriver.c:
extern uint8_t __dtb_myplugin_begin[];
extern uint8_t __dtb_myplugin_end[];

int mydriver_probe(struct platform_device *pdev)
{
	u32 size = __dtb_myplugin_end - __dtb_myplugin_begin;
	int overlay_id;
	int ret;
	
	ret = of_overlay_fdt_apply(__dtb_myplugin_begin,
				   size, &overlay_id);
	return ret;
}


The first issue is that I need to add -@ to the DTC_FLAGS for my board 
dtb. I kind of understand that I only need -@ if my overlay targets 
something symbolic so I might not need it but I was surprised that there 
wasn't a Kconfig option that makes this happen automatically.

externing things in C files makes checkpatch.pl complain. I see the 
of/unittests.c and rcar_du_of.c hide this with a macro. I was again 
surprised that there wasn't a common macro to declare these.



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

end of thread, other threads:[~2019-04-09 20:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-04  1:50 Using device tree overlays in Linux Chris Packham
2019-04-06  6:07 ` Rob Herring
2019-04-08  1:05 ` Frank Rowand
2019-04-08  1:27   ` Chris Packham
2019-04-09 19:19     ` Frank Rowand
2019-04-09 20:54       ` Chris Packham
2019-04-09 19:33     ` Frank Rowand
2019-04-09 20:47       ` Chris Packham

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).