devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* recommended action for bootloaders regarding modifying device-tree nodes
@ 2014-01-30  9:11 Tim Harvey
       [not found] ` <CAJ+vNU366GiY4k_rnh1Jf0kra+PU99w4tDdM2sNioUAJCiZqOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Harvey @ 2014-01-30  9:11 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Grant Likely

Greetings,

I develop the boot-loader and kernel for a family of boards that have
an on-board EEPROM which contains information as to what options are
physically loaded on the board such as memory size/config, and
peripheral IC's.  We allow customers to create special builds of our
standard products with sub-loaded components and while each
combination of options ends up with a unique model number, it seems
silly to create a different static device-trees for each possible
option (not to mention we don't create the unique model number until
an order is placed).

My approach has been to define a per-baseboard device-tree in Linux
for a 'fully loaded' board, then remove nodes which the EEPROM claims
are not present in the bootloader before it passes the DTB to the
kernel.  I do this by defining aliases in the device-tree for the
peripherals that are 'optional' so that the bootloader itself does not
need to know the details about how the device is connected.

Is it more appropriate for the bootloader to 'remove' nodes for
devices that are not physically present or should I be setting their
status property to 'disabled' instead?  I'm not clear if either option
really has any pros or cons.

Thanks for any suggestions or comments,

Tim

Tim Harvey - Principal Software Engineer
Gateworks Corporation
3026 S. Higuera St. San Luis Obispo CA 93401
805-781-2000
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [U-Boot] recommended action for bootloaders regarding modifying device-tree nodes
       [not found] ` <CAJ+vNU366GiY4k_rnh1Jf0kra+PU99w4tDdM2sNioUAJCiZqOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-01-30  9:22   ` Michal Suchanek
  2014-01-30 20:45   ` Jason Cooper
  1 sibling, 0 replies; 7+ messages in thread
From: Michal Suchanek @ 2014-01-30  9:22 UTC (permalink / raw)
  To: Tim Harvey
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, uboot,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Grant Likely

Hello,

On 30 January 2014 10:11, Tim Harvey <tharvey-UMMOYl/HMS+akBO8gow8eQ@public.gmane.org> wrote:
> Greetings,
>
>
> Is it more appropriate for the bootloader to 'remove' nodes for
> devices that are not physically present or should I be setting their
> status property to 'disabled' instead?  I'm not clear if either option
> really has any pros or cons.
>

I am not a DT or u-boot developer but I observe these things:

1) DT include for a SoC has all supported devices. Some which require
external parts (eg. physical connectors, extra PHY, ...) are listed as
disabled and particular board DT enables them.

2) there is code for setting mac address on ethernet nodes with a
specific alias so you could perhaps reuse this code to set disabled
option on particular nodes.

Thanks

Michal
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: recommended action for bootloaders regarding modifying device-tree nodes
       [not found] ` <CAJ+vNU366GiY4k_rnh1Jf0kra+PU99w4tDdM2sNioUAJCiZqOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2014-01-30  9:22   ` [U-Boot] " Michal Suchanek
@ 2014-01-30 20:45   ` Jason Cooper
       [not found]     ` <20140130204558.GC29184-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Jason Cooper @ 2014-01-30 20:45 UTC (permalink / raw)
  To: Tim Harvey
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Grant Likely

Hi Tim,

On Thu, Jan 30, 2014 at 01:11:18AM -0800, Tim Harvey wrote:
> My approach has been to define a per-baseboard device-tree in Linux
> for a 'fully loaded' board, then remove nodes which the EEPROM claims
> are not present in the bootloader before it passes the DTB to the
> kernel.  I do this by defining aliases in the device-tree for the
> peripherals that are 'optional' so that the bootloader itself does not
> need to know the details about how the device is connected.

This is more of a process question:  Is there any information captured
in your EEPROM that can't be represented in the dtb?  iow, at the point
when you write the EEPROM, why not write the dtb to it as configured?

You could have pre-configured dtsi fragments for each config option, and
then dynamically create the board dts from the order.

I only ask because it would solve the problem below.  However, there's a
lot more to changing a manufacturing process than meets the eye. :)

> Is it more appropriate for the bootloader to 'remove' nodes for
> devices that are not physically present or should I be setting their
> status property to 'disabled' instead?  I'm not clear if either option
> really has any pros or cons.

That depends on how you have it structured.  Is it a valid dtb?
Meaning, do you have four nodes all at the same register address?
Perhaps you could provide an example dts?

thx,

Jason.

> Tim Harvey - Principal Software Engineer
> Gateworks Corporation

btw - one of my first embedded projects was on one of your boards. An
ixp425 with 4 mini-pci slots.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: recommended action for bootloaders regarding modifying device-tree nodes
       [not found]     ` <20140130204558.GC29184-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
@ 2014-01-30 21:15       ` Jason Gunthorpe
       [not found]         ` <20140130211512.GD13372-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2014-01-31  4:39       ` Tim Harvey
  1 sibling, 1 reply; 7+ messages in thread
From: Jason Gunthorpe @ 2014-01-30 21:15 UTC (permalink / raw)
  To: Jason Cooper
  Cc: Tim Harvey, Grant Likely,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg

On Thu, Jan 30, 2014 at 03:45:58PM -0500, Jason Cooper wrote:

> This is more of a process question:  Is there any information captured
> in your EEPROM that can't be represented in the dtb?  iow, at the point
> when you write the EEPROM, why not write the dtb to it as configured?

I can share what we do here.. In our systems the serial EEPROM is only
256 bytes, so storing things in DT format would be challenging.

What we do is have a master DTB that has the union of all our
configurations. The boot process has a very simple bit of code that
runs down the DTB in binary format and replaces entire
OF_DT_BEGIN_NODE->OF_DT_END_NODE regions with OF_DT_NOP.

The NOP approach is very simple, no other changes (eg offset
recalculation) needs to be done to the DT, so we can do this process
with a very small code footprint and without libfdt.

Choosing which sections to drop is done with some combination of
hardwired code and searching for specific property patterns. There are
also a few places where placeholder sections are directly fixed up, eg
a mac address is written into a placeholder of 0s, etc.

So an example might be

   optional_peripheral@10000 {
      orc,board-style = <1>;
      [..]
   }

Eg The board-style number comes from the EEPROM and if board-style !=
1 then the entire stanza is replaced with NOP.

Jason
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: recommended action for bootloaders regarding modifying device-tree nodes
       [not found]     ` <20140130204558.GC29184-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
  2014-01-30 21:15       ` Jason Gunthorpe
@ 2014-01-31  4:39       ` Tim Harvey
       [not found]         ` <CAJ+vNU2zis+1DUCzmegUFw+Z6XATBEPJ+yqMsttp4ENcckHUYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Tim Harvey @ 2014-01-31  4:39 UTC (permalink / raw)
  To: Jason Cooper
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Grant Likely

On Thu, Jan 30, 2014 at 12:45 PM, Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org> wrote:
> Hi Tim,
>
> On Thu, Jan 30, 2014 at 01:11:18AM -0800, Tim Harvey wrote:
>> My approach has been to define a per-baseboard device-tree in Linux
>> for a 'fully loaded' board, then remove nodes which the EEPROM claims
>> are not present in the bootloader before it passes the DTB to the
>> kernel.  I do this by defining aliases in the device-tree for the
>> peripherals that are 'optional' so that the bootloader itself does not
>> need to know the details about how the device is connected.
>
> This is more of a process question:  Is there any information captured
> in your EEPROM that can't be represented in the dtb?  iow, at the point
> when you write the EEPROM, why not write the dtb to it as configured?
>
> You could have pre-configured dtsi fragments for each config option, and
> then dynamically create the board dts from the order.
>
> I only ask because it would solve the problem below.  However, there's a
> lot more to changing a manufacturing process than meets the eye. :)
>

our eeprom config section is only 40 bytes.  It contains a SKU string,
mac addrs, and some bitwise fields for the various optional components
that we can subload.

>> Is it more appropriate for the bootloader to 'remove' nodes for
>> devices that are not physically present or should I be setting their
>> status property to 'disabled' instead?  I'm not clear if either option
>> really has any pros or cons.
>
> That depends on how you have it structured.  Is it a valid dtb?
> Meaning, do you have four nodes all at the same register address?
> Perhaps you could provide an example dts?

yes its a valid dtb - it is just the superset of everything the
baseboard (ie schematic design) can support.

A good example is a custom SKU of a baseboard with ethernet subloaded.
 If the EEPROM says there is no ethernet mac or phy, I would want to
remove or disable the ethernet node from the devicetree.

Another example would be a node for 'gpio-pps' (GPIO based
pulse-per-second) support.  A baseboard design that has a GPS with its
PPS signal tied to a GPIO would define this in the device-tree, but if
the EEPROM says the GPS isn't loaded, I would want to remove or
disable the gps-pps node.

Tim

>
> thx,
>
> Jason.
>
>> Tim Harvey - Principal Software Engineer
>> Gateworks Corporation
>
> btw - one of my first embedded projects was on one of your boards. An
> ixp425 with 4 mini-pci slots.
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: recommended action for bootloaders regarding modifying device-tree nodes
       [not found]         ` <20140130211512.GD13372-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2014-01-31  4:44           ` Tim Harvey
  0 siblings, 0 replies; 7+ messages in thread
From: Tim Harvey @ 2014-01-31  4:44 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Jason Cooper, Grant Likely,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg

On Thu, Jan 30, 2014 at 1:15 PM, Jason Gunthorpe
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote:
>
> On Thu, Jan 30, 2014 at 03:45:58PM -0500, Jason Cooper wrote:
>
> > This is more of a process question:  Is there any information captured
> > in your EEPROM that can't be represented in the dtb?  iow, at the point
> > when you write the EEPROM, why not write the dtb to it as configured?
>
> I can share what we do here.. In our systems the serial EEPROM is only
> 256 bytes, so storing things in DT format would be challenging.
>
> What we do is have a master DTB that has the union of all our
> configurations. The boot process has a very simple bit of code that
> runs down the DTB in binary format and replaces entire
> OF_DT_BEGIN_NODE->OF_DT_END_NODE regions with OF_DT_NOP.
>
> The NOP approach is very simple, no other changes (eg offset
> recalculation) needs to be done to the DT, so we can do this process
> with a very small code footprint and without libfdt.
>
> Choosing which sections to drop is done with some combination of
> hardwired code and searching for specific property patterns. There are
> also a few places where placeholder sections are directly fixed up, eg
> a mac address is written into a placeholder of 0s, etc.
>
> So an example might be
>
>    optional_peripheral@10000 {
>       orc,board-style = <1>;
>       [..]
>    }
>
> Eg The board-style number comes from the EEPROM and if board-style !=
> 1 then the entire stanza is replaced with NOP.
>
> Jason

Jason,

Sounds pretty much like what we are doing.  I am using u-boot and my
current code looks like this:

        /*
         * Peripheral Config:
         *  remove nodes by alias path if EEPROM config tells us the
         *  peripheral is not loaded on the board.
         */
        if (!test_bit(EECONFIG_ETH0, info->config))
                fdt_del_node_and_alias(blob, "ethernet0");
        if (!test_bit(EECONFIG_ETH1, info->config))
                fdt_del_node_and_alias(blob, "ethernet1");
        if (!test_bit(EECONFIG_HDMI_OUT, info->config))
                fdt_del_node_and_alias(blob, "hdmi_out");
        if (!test_bit(EECONFIG_SATA, info->config))
                fdt_del_node_and_alias(blob, "ahci0");
        if (!test_bit(EECONFIG_PCIE, info->config))
                fdt_del_node_and_alias(blob, "pcie");
        if (!test_bit(EECONFIG_SSI0, info->config))
                fdt_del_node_and_alias(blob, "ssi0");
        if (!test_bit(EECONFIG_SSI1, info->config))
                fdt_del_node_and_alias(blob, "ssi1");
...

I've submitted my code to u-boot and have been asked if its more
appropriate to remove nodes as I'm doing above or to mark them as
'disabled'.  From what I can tell there really isn't a rule or
recommendation for this so I think I'll keep doing what I'm doing
above.

Thanks!

Tim
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: recommended action for bootloaders regarding modifying device-tree nodes
       [not found]         ` <CAJ+vNU2zis+1DUCzmegUFw+Z6XATBEPJ+yqMsttp4ENcckHUYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-01-31 16:07           ` Jason Cooper
  0 siblings, 0 replies; 7+ messages in thread
From: Jason Cooper @ 2014-01-31 16:07 UTC (permalink / raw)
  To: Tim Harvey
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	u-boot-0aAXYlwwYIKGBzrmiIFOJg,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Grant Likely

On Thu, Jan 30, 2014 at 08:39:00PM -0800, Tim Harvey wrote:
> On Thu, Jan 30, 2014 at 12:45 PM, Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org> wrote:
> > Hi Tim,
> >
> > On Thu, Jan 30, 2014 at 01:11:18AM -0800, Tim Harvey wrote:
> >> My approach has been to define a per-baseboard device-tree in Linux
> >> for a 'fully loaded' board, then remove nodes which the EEPROM claims
> >> are not present in the bootloader before it passes the DTB to the
> >> kernel.  I do this by defining aliases in the device-tree for the
> >> peripherals that are 'optional' so that the bootloader itself does not
> >> need to know the details about how the device is connected.
> >
> > This is more of a process question:  Is there any information captured
> > in your EEPROM that can't be represented in the dtb?  iow, at the point
> > when you write the EEPROM, why not write the dtb to it as configured?
> >
> > You could have pre-configured dtsi fragments for each config option, and
> > then dynamically create the board dts from the order.
> >
> > I only ask because it would solve the problem below.  However, there's a
> > lot more to changing a manufacturing process than meets the eye. :)
> >
> 
> our eeprom config section is only 40 bytes.  It contains a SKU string,
> mac addrs, and some bitwise fields for the various optional components
> that we can subload.

Ok.

> >> Is it more appropriate for the bootloader to 'remove' nodes for
> >> devices that are not physically present or should I be setting their
> >> status property to 'disabled' instead?  I'm not clear if either option
> >> really has any pros or cons.
> >
> > That depends on how you have it structured.  Is it a valid dtb?
> > Meaning, do you have four nodes all at the same register address?
> > Perhaps you could provide an example dts?
> 
> yes its a valid dtb - it is just the superset of everything the
> baseboard (ie schematic design) can support.
> 
> A good example is a custom SKU of a baseboard with ethernet subloaded.
>  If the EEPROM says there is no ethernet mac or phy, I would want to
> remove or disable the ethernet node from the devicetree.
> 
> Another example would be a node for 'gpio-pps' (GPIO based
> pulse-per-second) support.  A baseboard design that has a GPS with its
> PPS signal tied to a GPIO would define this in the device-tree, but if
> the EEPROM says the GPS isn't loaded, I would want to remove or
> disable the gps-pps node.

I think JasonG's approach is the way to go (inserting nops).  But it's a
matter of preference as long as the output is a valid dtb.

on a side note:  Do you still have to tie your dtb to a version of the
kernel?

thx,

Jason.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-01-31 16:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-30  9:11 recommended action for bootloaders regarding modifying device-tree nodes Tim Harvey
     [not found] ` <CAJ+vNU366GiY4k_rnh1Jf0kra+PU99w4tDdM2sNioUAJCiZqOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-30  9:22   ` [U-Boot] " Michal Suchanek
2014-01-30 20:45   ` Jason Cooper
     [not found]     ` <20140130204558.GC29184-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2014-01-30 21:15       ` Jason Gunthorpe
     [not found]         ` <20140130211512.GD13372-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2014-01-31  4:44           ` Tim Harvey
2014-01-31  4:39       ` Tim Harvey
     [not found]         ` <CAJ+vNU2zis+1DUCzmegUFw+Z6XATBEPJ+yqMsttp4ENcckHUYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-31 16:07           ` Jason Cooper

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