[U-Boot] [PATCH 06/17] dm: Add callback to modify the device tree

Maxime Ripard maxime.ripard at free-electrons.com
Mon Dec 5 10:47:57 CET 2016


On Thu, Dec 01, 2016 at 09:39:14AM +0100, Stefan Roese wrote:
> (Adding Simon and Maxim to Cc)
> 
> On 23.11.2016 16:12, Mario Six wrote:
> > Certain boards come in different variations by way of utilizing daughter
> > boards, for example. These boards might contain additional chips, which
> > are added to the main board's busses, e.g. I2C.
> > 
> > The device tree support for such boards would either, quite naturally,
> > employ the overlay mechanism to add such chips to the tree, or would use
> > one large default device tree, and delete the devices that are actually
> > not present.
> > 
> > Regardless of approach, even on the U-Boot level, a modification of the
> > device tree is a prerequisite to have such modular families of boards
> > supported properly.
> > 
> > Therefore, we add an option to make the U-Boot device tree (the actual
> > copy later used by the driver model) writeable, and add a callback
> > method that allows boards to modify the device tree at an early stage,
> > at which, hopefully, also the application of device tree overlays will
> > be possible.
> > 
> > Signed-off-by: Mario Six <mario.six at gdsys.cc>
> 
> I didn't follow DT overlay lately closely especially not in U-Boot.
> Simon, Maxim could you please take a look at this patch and comment
> on its necessity?
> 
> > ---
> >  common/board_f.c                  |  3 +++
> >  dts/Kconfig                       | 10 ++++++++++
> >  include/asm-generic/global_data.h |  4 ++++
> >  include/common.h                  |  1 +
> >  4 files changed, 18 insertions(+)
> > 
> > diff --git a/common/board_f.c b/common/board_f.c
> > index 4b74835..cda5aae 100644
> > --- a/common/board_f.c
> > +++ b/common/board_f.c
> > @@ -1034,6 +1034,9 @@ static init_fnc_t init_sequence_f[] = {
> >  #ifdef CONFIG_SYS_EXTBDINFO
> >  	setup_board_extra,
> >  #endif
> > +#ifdef CONFIG_OF_BOARD_FIXUP
> > +	board_fix_fdt,
> > +#endif
> >  	INIT_FUNC_WATCHDOG_RESET
> >  	reloc_fdt,
> >  	setup_reloc,
> > diff --git a/dts/Kconfig b/dts/Kconfig
> > index 4b7d8b1..3f64eda 100644
> > --- a/dts/Kconfig
> > +++ b/dts/Kconfig
> > @@ -14,6 +14,16 @@ config OF_CONTROL
> >  	  This feature provides for run-time configuration of U-Boot
> >  	  via a flattened device tree.
> > 
> > +config OF_BOARD_FIXUP
> > +	bool "Board-specific manipulation of Device Tree"
> > +	help
> > +	  In certain circumstances it is necessary to be able to modify
> > +	  U-Boot's device tree (e.g. to delete device from it). This option
> > +	  make the Device Tree writeable and provides a board-specific
> > +	  "board_fix_fdt" callback (called during pre-relocation time), which
> > +	  enables the board initialization to modifiy the Device Tree. The
> > +	  modified copy is subsequently used by U-Boot after relocation.
> > +

Judging from the help, I guess this is going to be applied even before
the device model initialization. Since our plan is to eventually
switch to the device model, and you'll probably need someway to detect
which adjustments you need to make (using a GPIO, some bus, etc.)
which is probably going to be backed by a device model
driver. Wouldn't that introduce a chicken and egg issue?

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161205/7d6cfdcd/attachment.sig>


More information about the U-Boot mailing list