mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Roland Hieber <rhi@pengutronix.de>
To: Tomaz Solc <tomaz.solc@tablix.org>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/3] ARM: rpi: save fdt that was passed from VideoCore
Date: Tue, 26 Feb 2019 16:18:49 +0100	[thread overview]
Message-ID: <20190226151849.zm76xfyxhevbdn2l@pengutronix.de> (raw)
In-Reply-To: <20190221092848.4488-3-tomaz.solc@tablix.org>

Hi,

On Thu, Feb 21, 2019 at 10:28:47AM +0100, Tomaz Solc wrote:
> On Raspberry Pi, VideoCore firmware creates a device tree that contains
> information about peripherals that were initialized by VideoCore based
> on settings in config.txt. Normally this device tree is passed to the
> Linux kernel via a pointer in the r2 register. A bootloader needs to
> pass this device tree to the kernel, or some peripherals will not work
> correctly.
> 
> Since the VideoCore device tree is not compatible with barebox, we can't
> just pass it to barebox_arm_entry() as the internal barebox device tree.
> 
> This commit makes the prebootloader code copy the device tree from
> VideoCore into a scrap RAM area just above the area reserved for the
> bootloader. Board initialization code in the bootloader proper then
> copies it into a file /vc.dtb. The bootloader environment is then free
> to pass this file to the kernel at boot (e.g. via bootm -o).
> ---
>  Documentation/boards/bcm2835.rst          |  4 ++
>  arch/arm/boards/raspberry-pi/lowlevel.c   | 68 ++++++++++++++++++++++---------
>  arch/arm/boards/raspberry-pi/lowlevel.h   |  9 ++++
>  arch/arm/boards/raspberry-pi/rpi-common.c | 34 ++++++++++++++++
>  4 files changed, 96 insertions(+), 19 deletions(-)
>  create mode 100644 arch/arm/boards/raspberry-pi/lowlevel.h
> 
[...]
> diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
> index b5d16a15c..f17384857 100644
> --- a/arch/arm/boards/raspberry-pi/rpi-common.c
> +++ b/arch/arm/boards/raspberry-pi/rpi-common.c
> @@ -370,12 +375,41 @@ static int rpi_env_init(void)
>  	return 0;
>  }
>  
> +static void rpi_vc_fdt(void)
> +{
> +	void *saved_vc_fdt;
> +	struct fdt_header *oftree;
> +	unsigned long magic, size;
> +
> +	/* VideoCore FDT was copied in PBL just above Barebox memory */
> +	saved_vc_fdt = (void *)(arm_mem_endmem_get());
> +
> +	oftree = saved_vc_fdt;
> +	magic = be32_to_cpu(oftree->magic);
> +	if (magic != FDT_MAGIC) {
> +		printf("videocore fdt saved in pbl has invalid magic\n");

It's more idiomatic to use pr_err() here

> +
> +		if (magic == VIDEOCORE_FDT_ERROR) {
> +			printf("there was an error copying fdt in pbl: %d\n",
> +					be32_to_cpu(oftree->totalsize));

and here

> +		}
> +		return;
> +	}
> +
> +	size = be32_to_cpu(oftree->totalsize);
> +	if (write_file("/vc.dtb", saved_vc_fdt, size)) {
> +		printf("failed to save videocore fdt to a file\n");

and here.

 - Roland

> +		return;
> +	}
> +}
> +
>  static int rpi_devices_init(void)
>  {
>  	rpi_model_init();
>  	bcm2835_register_fb();
>  	armlinux_set_architecture(MACH_TYPE_BCM2708);
>  	rpi_env_init();
> +	rpi_vc_fdt();
>  	return 0;
>  }
>  late_initcall(rpi_devices_init);
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Roland Hieber                     | r.hieber@pengutronix.de     |
Pengutronix e.K.                  | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2019-02-26 15:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21  9:28 [PATCH 0/3] VideoCore FDT interop for Raspberry Pi Tomaz Solc
2019-02-21  9:28 ` [PATCH 1/3] ARM: start: save end of memory passed to start Tomaz Solc
2019-02-21  9:28 ` [PATCH 2/3] ARM: rpi: save fdt that was passed from VideoCore Tomaz Solc
2019-02-26 15:18   ` Roland Hieber [this message]
2019-02-21  9:28 ` [PATCH 3/3] commands: add of_bootargs command Tomaz Solc
2019-02-22  7:49   ` Sascha Hauer
2019-02-22 10:38     ` Tomaž Šolc
2019-02-22 11:08       ` Sascha Hauer
2019-02-26 15:21   ` Roland Hieber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190226151849.zm76xfyxhevbdn2l@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=tomaz.solc@tablix.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox