public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lokesh Vutla <lokeshvutla@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 13/16] ARM: omap5: add hooks for cpu/SoC fdt fixups
Date: Fri, 15 Apr 2016 15:33:26 +0530	[thread overview]
Message-ID: <5710BC6E.1040408@ti.com> (raw)
In-Reply-To: <1460417838-22343-14-git-send-email-d-allred@ti.com>



On Tuesday 12 April 2016 05:07 AM, Daniel Allred wrote:
> Adds an fdt.c file in that defines the ft_cpu_setup() function,
> which should be called from a board-specific ft_board_setup()).
> This ft_cpu_setup() will currently do nothing for non-secure (GP)
> devices	but contains pertinent updates for booting on secure (HS)
> devices.
> 
> Update the omap5 Makefile to include the fdt.c in the build.

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

> 
> Signed-off-by: Daniel Allred <d-allred@ti.com>
> Signed-off-by: Madan Srinivas <madans@ti.com>
> ---
>  arch/arm/cpu/armv7/omap5/Makefile |   1 +
>  arch/arm/cpu/armv7/omap5/fdt.c    | 183 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 184 insertions(+)
>  create mode 100644 arch/arm/cpu/armv7/omap5/fdt.c
> 
> diff --git a/arch/arm/cpu/armv7/omap5/Makefile b/arch/arm/cpu/armv7/omap5/Makefile
> index f2930d5..3caba86 100644
> --- a/arch/arm/cpu/armv7/omap5/Makefile
> +++ b/arch/arm/cpu/armv7/omap5/Makefile
> @@ -12,4 +12,5 @@ obj-y	+= sdram.o
>  obj-y	+= prcm-regs.o
>  obj-y	+= hw_data.o
>  obj-y	+= abb.o
> +obj-y	+= fdt.o
>  obj-$(CONFIG_IODELAY_RECALIBRATION) += dra7xx_iodelay.o
> diff --git a/arch/arm/cpu/armv7/omap5/fdt.c b/arch/arm/cpu/armv7/omap5/fdt.c
> new file mode 100644
> index 0000000..f2f40f0
> --- /dev/null
> +++ b/arch/arm/cpu/armv7/omap5/fdt.c
> @@ -0,0 +1,183 @@
> +/*
> + * Copyright 2016 Texas Instruments, Inc.
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <libfdt.h>
> +#include <fdt_support.h>
> +#include <malloc.h>
> +
> +#include <asm/omap_common.h>
> +#include <asm/arch-omap5/sys_proto.h>
> +
> +#ifdef CONFIG_TI_SECURE_DEVICE
> +
> +/* Give zero values if not already defined */
> +#ifndef CONFIG_SECURE_BOOT_SRAM
> +#define CONFIG_SECURE_BOOT_SRAM (0)
> +#endif
> +#ifndef CONFIG_SECURE_RUN_SRAM
> +#define CONFIG_SECURE_RUN_SRAM (0)
> +#endif
> +
> +static u32 hs_irq_skip[] = {
> +	8,	/* Secure violation reporting interrupt */
> +	15,	/* One interrupt for SDMA by secure world */
> +	118	/* One interrupt for Crypto DMA by secure world */
> +};
> +
> +static int ft_hs_fixup_crossbar(void *fdt, bd_t *bd)
> +{
> +	const char *path;
> +	int offs;
> +	int ret;
> +	int len, i, old_cnt, new_cnt;
> +	u32 *temp;
> +	const u32 *p_data;
> +
> +	/*
> +	 * Increase the size of the fdt
> +	 * so we have some breathing room
> +	 */
> +	ret = fdt_increase_size(fdt, 512);
> +	if (ret < 0) {
> +		printf("Could not increase size of device tree: %s\n",
> +		       fdt_strerror(ret));
> +		return ret;
> +	}
> +
> +	/* Reserve IRQs that are used/needed by secure world */
> +	path = "/ocp/crossbar";
> +	offs = fdt_path_offset(fdt, path);
> +	if (offs < 0) {
> +		debug("Node %s not found.\n", path);
> +		return 0;
> +	}
> +
> +	/* Get current entries */
> +	p_data = fdt_getprop(fdt, offs, "ti,irqs-skip", &len);
> +	if (p_data)
> +		old_cnt = len / sizeof(u32);
> +	else
> +		old_cnt = 0;
> +
> +	new_cnt = sizeof(hs_irq_skip) /
> +				sizeof(hs_irq_skip[0]);
> +
> +	/* Create new/updated skip list for HS parts */
> +	temp = malloc(sizeof(u32) * (old_cnt + new_cnt));
> +	for (i = 0; i < new_cnt; i++)
> +		temp[i] = cpu_to_fdt32(hs_irq_skip[i]);
> +	for (i = 0; i < old_cnt; i++)
> +		temp[i + new_cnt] = p_data[i];
> +
> +	/* Blow away old data and set new data */
> +	fdt_delprop(fdt, offs, "ti,irqs-skip");
> +	ret = fdt_setprop(fdt, offs, "ti,irqs-skip",
> +			  temp,
> +			  (old_cnt + new_cnt) * sizeof(u32));
> +	free(temp);
> +
> +	/* Check if the update worked */
> +	if (ret < 0) {
> +		printf("Could not add ti,irqs-skip property to node %s: %s\n",
> +		       path, fdt_strerror(ret));
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static int ft_hs_disable_rng(void *fdt, bd_t *bd)
> +{
> +	const char *path;
> +	int offs;
> +	int ret;
> +
> +	/* Make HW RNG reserved for secure world use */
> +	path = "/ocp/rng";
> +	offs = fdt_path_offset(fdt, path);
> +	if (offs < 0) {
> +		debug("Node %s not found.\n", path);
> +		return 0;
> +	}
> +	ret = fdt_setprop_string(fdt, offs,
> +				 "status", "disabled");
> +	if (ret < 0) {
> +		printf("Could not add status property to node %s: %s\n",
> +		       path, fdt_strerror(ret));
> +		return ret;
> +	}
> +	return 0;
> +}
> +
> +#if (CONFIG_SECURE_BOOT_SRAM != 0) || (CONFIG_SECURE_RUN_SRAM != 0)
> +static int ft_hs_fixup_sram(void *fdt, bd_t *bd)
> +{
> +	const char *path;
> +	int offs;
> +	int ret;
> +	u32 temp[2];
> +
> +	/*
> +	 * Update SRAM reservations on secure devices. The OCMC RAM
> +	 * is always reserved for secure use from the start of that
> +	 * memory region
> +	 */
> +	path = "/ocp/ocmcram at 40300000/sram-hs";
> +	offs = fdt_path_offset(fdt, path);
> +	if (offs < 0) {
> +		debug("Node %s not found.\n", path);
> +		return 0;
> +	}
> +
> +	/* relative start offset */
> +	temp[0] = cpu_to_fdt32(0);
> +	/* reservation size */
> +	temp[1] = cpu_to_fdt32(max(CONFIG_SECURE_BOOT_SRAM,
> +				   CONFIG_SECURE_RUN_SRAM));
> +	fdt_delprop(fdt, offs, "reg");
> +	ret = fdt_setprop(fdt, offs, "reg", temp, 2 * sizeof(u32));
> +	if (ret < 0) {
> +		printf("Could not add reg property to node %s: %s\n",
> +		       path, fdt_strerror(ret));
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +#else
> +static int ft_hs_fixup_sram(void *fdt, bd_t *bd) { return 0; }
> +#endif
> +
> +static void ft_hs_fixups(void *fdt, bd_t *bd)
> +{
> +	/* Check we are running on an HS/EMU device type */
> +	if (GP_DEVICE != get_device_type()) {
> +		if ((ft_hs_fixup_crossbar(fdt, bd) == 0) &&
> +		    (ft_hs_disable_rng(fdt, bd) == 0) &&
> +		    (ft_hs_fixup_sram(fdt, bd) == 0))
> +			return;
> +	} else {
> +		printf("ERROR: Incorrect device type (GP) detected!");
> +	}
> +	/* Fixup failed or wrong device type */
> +	hang();
> +}
> +#else
> +static void ft_hs_fixups(void *fdt, bd_t *bd)
> +{
> +}
> +#endif
> +
> +/*
> + * Place for general cpu/SoC FDT fixups. Board specific
> + * fixups should remain in the board files which is where
> + * this function should be called from.
> + */
> +void ft_cpu_setup(void *fdt, bd_t *bd)
> +{
> +	ft_hs_fixups(fdt, bd);
> +}
> 

  reply	other threads:[~2016-04-15 10:03 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-11 23:37 [U-Boot] [PATCH 00/16] Support for boot image creation for TI secure devices Daniel Allred
2016-04-11 23:37 ` [U-Boot] [PATCH 01/16] doc: Add info on using secure devices from TI Daniel Allred
2016-04-15  9:47   ` Lokesh Vutla
2016-04-19 15:21   ` Andreas Dannenberg
2016-04-21 13:38   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 02/16] arm: am33xx: Kconfig: Add secure device definitions Daniel Allred
2016-04-15  9:47   ` Lokesh Vutla
2016-04-19 15:13   ` Andreas Dannenberg
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 03/16] arm: Kconfig: Add support for AM43xx SoC specific Kconfig Daniel Allred
2016-04-15  9:48   ` Lokesh Vutla
2016-04-15 10:57   ` Lokesh Vutla
2016-04-18 21:03     ` Andreas Dannenberg
2016-04-18 23:04       ` Andreas Dannenberg
2016-04-11 23:37 ` [U-Boot] [PATCH 04/16] ti: omap-common: Add Kconfig file for secure device support Daniel Allred
2016-04-15  9:48   ` Lokesh Vutla
2016-04-20 22:48   ` Andreas Dannenberg
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 05/16] ti: omap-common: Add commands for generating secure SPL images Daniel Allred
2016-04-15  9:48   ` Lokesh Vutla
2016-04-20 22:47   ` Andreas Dannenberg
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 06/16] ti: AM43xx: config.mk: Add support for generating secure boot images Daniel Allred
2016-04-15  9:49   ` Lokesh Vutla
2016-04-19 15:12   ` Andreas Dannenberg
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 07/16] ti: AM43xx: Use CONFIG options from SOC Kconfig Daniel Allred
2016-04-15  9:54   ` Lokesh Vutla
2016-04-19 15:10   ` Andreas Dannenberg
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 08/16] ti: AM43xx: board: Detect AM43xx HS EVM Daniel Allred
2016-04-15  9:55   ` Lokesh Vutla
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 09/16] defconfig: Add configs for AM43xx secure parts Daniel Allred
2016-04-15  9:58   ` Lokesh Vutla
2016-04-21 13:40     ` Tom Rini
2016-04-21 18:24       ` Allred, Daniel
2016-04-21 19:04         ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 10/16] ti_omap5_common: Update SPL start address on " Daniel Allred
2016-04-15  9:58   ` Lokesh Vutla
2016-04-20 22:50   ` Andreas Dannenberg
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 11/16] spl: build: ti: add support for secure boot images Daniel Allred
2016-04-15  9:59   ` Lokesh Vutla
2016-04-21 13:39   ` Tom Rini
2016-04-21 17:27   ` Andreas Dannenberg
2016-04-11 23:37 ` [U-Boot] [PATCH 12/16] ARM: omap4/5: Add device type to CPU string Daniel Allred
2016-04-15  9:59   ` Lokesh Vutla
2016-04-19 16:26   ` Andreas Dannenberg
2016-04-21 17:55     ` Andreas Dannenberg
2016-04-21 18:01       ` Allred, Daniel
2016-04-21 18:59         ` Andreas Dannenberg
2016-04-21 20:27           ` Tom Rini
2016-04-21 22:56             ` Andreas Dannenberg
2016-04-21 23:38               ` Tom Rini
2016-04-22 15:50                 ` Andreas Dannenberg
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 13/16] ARM: omap5: add hooks for cpu/SoC fdt fixups Daniel Allred
2016-04-15 10:03   ` Lokesh Vutla [this message]
2016-04-20 22:53   ` Andreas Dannenberg
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 14/16] ARM: omap5: add ft_board_setup for dra7xx/am57xx Daniel Allred
2016-04-15 10:03   ` Lokesh Vutla
2016-04-20 22:55   ` Andreas Dannenberg
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 15/16] ARM: omap5: Add config for board/cpu fdt fixups Daniel Allred
2016-04-15 10:05   ` Lokesh Vutla
2016-04-20 22:55   ` Andreas Dannenberg
2016-04-21 13:39   ` Tom Rini
2016-04-11 23:37 ` [U-Boot] [PATCH 16/16] defconfig: ti: Add configs for OMAP5-class secure parts Daniel Allred
2016-04-15 10:05   ` Lokesh Vutla
2016-04-20 22:57   ` Andreas Dannenberg
2016-04-21 13:40   ` Tom Rini

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=5710BC6E.1040408@ti.com \
    --to=lokeshvutla@ti.com \
    --cc=u-boot@lists.denx.de \
    /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