[U-Boot] How to re-use the driver data for pre-reloc in post-reloc driver

Simon Glass sjg at chromium.org
Tue Dec 19 15:41:45 UTC 2017


+Tom, Wolfgang, Masahiro

Hi Kever,

On 12 December 2017 at 21:35, Kever Yang <kever.yang at rock-chips.com> wrote:
> Hi Simon,
>
>     This is not the topic about disable the relocate feature in U-Boot
> proper.
>
> My target is re-use kernel dtb in U-Boot and U-Boot can work properly even
> if
> some of dts node in kernel is broken.
> - U-Boot mark a set of driver as u-boot,dm-pre-reloc, suppose to able to get
>    into U-Boot shell with them. dram, syscon, serial, clock, pinctrl, emmc,
> and etc.
>     In this case we can always make U-Boot works and get into shell.
> - When relocate, I would like to read dtb from kernel and use it for U-Boot
> driver.
>     In this case, we can get periph driver setting for different board from
> kernel dtb,
>     what we need most are: power/pmic, display, charger, input key and etc.
>
> The problem is, the dm architecture now always init all the driver from dtb
> after relocate,
> If anything missin in kernel dtb, the U-Boot hang there. What I met now in
> rockchip
> kernel(same in different SoCs) is:
> - no stdout in chosen, we use cmdline instead;
> - debug uart node not enabled; we may use ttyFIQ driver instead of uart
> driver for it.
> - no alias for emmc/sd, which is much in U-Boot;
> - compaptible for syscon may different, kernel may use "syscon",
> "simple-mfd" only,
>     but U-Boot need "rockchip,rk3228-grf" for GRF and "rockchip,rk3228-PMU"
> for PMU and etc.
> Of cause I can update kernel source, but as you can see we are not able to
> cover all the case
> because kernel may have different use with U-Boot.

One option is to fix up the kernel DT using code, e.g. in the
fix_fdt() function.

Another is to fix the Linux DT. I think the above could all be fixed
without complaints from Linux. Could you try that? We should use
exactly the same DT for Linux and U-Boot. Even the u-boot,dm-* should
be able to be sent upstream, based on my understanding of a discussion
at ELCE.

>
> If we do not need to re-init all the driver after relocate, or re-use the
> driver data,
> then we can have a robust U-Boot only depends on U-Boot dtb with
> dm-pre-reloc,
> and we can have a good compatibility U-Boot with kernel dtb support for
> different board/periph.
> Then U-Boot focus on SoC support, kernel focus on all kinds of board/periph
> support,
> U-Boot need to sync periph driver from kernel, so that if kernel works then
> U-Boot also works, developers
> do not need to develop one for kernel and one for U-Boot.
>
> Could you help to make a demo patch about how to re-use the driver-data of
> pre-reloc to post-reloc?

I don't think this is a good way to solve the problem. Masahiro has
suggested that we eliminate pre-relocatiom U-Boot when using SPL, so
in this case we would not have the ability to use a separate DT for
pre-relocation and post-relocation U-Boot.

As to your goal of avoiding device re-init, Masahiro's idea (if
implemented) would avoid the need to re-init (SPL would still do it
but that is a separate program).

That said, I will see if I can come up with a patch to allow access to
driver data from a previous driver-model data structure. I worry that
it would be a bit fiddly though.

Regards,
Simon


More information about the U-Boot mailing list