Re: [U-Boot] [PATCH 2/2] arm64: add better spin-table support

2016-06-24 Thread Masahiro Yamada
Hi York,

2016-06-21 1:30 GMT+09:00 york sun :
> On 06/19/2016 03:34 AM, André Przywara wrote:
>> Hi,
>>
>> On 19/06/16 09:57, Masahiro Yamada wrote:
>>> 2016-06-18 18:40 GMT+09:00 Linus Walleij :
 On Fri, Jun 17, 2016 at 2:51 PM, Masahiro Yamada
  wrote:

> There are two enable methods supported by ARM64 Linux; psci and
> spin-table.  The latter is simpler and easier to use for quick SoC
> bring-up.
>
> So, I used the spin-table for my first ARMv8 SoC porting, but I
> found its support in U-Boot was poor.  It is true there exists a
> code fragment for the spin code in arch/arm/cpu/armv8/start.S,
> but I see some problems:

 Is part of the motivation for this approach to boot an ARMv8 system
 without using the ARM Trusted Firmware?

 Yours,
 Linus Walleij
>>>
>>> Yes, exactly.
>>>
>>> It would be the best choice
>>> to switch over to PSCI with ATF in a long run,
>>> but, I decided to use spin-table for the initial SoC bring-up
>>> because of tight schedule.
>>
>> So if you don't have an ATF port ready, why not use U-Boot's PSCI
>> implementation meanwhile? I think there are efforts underway to make
>> PSCI enablement for random new boards a walk in the park (by making the
>> PSCI support as generic as possible, CCing Chen-Yu for this).
>>
>> IIRC the spin-table boot method was just introduced to cope with cores
>> that don't have EL3 and thus cannot provide PSCI services the normal way
>> (and that don't want to or cannot sacrifice EL2 for that).
>> So I am a bit wary of proliferating this SMP method.
>>
>> Wouldn't it be better to help making U-Boot's PSCI stack as easy to use
>> as possible? I don't see technical reasons that adding PSCI support for
>> a board should be harder or more involved than adding spin-table support
>> - in the end you need to tell it about the SMP pen, maybe providing (or
>> faking?) reset and shutdown for 0.2 compliance.
>>
>
> We have a team working on PSCI for ARMv8. The patches are floating and
> need some minor fix. With these patches, PSCI will be used instead of
> spin-table. However, a trusted firmware (or other kind) is required.
>


That's great.


So, what should we do about this patch?


I admit PSCI with ATF is the best way in the end,
but I believe having a simpler alternative should not hurt.




-- 
Best Regards
Masahiro Yamada
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/2] arm64: add better spin-table support

2016-06-24 Thread Masahiro Yamada
Hi Andre,


2016-06-19 19:33 GMT+09:00 André Przywara :
> Hi,
>
> On 19/06/16 09:57, Masahiro Yamada wrote:
>> 2016-06-18 18:40 GMT+09:00 Linus Walleij :
>>> On Fri, Jun 17, 2016 at 2:51 PM, Masahiro Yamada
>>>  wrote:
>>>
 There are two enable methods supported by ARM64 Linux; psci and
 spin-table.  The latter is simpler and easier to use for quick SoC
 bring-up.

 So, I used the spin-table for my first ARMv8 SoC porting, but I
 found its support in U-Boot was poor.  It is true there exists a
 code fragment for the spin code in arch/arm/cpu/armv8/start.S,
 but I see some problems:
>>>
>>> Is part of the motivation for this approach to boot an ARMv8 system
>>> without using the ARM Trusted Firmware?
>>>
>>> Yours,
>>> Linus Walleij
>>
>> Yes, exactly.
>>
>> It would be the best choice
>> to switch over to PSCI with ATF in a long run,
>> but, I decided to use spin-table for the initial SoC bring-up
>> because of tight schedule.
>
> So if you don't have an ATF port ready, why not use U-Boot's PSCI
> implementation meanwhile? I think there are efforts underway to make
> PSCI enablement for random new boards a walk in the park (by making the
> PSCI support as generic as possible, CCing Chen-Yu for this).


So, you mean U-Boot can serve PSCI for ARMv8 SoCs without ATF, right?
(and efforts underway for further improvement)

I know PSCI support is available for ARMv7
(arch/arm/cpu/armv7/psci.S),
but I could not find PSCI implementation
in arch/arm/cpu/armv8/ directory in the mainline U-Boot.

I checked Chen-Yu's patches on Patchwork,
but I think they are mostly for improvement of ARMv7 PSCI support.

If I am missing something,
could you point me to the reference, please?



> IIRC the spin-table boot method was just introduced to cope with cores
> that don't have EL3 and thus cannot provide PSCI services the normal way
> (and that don't want to or cannot sacrifice EL2 for that).
> So I am a bit wary of proliferating this SMP method.

Proliferating?

Many of ARM 32bit SoCs have vendor-specific SMP methods.
On the other hand, ARM64 only has two methods; psci and spin-table.

Is this a problem?



> Wouldn't it be better to help making U-Boot's PSCI stack as easy to use
> as possible? I don't see technical reasons that adding PSCI support for
> a board should be harder or more involved than adding spin-table support
> - in the end you need to tell it about the SMP pen, maybe providing (or
> faking?) reset and shutdown for 0.2 compliance.


Right.

My motivation is to bring up Linux quickly
before ATF becomes ready.

From your statement, I felt
efforts for the ARMv8 PSCI implementation in U-Boot are underway.
If so, I am definitely interested in it.


-- 
Best Regards
Masahiro Yamada
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] kbuild: avoid race between dtbs and dt/dt.dtb targets

2016-06-24 Thread Tom Rini
On Thu, Jun 23, 2016 at 01:53:46PM +0900, Masahiro Yamada wrote:

> If the final targets depend on both "dtbs" and "dts/dt.dtb",
> and -j option is given to the command line, multiple threads
> descend into the dts/ directory, which causes build error.
> 
> Signed-off-by: Masahiro Yamada 
> Tested-by: Andreas Dannenberg 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot,v1,2/2] board/BuR: rename kwb board to brxre1

2016-06-24 Thread Tom Rini
On Wed, Jun 22, 2016 at 12:36:14PM +0200, Hannes Schmelzer wrote:

> Rename B&R kwb board to brxre1
> 
> Signed-off-by: Hannes Schmelzer 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v1, 1/2] board/BuR: rename tseries board to brppt1

2016-06-24 Thread Tom Rini
On Wed, Jun 22, 2016 at 12:36:13PM +0200, Hannes Schmelzer wrote:

> Rename B&R tseries board to brppt1
> 
> Signed-off-by: Hannes Schmelzer 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] efi_loader: Fix typo in distro script

2016-06-24 Thread Tom Rini
On Thu, Jun 23, 2016 at 01:15:38AM +0200, Alexander Graf wrote:

> The distro script is supposed to use the internal fdt as fallback if we
> find no viable other option. However, we're missing a space key to actually
> make that work.
> 
> Add the space, so we can successfully load an EFI blob even when there is
> no device tree provided on the target device.
> 
> Signed-off-by: Alexander Graf 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, 2/4] arm: bcm235xx: implement the boot0 hook code

2016-06-24 Thread Tom Rini
On Tue, Jun 21, 2016 at 04:43:05PM -0700, Steve Rae wrote:

> Choose the Kconfig boot0 hook option and implement the required code.
> 
> Signed-off-by: Steve Rae 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot,3/4] arm: bcm235xx: fix kps ccu

2016-06-24 Thread Tom Rini
On Tue, Jun 21, 2016 at 04:43:06PM -0700, Steve Rae wrote:

> From: Chris Brand 
> 
> The Kona Peripheral Slave CCU has 4 policy mask registers, not 8.
> 
> Signed-off-by: Chris Brand 
> Signed-off-by: Steve Rae 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot,4/4] arm: bcm235xx: update clock framework

2016-06-24 Thread Tom Rini
On Tue, Jun 21, 2016 at 04:43:07PM -0700, Steve Rae wrote:

> The handling of the "usage counter" is incorrect, and the clock should
> only be disabled when transitioning from 1 to 0.
> 
> Reported-by: Chris Brand 
> Signed-off-by: Steve Rae 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/4] arm: bcm235xx: choose 8-bit phy bus width

2016-06-24 Thread Tom Rini
On Tue, Jun 21, 2016 at 04:43:04PM -0700, Steve Rae wrote:

> The Kona PHY supports an 8-bit wide UTMI interface,
> therefore, choose this Kconfig setting.
> 
> Signed-off-by: Steve Rae 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] ARM: armv7: refactor Makefile slightly

2016-06-24 Thread Tom Rini
On Tue, Jun 21, 2016 at 09:30:09PM +0900, Masahiro Yamada wrote:

> Use Kbuild standard style where possible.
> 
> Signed-off-by: Masahiro Yamada 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] clk: sandbox: don't check clk ID against 0

2016-06-24 Thread Tom Rini
On Tue, Jun 21, 2016 at 01:32:07PM -0600, Stephen Warren wrote:

> From: Stephen Warren 
> 
> clk->id is unsigned, so it can't be < 0. Remove the check for that.
> 
> FWIW, this issue was introduced when the clock API converted e.g.
> clk_get_rate()'s clock ID parameter from an int to an unsigned long
> (with a struct clk), without removing this check.
> 
> Fixes: 135aa9500264 ("clk: convert API to match reset/mailbox style")
> Reported-by: Coverity Scan
> Signed-off-by: Stephen Warren 
> Acked-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/2] Move CONFIG_SYS_HUSH_PARSER to Kconfig for last 4 boards

2016-06-24 Thread Tom Rini
On Tue, Jun 21, 2016 at 02:11:18AM +0900, Masahiro Yamada wrote:

> I still see some defines of this config in board headers.  Move them
> to defconfigs (+ renaming to CONFIG_HUSH_PARSER) to complete this
> migration.
> 
> Signed-off-by: Masahiro Yamada 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] common: Fix support for environment file in EXT4

2016-06-24 Thread Tom Rini
On Tue, Jun 21, 2016 at 05:54:25PM +0200, and...@inversepath.com wrote:

> From: Andrej Rosano 
> 
> Signed-off-by: Andrej Rosano 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3] mtd: nand: Drop a blank line in nand_wait()

2016-06-24 Thread Tom Rini
On Sun, Jun 19, 2016 at 07:25:25PM -0600, Simon Glass wrote:

> From: Andre Renaud 
> 
> This empty line should not be there. Remove it.
> Signed-off-by: Andre Renaud 
> Reviewed-by: Andreas Bießmann 
> Signed-off-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, 2/2] hush: complete renaming CONFIG_SYS_HUSH_PARSER to CONFIG_HUSH_PARSER

2016-06-24 Thread Tom Rini
On Tue, Jun 21, 2016 at 02:11:19AM +0900, Masahiro Yamada wrote:

> There is no more define of CONFIG_SYS_HUSH_PARSER.  Rename some
> remaining references and drop the backward compatible Kconfig entry.
> 
> Signed-off-by: Masahiro Yamada 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/2] ARM: move #ifdef to match the error handling code

2016-06-24 Thread Tom Rini
On Fri, Jun 17, 2016 at 09:51:48PM +0900, Masahiro Yamada wrote:

> Match the #ifdef ... #endif and the code,
> 
>ret = do_something();
>if (ret)
>return ret;
> 
> This will make it easier to add more #ifdef'ed code.
> 
> Signed-off-by: Masahiro Yamada 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Use C locale when setting CC_VERSION_STRING and LD_VERSION_STRING.

2016-06-24 Thread Tom Rini
On Sun, Jun 12, 2016 at 06:07:07AM -0700, Vagrant Cascadian wrote:

> The output reported may be locale-dependent, which results in
> unreproducible builds.
> 
>   $ LANG=C ld --version | head -n 1
> GNU ld (GNU Binutils for Debian) 2.26
> 
>   $ LANG=it_CH.UTF-8 ld --version | head -n 1
> ld di GNU (GNU Binutils for Debian) 2.26
> 
> Forcing LC_ALL=C ensures the output is consistant regardless of the
> build environment.
> 
> Thanks to HW42 for debugging the issue:
> 
>   
> https://lists.alioth.debian.org/pipermail/reproducible-builds/Week-of-Mon-20160606/005722.html
> 
> For more information about reproducible builds:
> 
>   https://reproducible-builds.org/
> 
> Signed-off-by: Vagrant Cascadian 
> Reviewed-by: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] arm64: optimize smp_kick_all_cpus

2016-06-24 Thread Tom Rini
On Fri, Jun 17, 2016 at 06:32:47PM +0900, Masahiro Yamada wrote:

> gic_kick_secondary_cpus can directly return to the caller of
> smp_kick_all_cpus.  We do not have to use x29 register here.
> 
> Signed-off-by: Masahiro Yamada 
> Reviewed-by: York Sun 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] lib/lzo: bugfix when input data is not compressed

2016-06-24 Thread Tom Rini
On Fri, Jun 17, 2016 at 10:46:58AM +0200, Joris Lijssens wrote:

> When the input data is not compressed at all,
> lzo1x_decompress_safe will fail, so call memcpy()
> instead.
> 
> Signed-off-by: Joris Lijssens 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Respect SOURCE_DATE_EPOCH when building FIT images.

2016-06-24 Thread Tom Rini
On Thu, Jun 16, 2016 at 12:28:40PM -0700, Vagrant Cascadian wrote:

> Embedding timestamps in FIT images results in unreproducible builds
> for targets that generate a fit image, such as dra7xx_evm.
> 
> This patch uses the SOURCE_DATE_EPOCH environment variable, when set,
> to use specified value for the date.
> 
> Thanks to HW42 for debugging the issue and providing the patch:
> 
>   
> https://lists.alioth.debian.org/pipermail/reproducible-builds/Week-of-Mon-20160606/005722.html
> 
> For more information about reproducible builds and the
> SOURCE_DATE_EPOCH specification:
> 
>   https://reproducible-builds.org/specs/source-date-epoch/
>   https://reproducible-builds.org/
> 
> Signed-off-by: Vagrant Cascadian 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, RFC, V2] common: image: minimal android image iminfo support

2016-06-24 Thread Tom Rini
On Fri, Jun 10, 2016 at 07:54:37PM +0200, Michael Trimarchi wrote:

> We already support iminfo for other images. The idea
> of this patch is start to have a minimal support for
> android image format. We still need to print id[] array
> 
> Signed-off-by: Michael Trimarchi 
> Reviewed-by: Simon Glass 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] env: avoid build error for boards without CONFIG_SYS_{CPU, BOARD}

2016-06-24 Thread Tom Rini
On Fri, Jun 17, 2016 at 02:24:07PM +0900, Masahiro Yamada wrote:

> If CONFIG_ENV_VARS_UBOOT_CONFIG is enabled (it is by distro), this
> code causes build error for boards without CONFIG_SYS_{CPU,_BOARD}.
> 
> Signed-off-by: Masahiro Yamada 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v3] mkimage: fit: spl: Add an optional static offset for external data

2016-06-24 Thread Tom Rini
On Thu, Jun 09, 2016 at 07:38:02PM -0700, Teddy Reed wrote:

> When building a FIT with external data (-E), U-Boot proper may require
> absolute positioning for executing the external firmware. To acheive this
> use the (-p) switch, which will replace the amended 'data-offset' with
> 'data-position' indicating the absolute position of external data.
> 
> It is considered an error if the requested absolute position overlaps with the
> initial data required for the compact FIT.
> 
> Signed-off-by: Teddy Reed 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v2, 1/2] configs: gxbb: Introduce a common config header file

2016-06-24 Thread Tom Rini
On Fri, Jun 10, 2016 at 08:18:22PM +0200, Carlo Caione wrote:

> From: Carlo Caione 
> 
> Introduce a meson-gxbb-common.h header file and derive the
> configuration for Hardkernel Odroid-C2 board from that.
> 
> Reviewed-by: Simon Glass 
> Signed-off-by: Carlo Caione 
> Acked-by: Beniamino Galvani 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot, v2, 2/2] board: amlogic: Rename folder for Amlogic boards

2016-06-24 Thread Tom Rini
On Fri, Jun 10, 2016 at 08:18:23PM +0200, Carlo Caione wrote:

> From: Carlo Caione 
> 
> s/hardkernel/amlogic/ to have a single place for all the amlogic-based
> boards.
> 
> Reviewed-by: Simon Glass 
> Signed-off-by: Carlo Caione 
> Acked-by: Beniamino Galvani 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot,1/1] cmd: bootefi: cosmetic

2016-06-24 Thread Tom Rini
On Tue, Jun 07, 2016 at 11:14:31AM -0700, Sergey Kubushyn wrote:

> Short help (description) in bootefi command has a trailing "\n" that
> breaks the "help" command output (empty line after "bootefi").
> 
> Nothing important, doesn't affect anything but better be fixed in the
> upcoming release.
> 
> Still working on i.MX6 and their siblings NAND U-Boot update -- it
> works here but not ready for a submission yet. Anyway it is for the
> next cycle, not going to go into this release because it is too big
> and may affect something else.
> 
> Also have some thoughts about fastboot (using multiple devices) but
> this will go into separate email with RFC.
> 
> Signed-off-by: Sergey Kubushyn 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [U-Boot,1/1] omap3: bugfix in timer on rollover

2016-06-24 Thread Tom Rini
On Mon, Jun 06, 2016 at 09:40:11AM +0200, Daniel Gorsulowski wrote:

> Signed-off-by: Daniel Gorsulowski 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 0/6] Convert FSL LayerScape ARMv8 SoCs to use common MMU code

2016-06-24 Thread York Sun
To use common MMU code, non-identical mapping needs to be supported.
Minior change in the MMU framework is required to support splitting
blocks. With these changes, using common code is straight forward.
Attention is needed where the tables are for early boot, secure and
non-secure ram situations.


York Sun (6):
  armv8: Move secure_ram variable out of generic global data
  armv8: Add tlb_allocated to arch global data
  armv8: mmu: house cleaning
  armv8: mmu: split block if necessary
  armv8: mmu: Add support of non-identical mapping
  armv8: layerscape: Convert to use common MMU framework

 README |   3 +-
 arch/arm/cpu/armv8/cache_v8.c  | 112 
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c| 365 -
 arch/arm/cpu/armv8/s32v234/cpu.c   |  12 +-
 arch/arm/cpu/armv8/zynqmp/cpu.c|  21 +-
 arch/arm/include/asm/arch-fsl-layerscape/cpu.h | 310 -
 arch/arm/include/asm/armv8/mmu.h   |   5 +-
 arch/arm/include/asm/global_data.h |  15 +
 arch/arm/mach-exynos/mmu-arm64.c   |   9 +-
 arch/arm/mach-meson/board.c|   6 +-
 arch/arm/mach-snapdragon/sysmap-apq8016.c  |   6 +-
 arch/arm/mach-sunxi/board.c|   6 +-
 arch/arm/mach-tegra/arm64-mmu.c|   6 +-
 arch/arm/mach-uniphier/arm64/mem_map.c |   6 +-
 board/armltd/vexpress64/vexpress64.c   |   6 +-
 board/cavium/thunderx/thunderx.c   |   9 +-
 board/freescale/ls1043aqds/ddr.c   |  15 +-
 board/freescale/ls1043ardb/ddr.c   |  15 +-
 board/freescale/ls2080a/ddr.c  |  15 +-
 board/freescale/ls2080aqds/ddr.c   |  15 +-
 board/freescale/ls2080ardb/ddr.c   |  15 +-
 board/hisilicon/hikey/hikey.c  |   6 +-
 board/raspberrypi/rpi/rpi.c|   6 +-
 cmd/bdinfo.c   |   4 +-
 common/board_f.c   |  11 +-
 include/asm-generic/global_data.h  |  14 -
 26 files changed, 439 insertions(+), 574 deletions(-)

-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [Patch v4 3/5] fsl: usb: make errata function common for PPC and ARM

2016-06-24 Thread york sun
On 06/12/2016 09:28 PM, Sriram Dash wrote:
> This patch does the following things:
> 1. Makes the errata checking code common for PPC and ARM
> 2. Moves all these static inline functions into a dedicated C file
>
> Signed-off-by: Sriram Dash 
> Signed-off-by: Rajesh Bhagat 
> ---
>
> Changes in v4:
>- Rework done according to previous patches.


Sriram,

This patch breaks many PowerPC boards with SPL. Please test and fix.

York

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 5/6] armv8: mmu: Add support of non-identical mapping

2016-06-24 Thread York Sun
Introduce virtual and physical addresses in the mapping table. This change
have no impact on existing boards because they all use idential mapping.

Signed-off-by: York Sun 
---

 arch/arm/cpu/armv8/cache_v8.c | 37 +--
 arch/arm/cpu/armv8/s32v234/cpu.c  | 12 ++
 arch/arm/cpu/armv8/zynqmp/cpu.c   | 21 --
 arch/arm/include/asm/armv8/mmu.h  |  3 ++-
 arch/arm/mach-exynos/mmu-arm64.c  |  9 
 arch/arm/mach-meson/board.c   |  6 +++--
 arch/arm/mach-snapdragon/sysmap-apq8016.c |  6 +++--
 arch/arm/mach-sunxi/board.c   |  6 +++--
 arch/arm/mach-tegra/arm64-mmu.c   |  6 +++--
 arch/arm/mach-uniphier/arm64/mem_map.c|  6 +++--
 board/armltd/vexpress64/vexpress64.c  |  6 +++--
 board/cavium/thunderx/thunderx.c  |  9 +---
 board/hisilicon/hikey/hikey.c |  6 +++--
 board/raspberrypi/rpi/rpi.c   |  6 +++--
 14 files changed, 86 insertions(+), 53 deletions(-)

diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index 8604035..ac909a1 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -44,7 +44,7 @@ u64 get_tcr(int el, u64 *pips, u64 *pva_bits)
 
/* Find the largest address we need to support */
for (i = 0; mem_map[i].size || mem_map[i].attrs; i++)
-   max_addr = max(max_addr, mem_map[i].base + mem_map[i].size);
+   max_addr = max(max_addr, mem_map[i].virt + mem_map[i].size);
 
/* Calculate the maximum physical (and thus virtual) address */
if (max_addr > (1ULL << 44)) {
@@ -202,7 +202,8 @@ static void split_block(u64 *pte, int level)
 static void add_map(struct mm_region *map)
 {
u64 *pte;
-   u64 addr = map->base;
+   u64 virt = map->virt;
+   u64 phys = map->phys;
u64 size = map->size;
u64 attrs = map->attrs | PTE_TYPE_BLOCK | PTE_BLOCK_AF;
u64 blocksize;
@@ -210,37 +211,39 @@ static void add_map(struct mm_region *map)
u64 *new_table;
 
while (size) {
-   pte = find_pte(addr, 0);
+   pte = find_pte(virt, 0);
if (pte && (pte_type(pte) == PTE_TYPE_FAULT)) {
-   debug("Creating table for addr 0x%llx\n", addr);
+   debug("Creating table for virt 0x%llx\n", virt);
new_table = create_table();
set_pte_table(pte, new_table);
}
 
for (level = 1; level < 4; level++) {
-   pte = find_pte(addr, level);
+   pte = find_pte(virt, level);
if (!pte)
panic("pte not found\n");
+
blocksize = 1ULL << level2shift(level);
-   debug("Checking if pte fits for addr=%llx size=%llx "
- "blocksize=%llx\n", addr, size, blocksize);
-   if (size >= blocksize && !(addr & (blocksize - 1))) {
+   debug("Checking if pte fits for virt=%llx size=%llx 
blocksize=%llx\n",
+ virt, size, blocksize);
+   if (size >= blocksize && !(virt & (blocksize - 1))) {
/* Page fits, create block PTE */
-   debug("Setting PTE %p to block addr=%llx\n",
- pte, addr);
-   *pte = addr | attrs;
-   addr += blocksize;
+   debug("Setting PTE %p to block virt=%llx\n",
+ pte, virt);
+   *pte = phys | attrs;
+   virt += blocksize;
+   phys += blocksize;
size -= blocksize;
break;
} else if (pte_type(pte) == PTE_TYPE_FAULT) {
/* Page doesn't fit, create subpages */
-   debug("Creating subtable for addr 0x%llx "
- "blksize=%llx\n", addr, blocksize);
+   debug("Creating subtable for virt 0x%llx 
blksize=%llx\n",
+ virt, blocksize);
new_table = create_table();
set_pte_table(pte, new_table);
} else if (pte_type(pte) == PTE_TYPE_BLOCK) {
-   debug("Split block into subtable for addr 
0x%llx blksize=0x%llx\n",
- addr, blocksize);
+   debug("Split block into subtable for virt 
0x%llx blksize=0x%llx\n",
+ virt, blocksize);
split_block(pte, level);
   

[U-Boot] [PATCH v1 1/6] armv8: Move secure_ram variable out of generic global data

2016-06-24 Thread York Sun
Secure_ram variable was put in generic global data. But only ARMv8
uses this variable. Move it to ARM specific data structure.

Signed-off-by: York Sun 
---

 README  |  3 ++-
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 20 ++--
 arch/arm/include/asm/global_data.h  | 14 ++
 board/freescale/ls1043aqds/ddr.c| 15 ---
 board/freescale/ls1043ardb/ddr.c| 15 ---
 board/freescale/ls2080a/ddr.c   | 15 ---
 board/freescale/ls2080aqds/ddr.c| 15 ---
 board/freescale/ls2080ardb/ddr.c| 15 ---
 cmd/bdinfo.c|  4 ++--
 common/board_f.c|  2 +-
 include/asm-generic/global_data.h   | 14 --
 11 files changed, 69 insertions(+), 63 deletions(-)

diff --git a/README b/README
index 03bed18..1a5f121 100644
--- a/README
+++ b/README
@@ -3783,10 +3783,11 @@ Configuration Settings:
You only need to set this if address zero isn't writeable
 
 - CONFIG_SYS_MEM_RESERVE_SECURE
+   Only implemented for ARMv8 for now.
If defined, the size of CONFIG_SYS_MEM_RESERVE_SECURE memory
is substracted from total RAM and won't be reported to OS.
This memory can be used as secure memory. A variable
-   gd->secure_ram is used to track the location. In systems
+   gd->arch.secure_ram is used to track the location. In systems
the RAM base is not zero, or RAM is divided into banks,
this variable needs to be recalcuated to get the address.
 
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index 8062106..a397f5d 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -289,8 +289,8 @@ static inline int final_secure_ddr(u64 *level0_table,
  * These tables are in DRAM. Sub tables are added to enable cache for
  * QBMan and OCRAM.
  *
- * Put the MMU table in secure memory if gd->secure_ram is valid.
- * OCRAM will be not used for this purpose so gd->secure_ram can't be 0.
+ * Put the MMU table in secure memory if gd->arch.secure_ram is valid.
+ * OCRAM will be not used for this purpose so gd->arch.secure_ram can't be 0.
  *
  * Level 1 table 0 contains 512 entries for each 1GB from 0 to 512GB.
  * Level 1 table 1 contains 512 entries for each 1GB from 512GB to 1TB.
@@ -321,13 +321,13 @@ static inline void final_mmu_setup(void)
 
if (el == 3) {
/*
-* Only use gd->secure_ram if the address is recalculated
+* Only use gd->arch.secure_ram if the address is recalculated
 * Align to 4KB for MMU table
 */
-   if (gd->secure_ram & MEM_RESERVE_SECURE_MAINTAINED)
-   level0_table = (u64 *)(gd->secure_ram & ~0xfff);
+   if (gd->arch.secure_ram & MEM_RESERVE_SECURE_MAINTAINED)
+   level0_table = (u64 *)(gd->arch.secure_ram & ~0xfff);
else
-   printf("MMU warning: gd->secure_ram is not maintained, 
disabled.\n");
+   printf("MMU warning: gd->arch.secure_ram is not 
maintained, disabled.\n");
}
 #endif
level1_table0 = level0_table + 512;
@@ -374,7 +374,7 @@ static inline void final_mmu_setup(void)
}
/* Set the secure memory to secure in MMU */
 #ifdef CONFIG_SYS_MEM_RESERVE_SECURE
-   if (el == 3 && gd->secure_ram & MEM_RESERVE_SECURE_MAINTAINED) {
+   if (el == 3 && gd->arch.secure_ram & MEM_RESERVE_SECURE_MAINTAINED) {
 #ifdef CONFIG_FSL_LSCH3
level2_table_secure = level2_table1 + 512;
 #elif defined(CONFIG_FSL_LSCH2)
@@ -382,10 +382,10 @@ static inline void final_mmu_setup(void)
 #endif
if (!final_secure_ddr(level0_table,
  level2_table_secure,
- gd->secure_ram & ~0x3)) {
-   gd->secure_ram |= MEM_RESERVE_SECURE_SECURED;
+ gd->arch.secure_ram & ~0x3)) {
+   gd->arch.secure_ram |= MEM_RESERVE_SECURE_SECURED;
debug("Now MMU table is in secured memory at 0x%llx\n",
- gd->secure_ram & ~0x3);
+ gd->arch.secure_ram & ~0x3);
} else {
printf("MMU warning: Failed to secure DDR\n");
}
diff --git a/arch/arm/include/asm/global_data.h 
b/arch/arm/include/asm/global_data.h
index 77d2653..2d76cd4 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -44,6 +44,20 @@ struct arch_global_data {
unsigned long tlb_emerg;
 #endif
 #endif
+#ifdef CONFIG_SYS_MEM_RESERVE_SECURE
+#define MEM_RESERVE_SECURE_SECURED 0x1
+#define MEM_RESERVE_SECURE_M

[U-Boot] [PATCH v1 6/6] armv8: layerscape: Convert to use common MMU framework

2016-06-24 Thread York Sun
Drop platform code to create static MMU tables. Use common framework
to create MMU tables on the run. Tested on LS2080ARDB with secure and
non-secure ram scenarios.

Signed-off-by: York Sun 

   Alison Wang ,
   Prabhakar Kushwaha 

---

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c| 359 -
 arch/arm/include/asm/arch-fsl-layerscape/cpu.h | 310 -
 2 files changed, 237 insertions(+), 432 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index a397f5d..4790686 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -26,13 +26,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static struct mm_region layerscape_mem_map[] = {
-   {
-   /* List terminator */
-   0,
-   }
-};
-struct mm_region *mem_map = layerscape_mem_map;
+struct mm_region *mem_map = early_map;
 
 void cpu_name(char *name)
 {
@@ -56,233 +50,35 @@ void cpu_name(char *name)
 }
 
 #ifndef CONFIG_SYS_DCACHE_OFF
-static void set_pgtable_section(u64 *page_table, u64 index, u64 section,
-   u64 memory_type, u64 attribute)
-{
-   u64 value;
-
-   value = section | PTE_TYPE_BLOCK | PTE_BLOCK_AF;
-   value |= PMD_ATTRINDX(memory_type);
-   value |= attribute;
-   page_table[index] = value;
-}
-
-static void set_pgtable_table(u64 *page_table, u64 index, u64 *table_addr)
-{
-   u64 value;
-
-   value = (u64)table_addr | PTE_TYPE_TABLE;
-   page_table[index] = value;
-}
-
-/*
- * Set the block entries according to the information of the table.
- */
-static int set_block_entry(const struct sys_mmu_table *list,
-  struct table_info *table)
-{
-   u64 block_size = 0, block_shift = 0;
-   u64 block_addr, index;
-   int j;
-
-   if (table->entry_size == BLOCK_SIZE_L1) {
-   block_size = BLOCK_SIZE_L1;
-   block_shift = SECTION_SHIFT_L1;
-   } else if (table->entry_size == BLOCK_SIZE_L2) {
-   block_size = BLOCK_SIZE_L2;
-   block_shift = SECTION_SHIFT_L2;
-   } else {
-   return -EINVAL;
-   }
-
-   block_addr = list->phys_addr;
-   index = (list->virt_addr - table->table_base) >> block_shift;
-
-   for (j = 0; j < (list->size >> block_shift); j++) {
-   set_pgtable_section(table->ptr,
-   index,
-   block_addr,
-   list->memory_type,
-   list->attribute);
-   block_addr += block_size;
-   index++;
-   }
-
-   return 0;
-}
-
-/*
- * Find the corresponding table entry for the list.
- */
-static int find_table(const struct sys_mmu_table *list,
- struct table_info *table, u64 *level0_table)
-{
-   u64 index = 0, level = 0;
-   u64 *level_table = level0_table;
-   u64 temp_base = 0, block_size = 0, block_shift = 0;
-
-   while (level < 3) {
-   if (level == 0) {
-   block_size = BLOCK_SIZE_L0;
-   block_shift = SECTION_SHIFT_L0;
-   } else if (level == 1) {
-   block_size = BLOCK_SIZE_L1;
-   block_shift = SECTION_SHIFT_L1;
-   } else if (level == 2) {
-   block_size = BLOCK_SIZE_L2;
-   block_shift = SECTION_SHIFT_L2;
-   }
-
-   index = 0;
-   while (list->virt_addr >= temp_base) {
-   index++;
-   temp_base += block_size;
-   }
-
-   temp_base -= block_size;
-
-   if ((level_table[index - 1] & PTE_TYPE_MASK) ==
-   PTE_TYPE_TABLE) {
-   level_table = (u64 *)(level_table[index - 1] &
- ~PTE_TYPE_MASK);
-   level++;
-   continue;
-   } else {
-   if (level == 0)
-   return -EINVAL;
-
-   if ((list->phys_addr + list->size) >
-   (temp_base + block_size * NUM_OF_ENTRY))
-   return -EINVAL;
-
-   /*
-* Check the address and size of the list member is
-* aligned with the block size.
-*/
-   if (((list->phys_addr & (block_size - 1)) != 0) ||
-   ((list->size & (block_size - 1)) != 0))
-   return -EINVAL;
-
-   table->ptr = level_table;
-   table->table_base = temp_base -
-   ((index - 1) << block_shift);
-   table->entry_size = block_size;
-
-

[U-Boot] [PATCH v1 4/6] armv8: mmu: split block if necessary

2016-06-24 Thread York Sun
When page tables are created, allow later table to be created on
previous block entry. Splitting block feature is already working
with current code. This patch only rearranges the code order and
adds one condition to call split_block().

Signed-off-by: York Sun 
---

 arch/arm/cpu/armv8/cache_v8.c | 70 +++
 1 file changed, 38 insertions(+), 32 deletions(-)

diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index b8867a7..8604035 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -167,6 +167,37 @@ static void set_pte_table(u64 *pte, u64 *table)
*pte = PTE_TYPE_TABLE | (ulong)table;
 }
 
+/* Splits a block PTE into table with subpages spanning the old block */
+static void split_block(u64 *pte, int level)
+{
+   u64 old_pte = *pte;
+   u64 *new_table;
+   u64 i = 0;
+   /* level describes the parent level, we need the child ones */
+   int levelshift = level2shift(level + 1);
+
+   if (pte_type(pte) != PTE_TYPE_BLOCK)
+   panic("PTE %p (%llx) is not a block. Some driver code wants to "
+ "modify dcache settings for an range not covered in "
+ "mem_map.", pte, old_pte);
+
+   new_table = create_table();
+   debug("Splitting pte %p (%llx) into %p\n", pte, old_pte, new_table);
+
+   for (i = 0; i < MAX_PTE_ENTRIES; i++) {
+   new_table[i] = old_pte | (i << levelshift);
+
+   /* Level 3 block PTEs have the table type */
+   if ((level + 1) == 3)
+   new_table[i] |= PTE_TYPE_TABLE;
+
+   debug("Setting new_table[%lld] = %llx\n", i, new_table[i]);
+   }
+
+   /* Set the new table into effect */
+   set_pte_table(pte, new_table);
+}
+
 /* Add one mm_region map entry to the page tables */
 static void add_map(struct mm_region *map)
 {
@@ -188,6 +219,8 @@ static void add_map(struct mm_region *map)
 
for (level = 1; level < 4; level++) {
pte = find_pte(addr, level);
+   if (!pte)
+   panic("pte not found\n");
blocksize = 1ULL << level2shift(level);
debug("Checking if pte fits for addr=%llx size=%llx "
  "blocksize=%llx\n", addr, size, blocksize);
@@ -199,48 +232,21 @@ static void add_map(struct mm_region *map)
addr += blocksize;
size -= blocksize;
break;
-   } else if ((pte_type(pte) == PTE_TYPE_FAULT)) {
+   } else if (pte_type(pte) == PTE_TYPE_FAULT) {
/* Page doesn't fit, create subpages */
debug("Creating subtable for addr 0x%llx "
  "blksize=%llx\n", addr, blocksize);
new_table = create_table();
set_pte_table(pte, new_table);
+   } else if (pte_type(pte) == PTE_TYPE_BLOCK) {
+   debug("Split block into subtable for addr 
0x%llx blksize=0x%llx\n",
+ addr, blocksize);
+   split_block(pte, level);
}
}
}
 }
 
-/* Splits a block PTE into table with subpages spanning the old block */
-static void split_block(u64 *pte, int level)
-{
-   u64 old_pte = *pte;
-   u64 *new_table;
-   u64 i = 0;
-   /* level describes the parent level, we need the child ones */
-   int levelshift = level2shift(level + 1);
-
-   if (pte_type(pte) != PTE_TYPE_BLOCK)
-   panic("PTE %p (%llx) is not a block. Some driver code wants to "
- "modify dcache settings for an range not covered in "
- "mem_map.", pte, old_pte);
-
-   new_table = create_table();
-   debug("Splitting pte %p (%llx) into %p\n", pte, old_pte, new_table);
-
-   for (i = 0; i < MAX_PTE_ENTRIES; i++) {
-   new_table[i] = old_pte | (i << levelshift);
-
-   /* Level 3 block PTEs have the table type */
-   if ((level + 1) == 3)
-   new_table[i] |= PTE_TYPE_TABLE;
-
-   debug("Setting new_table[%lld] = %llx\n", i, new_table[i]);
-   }
-
-   /* Set the new table into effect */
-   set_pte_table(pte, new_table);
-}
-
 enum pte_type {
PTE_INVAL,
PTE_BLOCK,
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 3/6] armv8: mmu: house cleaning

2016-06-24 Thread York Sun
Make setup_pgtages() and get_tcr() available for platform code to
customize MMU tables.
Remove unintentional call of create_table().

Signed-off-by: York Sun 
---

 arch/arm/cpu/armv8/cache_v8.c| 13 -
 arch/arm/include/asm/armv8/mmu.h |  2 ++
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index 1615542..b8867a7 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -35,7 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
  *off:  FFF
  */
 
-static u64 get_tcr(int el, u64 *pips, u64 *pva_bits)
+u64 get_tcr(int el, u64 *pips, u64 *pva_bits)
 {
u64 max_addr = 0;
u64 ips, va_bits;
@@ -349,10 +349,13 @@ __weak u64 get_page_table_size(void)
return size;
 }
 
-static void setup_pgtables(void)
+void setup_pgtables(void)
 {
int i;
 
+   if (!gd->arch.tlb_fillptr || !gd->arch.tlb_addr)
+   panic("Page table pointer not setup.");
+
/*
 * Allocate the first level we're on with invalidate entries.
 * If the starting level is 0 (va_bits >= 39), then this is our
@@ -363,9 +366,6 @@ static void setup_pgtables(void)
/* Now add all MMU table entries one after another to the table */
for (i = 0; mem_map[i].size || mem_map[i].attrs; i++)
add_map(&mem_map[i]);
-
-   /* Create the same thing once more for our emergency page table */
-   create_table();
 }
 
 static void setup_all_pgtables(void)
@@ -527,6 +527,9 @@ void mmu_set_region_dcache_behaviour(phys_addr_t start, 
size_t size,
 
debug("start=%lx size=%lx\n", (ulong)start, (ulong)size);
 
+   if (!gd->arch.tlb_emerg)
+   panic("Emergency page table not setup.");
+
/*
 * We can not modify page tables that we're currently running on,
 * so we first need to switch to the "emergency" page tables where
diff --git a/arch/arm/include/asm/armv8/mmu.h b/arch/arm/include/asm/armv8/mmu.h
index 0d08ed3..b7b4706 100644
--- a/arch/arm/include/asm/armv8/mmu.h
+++ b/arch/arm/include/asm/armv8/mmu.h
@@ -141,6 +141,8 @@ struct mm_region {
 };
 
 extern struct mm_region *mem_map;
+void setup_pgtables(void);
+u64 get_tcr(int el, u64 *pips, u64 *pva_bits);
 #endif
 
 #endif /* _ASM_ARMV8_MMU_H_ */
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 2/6] armv8: Add tlb_allocated to arch global data

2016-06-24 Thread York Sun
When secure ram is used, MMU tables have to be put into secure ram.
To use common MMU code, gd->arch.tlb_addr will be used to host TLB
entry pointer. To save allocated memory for later use, tlb_allocated
variable is added to global data structure.

Signed-off-by: York Sun 
---

 arch/arm/include/asm/global_data.h | 1 +
 common/board_f.c   | 9 +
 2 files changed, 10 insertions(+)

diff --git a/arch/arm/include/asm/global_data.h 
b/arch/arm/include/asm/global_data.h
index 2d76cd4..1055017 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -57,6 +57,7 @@ struct arch_global_data {
 * 0x2 maintained
 */
phys_addr_t secure_ram;
+   unsigned long tlb_allocated;
 #endif
 
 #ifdef CONFIG_OMAP_COMMON
diff --git a/common/board_f.c b/common/board_f.c
index 0fc96bd..a1138b0 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -432,6 +432,15 @@ static int reserve_mmu(void)
gd->arch.tlb_addr = gd->relocaddr;
debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr,
  gd->arch.tlb_addr + gd->arch.tlb_size);
+
+#ifdef CONFIG_SYS_MEM_RESERVE_SECURE
+   /*
+* Record allocated tlb_addr in case gd->tlb_addr to be overwritten
+* with location within secure ram.
+*/
+   gd->arch.tlb_allocated = gd->arch.tlb_addr;
+#endif
+
return 0;
 }
 #endif
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] cmd, nand: add an option to disable the verification when writing in raw mode

2016-06-24 Thread Tom Rini
On Wed, Jun 15, 2016 at 10:42:18AM +0200, Boris Brezillon wrote:

> Modern NANDs do not guarantee that data written in raw mode will not
> contain bitflips just after writing them. This is fine since the number
> of bitflips should be rather low and thus fixable by the ECC engine,
> but since we are reading data in raw mode to verify if they match the
> input data we cannot prevent failures if some bits are flipped.
> 
> The option of using standard mode to verify the data is not acceptable
> either, since one of the usage of raw mode is to allow flashing images
> that do not respect the standard NAND page layout or the default ECC
> config (this is the case on Allwinner platforms, where the ROM code
> tests several hardcoded configs, which are not necessarily matching the
> NAND characteristics).
> 
> Add an extension to the nand write.raw command allowing one to disable
> the verification step.
> 
> Signed-off-by: Boris Brezillon 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] i.MX SPL tools (was Re: [RFC PATCH 00/12] imx: mx6: add virtual mx6memcal board)

2016-06-24 Thread Tom Rini
On Tue, Jun 21, 2016 at 12:48:45PM -0700, Eric Nelson wrote:
> On 06/21/2016 11:41 AM, Eric Nelson wrote:
> > This patch set makes use of the dynamic DDR calibration routines added in 
> > commit
> > d339f16 to define an alternative to the Freescale DDR stress tester tool.
> > 
> Hi all,
> 
> While preparing this patch set, I thought again about the tools we have
> for managing SPL images, and especially "first boot" issues (when a
> full U-Boot isn't available or isn't programmed into the normal boot
> device).
> 
> Since the "mx6memcal" device is deliberately small, with only
> the DDR and UART defined, there's no way to load a full U-Boot
> and doing so would defeat the primary purpose.
> 
> We've discussed this at length on a number of occasions, (most recently
> in [5]) but I don't think we have a good solution.
> 
> I just looked at Troy's ancient patches ([1] and [2]) and it seems that
> these two patches are the bulk of the work needed to build a combined
> SPL+U-Boot image, and if I understand patch 2 correctly, SPL could
> tell at run-time that it was executed via a plugin and return control
> to the Boot ROM instead of trying to load U-Boot or a kernel.
> 
> If I recall correctly, Troy dropped these patches because of push-back
> that came from the sheer size of the 21-patch set, and not because of
> any particular objection to support for plugins.
> 
> It seems that a little work here would remove the need for things
> like Stefano's patch in [3] or Michael thoughts of adding DFU support
> in [4].
> 
> I'm interested in hearing your thoughts on the subject.

So, if I read the commentary right, "plugin" is how we can eventually
get to the point where we can support, in a single binary, somewhat
disparate board / SoC types because we can have enough smarts there to
see if it's a Q or D or DL and so forth, right?  That would be
worthwhile to support, yes.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH V2 2/2] common: add new boot media kconfig entry

2016-06-24 Thread Tom Rini
On Sun, Jun 19, 2016 at 06:20:52PM +0800, Peng Fan wrote:
> Hi Masahiro,
> 
> +Simon
> On Fri, Jun 17, 2016 at 07:08:23PM +0900, Masahiro Yamada wrote:
> >2016-06-17 18:39 GMT+09:00 Peng Fan :
> >> Add CONFIG_{SD|NAND|ONENAND|SPI|QSPI|SATA}_BOOT kconfig entries.
> >>
> >> SoCs supports loading U-Boot from different medias to DRAM, such as
> >> i.MX6/7 supports loading U-Boot to DRAM from sd/emmc/nand/qspi/spi/sata
> >> and etc. For i.MX, imximage will generate different IVT headers according
> >> to boot medias.
> >>
> >> Signed-off-by: Peng Fan 
> >> Cc: Simon Glass 
> >> Cc: Heiko Schocher 
> >> Cc: Joe Hershberger 
> >> Cc: Bin Meng 
> >> Cc: Christophe Ricard 
> >> Cc: Nikita Kiryanov 
> >> Cc: Francois Retief 
> >> Cc: Tom Rini 
> >> ---
> >>
> >> V2:
> >>  Move NOR_BOOT to the patch 1/2.
> >>  The idea of this patch is for adding different boot media support for
> >>  i.MXes. And I'll post out following patches if this patch is accepted.
> >>  I ran moveconfig.py, but I did not include the results into a patch.
> >>  This patch does not break the boards which defined NAND_BOOT/SD_BOOT and
> >>  etc, and I prefer to let board owners to move to defconfig later.
> >>
> >>  common/Kconfig | 48 
> >>  1 file changed, 48 insertions(+)
> >>
> >> diff --git a/common/Kconfig b/common/Kconfig
> >> index 04d092c..f0f6ee1 100644
> >> --- a/common/Kconfig
> >> +++ b/common/Kconfig
> >> @@ -108,6 +108,54 @@ config NOR_BOOT
> >>   as the ROM only partially sets up pinmux.  We also default to 
> >> using
> >>   NOR for environment.
> >>
> >> +config NAND_BOOT
> >> +   bool "Support for booting from NAND flash"
> >> +   default n
> >> +   help
> >> + Enabling this will make a U-Boot binary that is capable of being
> >> + booted via NAND flash. This is not a must, some SoCs need this,
> >> + somes not.
> >> +
> >> +config ONENAND_BOOT
> >> +   bool "Support for booting from ONENAND"
> >> +   default n
> >> +   help
> >> + Enabling this will make a U-Boot binary that is capable of being
> >> + booted via ONENAND. This is not a must, some SoCs need this,
> >> + somes not.
> >> +
> >> +config QSPI_BOOT
> >> +   bool "Support for booting from QSPI flash"
> >> +   default n
> >> +   help
> >> + Enabling this will make a U-Boot binary that is capable of being
> >> + booted via QSPI flash. This is not a must, some SoCs need this,
> >> + somes not.
> >> +
> >> +config SATA_BOOT
> >> +   bool "Support for booting from SATA"
> >> +   default n
> >> +   help
> >> + Enabling this will make a U-Boot binary that is capable of being
> >> + booted via SATA. This is not a must, some SoCs need this,
> >> + somes not.
> >> +
> >> +config SD_BOOT
> >> +   bool "Support for booting from SD/EMMC"
> >> +   default n
> >> +   help
> >> + Enabling this will make a U-Boot binary that is capable of being
> >> + booted via SD/EMMC. This is not a must, some SoCs need this,
> >> + somes not.
> >> +
> >> +config SPI_BOOT
> >> +   bool "Support for booting from SPI flash"
> >> +   default n
> >> +   help
> >> + Enabling this will make a U-Boot binary that is capable of being
> >> + booted via SPI flash. This is not a must, some SoCs need this,
> >> + somes not.
> >> +
> >>  endmenu
> >
> >
> >Do you intend to replace
> >CONFIG_SPL_NOR_SUPPORT
> >CONFIG_SPL_NAND_SUPPORT
> >CONFIG_SPL_USB_SUPPORT
> >CONFIG_SPL_MMC_SUPPORT
> >etc. with these options?
> >
> 
> I missed these.
> 
> >
> >Currently, common/spl/spl.c uses CONFIG_SPL_*_SUPPORT
> >to enable/disable capable boot devices.
> 
> I think we could use a common option to replace the ones used in SPL.

I'm not sure that CONFIG_xxx_BOOT and CONFIG_SPL_xxx_SUPPORT are the
same thing.  For example, CONFIG_NOR_BOOT on am335x means "we are
building to support booting from NOR, so include all of that stuff
that's normally not included".  While CONFIG_SPL_NAND_SUPPORT means
include NAND support in SPL, which is not mutually exclusive with MMC,
etc.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 0/2] Prepare U-Boot for more Amlogic boards

2016-06-24 Thread Tom Rini
On Fri, Jun 24, 2016 at 11:01:03PM +0200, Carlo Caione wrote:
> On 10/06/16 20:18, Carlo Caione wrote:
> > From: Carlo Caione 
> > 
> > Refactor the Odroid-C2 support code to prepare U-Boot for more Amlogic board
> > submissions.
> > The goal is to reduce the redundancy of the configuration files and unify 
> > all
> > the board support files onto a single amlogic directory.
> > 
> > Changelog:
> > v2:
> >  - Added Reviewed-by
> >  - Now 2/2 clearly shows the renaming
> 
> What's left for this patchset? I have a couple of submissions depending
> on this one.

Sorry for the delay, working on this shortly.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 0/2] Prepare U-Boot for more Amlogic boards

2016-06-24 Thread Carlo Caione
On 10/06/16 20:18, Carlo Caione wrote:
> From: Carlo Caione 
> 
> Refactor the Odroid-C2 support code to prepare U-Boot for more Amlogic board
> submissions.
> The goal is to reduce the redundancy of the configuration files and unify all
> the board support files onto a single amlogic directory.
> 
> Changelog:
> v2:
>  - Added Reviewed-by
>  - Now 2/2 clearly shows the renaming

What's left for this patchset? I have a couple of submissions depending
on this one.

-- 
Carlo Caione
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 4/9] arm: omap-common: secure ROM signature verify API

2016-06-24 Thread Tom Rini
On Fri, Jun 24, 2016 at 10:57:12AM -0500, Andreas Dannenberg wrote:

> Adds an API that verifies a signature attached to an image (binary
> blob). This API is basically a entry to a secure ROM service provided by
> the device and accessed via an SMC call, using a particular calling
> convention.
> 
> Signed-off-by: Daniel Allred 
> Signed-off-by: Andreas Dannenberg 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] README: Device Tree: Add & explain undocumented options.

2016-06-24 Thread Tom Rini
On Sat, Jun 11, 2016 at 02:56:42PM +0200, Ahmed Samir Khalil wrote:

> There are no info about these options in the README.
> Documenting these options makes getting startup,
> configuration & testing easier.
> 
> Signed-off-by: Ahmed Samir Khalil 
> ---
>  README | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/README b/README
> index 1d0b946..1c9f778 100644
> --- a/README
> +++ b/README
> @@ -1154,6 +1154,14 @@ The following options need to be configured:
>   still use the individual files if you need something more
>   exotic.
>  
> + CONFIG_OF_HOSTFILE
> + If this variable is defined, U-Boot will read the device tree
> + from a file on startup. This is only useful for sandbox. You
> + may use either CONFIG_OF_HOSTFILE or CONFIG_OF_CONTROL.
> +
> + CONFIG_OF_SPI_FLASH
> + Define to enable setting up a new SPI flash (slave) from an fdt 
> node.

I'm not sure if OF_SPI_FLASH works even as nothing calls it today.  Can
you please just do a patch that documents CONFIG_OF_HOSTFILE?  Thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] error: sdhci_send_command: Timeout for status update!

2016-06-24 Thread Steve Rae
Hi Stefan, Masahiro

On Thu, Jun 23, 2016 at 9:56 PM, Stefan Roese  wrote:
> Steve,
>
>
> On 24.06.2016 00:06, Steve Rae wrote:
>>
>> I am asking you about this code, because of this:
>>commit 29905a4 - mmc: sdhci: Use timer based timeout detection in
>> sdhci_send_command()
>>
>> Occasionally, I am seeing failures when writing to flash on my device:
>>
>>Flashing sparse image at offset 2078720
>>Flashing Sparse Image
>>sdhci_send_command: Timeout for status update!
>>mmc fail to send stop cmd
>>write_sparse_image: Write failed, block #2181088 [0]
>>
>> I can eliminate this error if I kludge the following code:
>>
>> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
>> index 5c71ab8..854f7ce 100644
>> --- a/drivers/mmc/sdhci.c
>> +++ b/drivers/mmc/sdhci.c
>> @@ -243,9 +243,9 @@ static int sdhci_send_command(struct mmc *mmc,
>> struct mmc_cmd *cmd,
>>  if (stat & SDHCI_INT_ERROR)
>>  break;
>>  } while (((stat & mask) != mask) &&
>> -(get_timer(start) < CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT));
>> +(get_timer(start) < 600
>> /*CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT*/));
>>
>> -   if (get_timer(start) >= CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT) {
>> +   if (get_timer(start) >= 600 /*CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT*/)
>> {
>>  if (host->quirks & SDHCI_QUIRK_BROKEN_R1B)
>>  return 0;
>>  else {
>>
>> I don't know much about this - I arrived at 600 by trial and error
>> (500 fails...)
>> Any ideas?
>
>
> Perhaps your platform needs a bigger timeout value. Did you check
> what the Linux driver does here?

It looks like (v.4.6) the code loops for max_loops=16,
and it looks like the loop delay is created by a write (which does not
exist in the U-Boot code):
 sdhci_writel(host, mask, SDHCI_INT_STATUS);

> You could move
> CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT to Kconfig with a default of 100
> and select a higher value for your platform.
>

Would it be wise to create a new CONFIG for the reading of the status,
rather than overloading the CONFIG used for sending the command?
maybe: CONFIG_SDHCI_STATUS_DEFAULT_TIMEOUT ?

Thanks, Steve

> Thanks,
> Stefan
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] nitrogen6x : Use generic distro configuration

2016-06-24 Thread Fabien Lahoudere
In order to simplify the use of various images on various media
for nitrogen6x, the configuration of the board must follow the
generic distro configuration (doc/README.distro).

In order to boot your old rootfs, move your kernel and your device
tree in /boot/. Then create /boot/extlinux/extlinux.conf with for
example:

default Buildroot

label Buildroot
kernel /boot/zImage
append console=ttymxc1,115200 root=/dev/mmcblk0p1 rootwait rw
fdtdir /boot

Signed-off-by: Fabien Lahoudere 
---
 configs/mx6qsabrelite_defconfig |   1 +
 configs/nitrogen6dl2g_defconfig |   1 +
 configs/nitrogen6dl_defconfig   |   1 +
 configs/nitrogen6q2g_defconfig  |   1 +
 configs/nitrogen6q_defconfig|   1 +
 configs/nitrogen6s1g_defconfig  |   1 +
 configs/nitrogen6s_defconfig|   1 +
 doc/README.imx6 |  47 +++
 include/configs/mx6_common.h|  28 +++
 include/configs/nitrogen6x.h| 169 
 10 files changed, 97 insertions(+), 154 deletions(-)

diff --git a/configs/mx6qsabrelite_defconfig b/configs/mx6qsabrelite_defconfig
index fa6139a..27b64c4 100644
--- a/configs/mx6qsabrelite_defconfig
+++ b/configs/mx6qsabrelite_defconfig
@@ -36,3 +36,4 @@ CONFIG_G_DNL_MANUFACTURER="Boundary"
 CONFIG_G_DNL_VENDOR_NUM=0x0525
 CONFIG_G_DNL_PRODUCT_NUM=0xa4a5
 CONFIG_OF_LIBFDT=y
+CONFIG_DISTRO_DEFAULTS=y
\ No newline at end of file
diff --git a/configs/nitrogen6dl2g_defconfig b/configs/nitrogen6dl2g_defconfig
index 02b2462..b1344c6 100644
--- a/configs/nitrogen6dl2g_defconfig
+++ b/configs/nitrogen6dl2g_defconfig
@@ -34,3 +34,4 @@ CONFIG_G_DNL_MANUFACTURER="Boundary"
 CONFIG_G_DNL_VENDOR_NUM=0x0525
 CONFIG_G_DNL_PRODUCT_NUM=0xa4a5
 CONFIG_OF_LIBFDT=y
+CONFIG_DISTRO_DEFAULTS=y
\ No newline at end of file
diff --git a/configs/nitrogen6dl_defconfig b/configs/nitrogen6dl_defconfig
index 52553f6..f794c08 100644
--- a/configs/nitrogen6dl_defconfig
+++ b/configs/nitrogen6dl_defconfig
@@ -34,3 +34,4 @@ CONFIG_G_DNL_MANUFACTURER="Boundary"
 CONFIG_G_DNL_VENDOR_NUM=0x0525
 CONFIG_G_DNL_PRODUCT_NUM=0xa4a5
 CONFIG_OF_LIBFDT=y
+CONFIG_DISTRO_DEFAULTS=y
\ No newline at end of file
diff --git a/configs/nitrogen6q2g_defconfig b/configs/nitrogen6q2g_defconfig
index 11188b7..56cebe0 100644
--- a/configs/nitrogen6q2g_defconfig
+++ b/configs/nitrogen6q2g_defconfig
@@ -34,3 +34,4 @@ CONFIG_G_DNL_MANUFACTURER="Boundary"
 CONFIG_G_DNL_VENDOR_NUM=0x0525
 CONFIG_G_DNL_PRODUCT_NUM=0xa4a5
 CONFIG_OF_LIBFDT=y
+CONFIG_DISTRO_DEFAULTS=y
\ No newline at end of file
diff --git a/configs/nitrogen6q_defconfig b/configs/nitrogen6q_defconfig
index 05bf140..c150b97 100644
--- a/configs/nitrogen6q_defconfig
+++ b/configs/nitrogen6q_defconfig
@@ -34,3 +34,4 @@ CONFIG_G_DNL_MANUFACTURER="Boundary"
 CONFIG_G_DNL_VENDOR_NUM=0x0525
 CONFIG_G_DNL_PRODUCT_NUM=0xa4a5
 CONFIG_OF_LIBFDT=y
+CONFIG_DISTRO_DEFAULTS=y
\ No newline at end of file
diff --git a/configs/nitrogen6s1g_defconfig b/configs/nitrogen6s1g_defconfig
index bb081a2..dfd096d 100644
--- a/configs/nitrogen6s1g_defconfig
+++ b/configs/nitrogen6s1g_defconfig
@@ -34,3 +34,4 @@ CONFIG_G_DNL_MANUFACTURER="Boundary"
 CONFIG_G_DNL_VENDOR_NUM=0x0525
 CONFIG_G_DNL_PRODUCT_NUM=0xa4a5
 CONFIG_OF_LIBFDT=y
+CONFIG_DISTRO_DEFAULTS=y
\ No newline at end of file
diff --git a/configs/nitrogen6s_defconfig b/configs/nitrogen6s_defconfig
index 08e91c9..5e2e693 100644
--- a/configs/nitrogen6s_defconfig
+++ b/configs/nitrogen6s_defconfig
@@ -34,3 +34,4 @@ CONFIG_G_DNL_MANUFACTURER="Boundary"
 CONFIG_G_DNL_VENDOR_NUM=0x0525
 CONFIG_G_DNL_PRODUCT_NUM=0xa4a5
 CONFIG_OF_LIBFDT=y
+CONFIG_DISTRO_DEFAULTS=y
\ No newline at end of file
diff --git a/doc/README.imx6 b/doc/README.imx6
index 1823fb2..36452f6 100644
--- a/doc/README.imx6
+++ b/doc/README.imx6
@@ -138,3 +138,50 @@ c
 The last "c" command tells kermit (from ckermit package in most distros)
 to switch from command line mode to communication mode, and when the
 script is finished, the U-Boot prompt is shown in the same shell.
+
+3. Using generic distro configuration
+-
+
+In order to simplify the use of various images on various media
+for imx6 boards, the configuration of the board must follow the
+generic distro configuration (doc/README.distro).
+
+3.1. Setup uboot configuration for your board
+-
+
+First, you have to set 'CONFIG_DISTRO_DEFAULTS=y' in your board defconfig
+
+Some mandatory variable are set in mx6_common.h but can be overwritten like:
+  - fdtfile with CONFIG_FDTFILE
+  - fdt_addr_r and fdt_addr with CONFIG_FDTADDR
+  - ramdisk_addr_r, ramdiskaddr CONFIG_RAMDISKADDR
+
+You also have to define BOOT_TARGET_DEVICES with available media.
+For example added in include/configs/nitrogen6x.h:
+#define BOOT_TARGET_DEVICES(func) \
+   func(MMC, mmc, 0) \
+   func(MMC, mmc, 1) \
+   func(SATA, sata, 0) \
+   func(USB, usb, 0) \
+   func(PXE, pxe, na) \
+   func(DHCP, dhcp, na)
+
+All

[U-Boot] [PATCH v2 7/9] arm: omap5: add U-Boot FIT signing and SPL image post-processing

2016-06-24 Thread Andreas Dannenberg
Modify the SPL build procedure for AM57xx and DRA7xx high-security (HS)
device variants to create a secure u-boot_HS.img FIT blob that contains
U-Boot and DTB artifacts signed with a TI-specific process based on the
CONFIG_TI_SECURE_DEVICE config option and the externally-provided image
signing tool.

Also populate the corresponding FIT image post processing call to be
performed during SPL runtime.

Signed-off-by: Daniel Allred 
Signed-off-by: Andreas Dannenberg 
Reviewed-by: Tom Rini 
---
 arch/arm/cpu/armv7/omap5/config.mk | 3 +++
 board/ti/am57xx/board.c| 8 
 board/ti/dra7xx/evm.c  | 9 +
 configs/am57xx_hs_evm_defconfig| 1 +
 configs/dra7xx_hs_evm_defconfig| 1 +
 5 files changed, 22 insertions(+)

diff --git a/arch/arm/cpu/armv7/omap5/config.mk 
b/arch/arm/cpu/armv7/omap5/config.mk
index a7e55a5..d245572 100644
--- a/arch/arm/cpu/armv7/omap5/config.mk
+++ b/arch/arm/cpu/armv7/omap5/config.mk
@@ -15,5 +15,8 @@ else
 ALL-y  += MLO
 endif
 else
+ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
+ALL-y   += u-boot_HS.img
+endif
 ALL-y  += u-boot.img
 endif
diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 08cf14d..927d136 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -750,3 +751,10 @@ int board_fit_config_name_match(const char *name)
return -1;
 }
 #endif
+
+#ifdef CONFIG_TI_SECURE_DEVICE
+void board_fit_image_post_process(void **p_image, size_t *p_size)
+{
+   secure_boot_verify_image(p_image, p_size);
+}
+#endif
diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 0394e4e..f9382b8 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -17,6 +17,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -830,3 +832,10 @@ int board_fit_config_name_match(const char *name)
return -1;
 }
 #endif
+
+#ifdef CONFIG_TI_SECURE_DEVICE
+void board_fit_image_post_process(void **p_image, size_t *p_size)
+{
+   secure_boot_verify_image(p_image, p_size);
+}
+#endif
diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
index e01e504..01a4701 100644
--- a/configs/am57xx_hs_evm_defconfig
+++ b/configs/am57xx_hs_evm_defconfig
@@ -40,4 +40,5 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
 CONFIG_OF_LIST="am57xx-beagle-x15"
diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
index 6933ab5..eb01f41 100644
--- a/configs/dra7xx_hs_evm_defconfig
+++ b/configs/dra7xx_hs_evm_defconfig
@@ -58,4 +58,5 @@ CONFIG_G_DNL_PRODUCT_NUM=0xd022
 CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
 CONFIG_OF_LIST="dra7-evm dra72-evm"
-- 
2.6.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 4/9] arm: omap-common: secure ROM signature verify API

2016-06-24 Thread Andreas Dannenberg
Adds an API that verifies a signature attached to an image (binary
blob). This API is basically a entry to a secure ROM service provided by
the device and accessed via an SMC call, using a particular calling
convention.

Signed-off-by: Daniel Allred 
Signed-off-by: Andreas Dannenberg 
---
 arch/arm/cpu/armv7/omap-common/sec-common.c | 88 +
 arch/arm/include/asm/omap_sec_common.h  |  9 +++
 2 files changed, 97 insertions(+)

diff --git a/arch/arm/cpu/armv7/omap-common/sec-common.c 
b/arch/arm/cpu/armv7/omap-common/sec-common.c
index 4ec736f..246a239 100644
--- a/arch/arm/cpu/armv7/omap-common/sec-common.c
+++ b/arch/arm/cpu/armv7/omap-common/sec-common.c
@@ -17,6 +17,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+
+/* Index for signature verify ROM API */
+#define API_HAL_KM_VERIFYCERTIFICATESIGNATURE_INDEX(0x000E)
 
 static uint32_t secure_rom_call_args[5] __aligned(ARCH_DMA_MINALIGN);
 
@@ -49,3 +54,86 @@ u32 secure_rom_call(u32 service, u32 proc_id, u32 flag, ...)
 
return omap_smc_sec(service, proc_id, flag, secure_rom_call_args);
 }
+
+static u32 find_sig_start(char *image, size_t size)
+{
+   char *image_end = image + size;
+   char *sig_start_magic = "CERT_";
+   int magic_str_len = strlen(sig_start_magic);
+   char *ch;
+
+   while (--image_end > image) {
+   if (*image_end == '_') {
+   ch = image_end - magic_str_len + 1;
+   if (!strncmp(ch, sig_start_magic, magic_str_len))
+   return (u32)ch;
+   }
+   }
+   return 0;
+}
+
+int secure_boot_verify_image(void **image, size_t *size)
+{
+   int result = 1;
+   u32 cert_addr, sig_addr;
+   size_t cert_size;
+
+   /* Perform cache writeback on input buffer */
+   flush_dcache_range(
+   (u32)*image,
+   (u32)*image + roundup(*size, ARCH_DMA_MINALIGN));
+
+   cert_addr = (uint32_t)*image;
+   sig_addr = find_sig_start((char *)*image, *size);
+
+   if (sig_addr == 0) {
+   printf("No signature found in image!\n");
+   result = 1;
+   goto auth_exit;
+   }
+
+   *size = sig_addr - cert_addr;   /* Subtract out the signature size */
+   cert_size = *size;
+
+   /* Check if image load address is 32-bit aligned */
+   if (!IS_ALIGNED(cert_addr, 4)) {
+   printf("Image is not 4-byte aligned!\n");
+   result = 1;
+   goto auth_exit;
+   }
+
+   /* Image size also should be multiple of 4 */
+   if (!IS_ALIGNED(cert_size, 4)) {
+   printf("Image size is not 4-byte aligned!\n");
+   result = 1;
+   goto auth_exit;
+   }
+
+   /* Call ROM HAL API to verify certificate signature */
+   debug("%s: load_addr = %x, size = %x, sig_addr = %x\n", __func__,
+ cert_addr, cert_size, sig_addr);
+
+   result = secure_rom_call(
+   API_HAL_KM_VERIFYCERTIFICATESIGNATURE_INDEX, 0, 0,
+   4, cert_addr, cert_size, sig_addr, 0x);
+auth_exit:
+   if (result != 0) {
+   printf("Authentication failed!\n");
+   printf("Return Value = %08X\n", result);
+   hang();
+   }
+
+   /*
+* Output notification of successful authentication as well the name of
+* the signing certificate used to re-assure the user that the secure
+* code is being processed as expected. However suppress any such log
+* output in case of building for SPL and booting via YMODEM. This is
+* done to avoid disturbing the YMODEM serial protocol transactions.
+*/
+   if (!(IS_ENABLED(CONFIG_SPL_BUILD) &&
+ IS_ENABLED(CONFIG_SPL_YMODEM_SUPPORT) &&
+ spl_boot_device() == BOOT_DEVICE_UART))
+   printf("Authentication passed: %s\n", (char *)sig_addr);
+
+   return result;
+}
diff --git a/arch/arm/include/asm/omap_sec_common.h 
b/arch/arm/include/asm/omap_sec_common.h
index 1f50f83..842f2af 100644
--- a/arch/arm/include/asm/omap_sec_common.h
+++ b/arch/arm/include/asm/omap_sec_common.h
@@ -18,4 +18,13 @@
  */
 u32 secure_rom_call(u32 service, u32 proc_id, u32 flag, ...);
 
+/*
+ * Invoke a secure ROM API on high-secure (HS) device variants that can be used
+ * to verify a secure blob by authenticating and optionally decrypting it. The
+ * exact operation performed depends on how the certificate that was embedded
+ * into the blob during the signing/encryption step when the secure blob was
+ * first created.
+ */
+int secure_boot_verify_image(void **p_image, size_t *p_size);
+
 #endif /* _OMAP_SEC_COMMON_H_ */
-- 
2.6.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 8/9] arm: am4x: add U-Boot FIT signing and SPL image post-processing

2016-06-24 Thread Andreas Dannenberg
From: Madan Srinivas 

Modify the SPL build procedure for AM437x high-security (HS) device
variants to create a secure u-boot_HS.img FIT blob that contains U-Boot
and DTB artifacts signed (and optionally encrypted) with a TI-specific
process based on the CONFIG_TI_SECURE_DEVICE config option and the
externally-provided image signing tool.

Also populate the corresponding FIT image post processing call to be
performed during SPL runtime.

Signed-off-by: Madan Srinivas 
Signed-off-by: Andreas Dannenberg 
Reviewed-by: Tom Rini 
---
 arch/arm/cpu/armv7/am33xx/config.mk | 1 +
 board/ti/am43xx/board.c | 8 
 configs/am43xx_hs_evm_defconfig | 1 +
 3 files changed, 10 insertions(+)

diff --git a/arch/arm/cpu/armv7/am33xx/config.mk 
b/arch/arm/cpu/armv7/am33xx/config.mk
index 6d95d32..ab94708 100644
--- a/arch/arm/cpu/armv7/am33xx/config.mk
+++ b/arch/arm/cpu/armv7/am33xx/config.mk
@@ -26,6 +26,7 @@ endif
 else
 ifeq ($(CONFIG_TI_SECURE_DEVICE),y)
 ALL-$(CONFIG_QSPI_BOOT) += u-boot_HS_XIP_X-LOADER
+ALL-y  += u-boot_HS.img
 endif
 ALL-y  += u-boot.img
 endif
diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index f005762..27c311e 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -862,3 +863,10 @@ int board_fit_config_name_match(const char *name)
return -1;
 }
 #endif
+
+#ifdef CONFIG_TI_SECURE_DEVICE
+void board_fit_image_post_process(void **p_image, size_t *p_size)
+{
+   secure_boot_verify_image(p_image, p_size);
+}
+#endif
diff --git a/configs/am43xx_hs_evm_defconfig b/configs/am43xx_hs_evm_defconfig
index 4856a19..68dfb6c 100644
--- a/configs/am43xx_hs_evm_defconfig
+++ b/configs/am43xx_hs_evm_defconfig
@@ -13,6 +13,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_FIT=y
 CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=1, NAND"
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_IMLS is not set
-- 
2.6.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 6/9] spl: fit: add support for post-processing of images

2016-06-24 Thread Andreas Dannenberg
From: Daniel Allred 

The next stage boot loader image and the selected FDT can be post-
processed by board/platform/device-specific code, which can include
modifying the size and altering the starting source address before
copying these binary blobs to their final destination. This might be
desired to do things like strip headers or footers attached to the
images before they were packaged into the FIT, or to perform operations
such as decryption or authentication. Introduce new configuration
option CONFIG_SPL_FIT_IMAGE_POST_PROCESS to allow controlling this
feature. If enabled, a platform-specific post-process function must
be provided.

Signed-off-by: Daniel Allred 
Signed-off-by: Andreas Dannenberg 
Reviewed-by: Tom Rini 
---
 Kconfig  |  4 
 common/spl/spl_fit.c | 21 -
 include/image.h  | 17 +
 3 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/Kconfig b/Kconfig
index 3ceff25..b0a5595 100644
--- a/Kconfig
+++ b/Kconfig
@@ -313,6 +313,10 @@ config SPL_LOAD_FIT
  particular it can handle selecting from multiple device tree
  and passing the correct one to U-Boot.
 
+config SPL_FIT_IMAGE_POST_PROCESS
+   bool "Enable post-processing of FIT artifacts after loading by the SPL"
+   depends on SPL_LOAD_FIT && TI_SECURE_DEVICE
+
 config SYS_CLK_FREQ
depends on ARC || ARCH_SUNXI
int "CPU clock frequency"
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 9874708..069e94d 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -132,7 +132,7 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong 
sector, void *fit)
int data_offset, data_size;
int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
int src_sector;
-   void *dst;
+   void *dst, *src;
 
/*
 * Figure out where the external images start. This is the base for the
@@ -206,8 +206,13 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong 
sector, void *fit)
return -EIO;
debug("image: dst=%p, data_offset=%x, size=%x\n", dst, data_offset,
  data_size);
-   memcpy(dst, dst + get_aligned_image_overhead(info, data_offset),
-  data_size);
+   src = dst + get_aligned_image_overhead(info, data_offset);
+
+#ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS
+   board_fit_image_post_process((void **)&src, (size_t *)&data_size);
+#endif
+
+   memcpy(dst, src, data_size);
 
/* Figure out which device tree the board wants to use */
fdt_len = spl_fit_select_fdt(fit, images, &fdt_offset);
@@ -236,8 +241,14 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong 
sector, void *fit)
 */
debug("fdt: dst=%p, data_offset=%x, size=%x\n", dst, fdt_offset,
  fdt_len);
-   memcpy(load_ptr + data_size,
-  dst + get_aligned_image_overhead(info, fdt_offset), fdt_len);
+   src = dst + get_aligned_image_overhead(info, fdt_offset);
+   dst = load_ptr + data_size;
+
+#ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS
+   board_fit_image_post_process((void **)&src, (size_t *)&fdt_len);
+#endif
+
+   memcpy(dst, src, fdt_len);
 
return 0;
 }
diff --git a/include/image.h b/include/image.h
index a8f6bd1..a17e505 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1172,4 +1172,21 @@ ulong android_image_get_kload(const struct andr_img_hdr 
*hdr);
  */
 int board_fit_config_name_match(const char *name);
 
+#ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS
+/**
+ * board_fit_image_post_process() - Do any post-process on FIT binary data
+ *
+ * This is used to do any sort of image manipulation, verification, decryption
+ * etc. in a platform or board specific way. Obviously, anything done here 
would
+ * need to be comprehended in how the images were prepared before being 
injected
+ * into the FIT creation (i.e. the binary blobs would have been pre-processed
+ * before being added to the FIT image).
+ *
+ * @image: pointer to the image start pointer
+ * @size: pointer to the image size
+ * @return no return value (failure should be handled internally)
+ */
+void board_fit_image_post_process(void **p_image, size_t *p_size);
+#endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */
+
 #endif /* __IMAGE_H__ */
-- 
2.6.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 3/9] arm: omap-common: add secure rom call API for secure devices

2016-06-24 Thread Andreas Dannenberg
Adds a generic C-callable API for making secure ROM calls on OMAP and
OMAP-compatible devices. This API provides the important function of
flushing the ROM call arguments to memory from the cache, so that the
secure world will have a coherent view of those arguments. Then is
simply calls the omap_smc_sec routine.

Signed-off-by: Daniel Allred 
Signed-off-by: Andreas Dannenberg 
Reviewed-by: Simon Glass 
Reviewed-by: Tom Rini 
---
 arch/arm/cpu/armv7/omap-common/Makefile |  2 ++
 arch/arm/cpu/armv7/omap-common/sec-common.c | 51 +
 arch/arm/include/asm/omap_sec_common.h  | 21 
 3 files changed, 74 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/omap-common/sec-common.c
 create mode 100644 arch/arm/include/asm/omap_sec_common.h

diff --git a/arch/arm/cpu/armv7/omap-common/Makefile 
b/arch/arm/cpu/armv7/omap-common/Makefile
index 87a7ac0..3172bae 100644
--- a/arch/arm/cpu/armv7/omap-common/Makefile
+++ b/arch/arm/cpu/armv7/omap-common/Makefile
@@ -36,3 +36,5 @@ obj-y += boot-common.o
 obj-y  += lowlevel_init.o
 
 obj-y  += mem-common.o
+
+obj-$(CONFIG_TI_SECURE_DEVICE) += sec-common.o
diff --git a/arch/arm/cpu/armv7/omap-common/sec-common.c 
b/arch/arm/cpu/armv7/omap-common/sec-common.c
new file mode 100644
index 000..4ec736f
--- /dev/null
+++ b/arch/arm/cpu/armv7/omap-common/sec-common.c
@@ -0,0 +1,51 @@
+/*
+ *
+ * Common security related functions for OMAP devices
+ *
+ * (C) Copyright 2016
+ * Texas Instruments, 
+ *
+ * Daniel Allred 
+ * Andreas Dannenberg 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+static uint32_t secure_rom_call_args[5] __aligned(ARCH_DMA_MINALIGN);
+
+u32 secure_rom_call(u32 service, u32 proc_id, u32 flag, ...)
+{
+   int i;
+   u32 num_args;
+   va_list ap;
+
+   va_start(ap, flag);
+
+   num_args = va_arg(ap, u32);
+
+   if (num_args > 4)
+   return 1;
+
+   /* Copy args to aligned args structure */
+   for (i = 0; i < num_args; i++)
+   secure_rom_call_args[i + 1] = va_arg(ap, u32);
+
+   secure_rom_call_args[0] = num_args;
+
+   va_end(ap);
+
+   /* if data cache is enabled, flush the aligned args structure */
+   flush_dcache_range(
+   (unsigned int)&secure_rom_call_args[0],
+   (unsigned int)&secure_rom_call_args[0] +
+   roundup(sizeof(secure_rom_call_args), ARCH_DMA_MINALIGN));
+
+   return omap_smc_sec(service, proc_id, flag, secure_rom_call_args);
+}
diff --git a/arch/arm/include/asm/omap_sec_common.h 
b/arch/arm/include/asm/omap_sec_common.h
new file mode 100644
index 000..1f50f83
--- /dev/null
+++ b/arch/arm/include/asm/omap_sec_common.h
@@ -0,0 +1,21 @@
+/*
+ * (C) Copyright 2016
+ * Texas Instruments, 
+ *
+ * Andreas Dannenberg 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+#ifndef_OMAP_SEC_COMMON_H_
+#define_OMAP_SEC_COMMON_H_
+
+#include 
+
+/*
+ * Invoke secure ROM API on high-security (HS) device variants. It formats
+ * the variable argument list into the format expected by the ROM code before
+ * triggering the actual low-level smc entry.
+ */
+u32 secure_rom_call(u32 service, u32 proc_id, u32 flag, ...);
+
+#endif /* _OMAP_SEC_COMMON_H_ */
-- 
2.6.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 5/9] arm: omap-common: Update to generate secure U-Boot FIT blob

2016-06-24 Thread Andreas Dannenberg
Adds commands so that when a secure device is in use and the SPL is
built to load a FIT image (with combined U-Boot binary and various
DTBs), these components that get fed into the FIT are all processed to
be signed/encrypted/etc. as per the operations performed by the
secure-binary-image.sh script of the TI SECDEV package. Furthermore,
perform minor comments cleanup to make better use of the available
space.

Signed-off-by: Daniel Allred 
Signed-off-by: Andreas Dannenberg 
Reviewed-by: Simon Glass 
---
 arch/arm/cpu/armv7/omap-common/config_secure.mk | 75 -
 1 file changed, 61 insertions(+), 14 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/config_secure.mk 
b/arch/arm/cpu/armv7/omap-common/config_secure.mk
index c7bb101..1122439 100644
--- a/arch/arm/cpu/armv7/omap-common/config_secure.mk
+++ b/arch/arm/cpu/armv7/omap-common/config_secure.mk
@@ -12,8 +12,8 @@ cmd_mkomapsecimg = 
$(TI_SECURE_DEV_PKG)/scripts/create-boot-image.sh \
$(if $(KBUILD_VERBOSE:1=), >/dev/null)
 else
 cmd_mkomapsecimg = $(TI_SECURE_DEV_PKG)/scripts/create-boot-image.sh \
-$(patsubst u-boot_HS_%,%,$(@F)) $< $@ $(CONFIG_ISW_ENTRY_ADDR) \
-$(if $(KBUILD_VERBOSE:1=), >/dev/null)
+   $(patsubst u-boot_HS_%,%,$(@F)) $< $@ $(CONFIG_ISW_ENTRY_ADDR) \
+   $(if $(KBUILD_VERBOSE:1=), >/dev/null)
 endif
 else
 cmd_mkomapsecimg = echo "WARNING:" \
@@ -25,14 +25,33 @@ cmd_mkomapsecimg = echo "WARNING: TI_SECURE_DEV_PKG 
environment" \
"variable must be defined for TI secure devices. $@ was NOT created!"
 endif
 
+ifdef CONFIG_SPL_LOAD_FIT
+quiet_cmd_omapsecureimg = SECURE  $@
+ifneq ($(TI_SECURE_DEV_PKG),)
+ifneq ($(wildcard $(TI_SECURE_DEV_PKG)/scripts/secure-binary-image.sh),)
+cmd_omapsecureimg = $(TI_SECURE_DEV_PKG)/scripts/secure-binary-image.sh \
+   $< $@ \
+   $(if $(KBUILD_VERBOSE:1=), >/dev/null)
+else
+cmd_omapsecureimg = echo "WARNING:" \
+   "$(TI_SECURE_DEV_PKG)/scripts/secure-binary-image.sh not found." \
+   "$@ was NOT created!"; cp $< $@
+endif
+else
+cmd_omapsecureimg = echo "WARNING: TI_SECURE_DEV_PKG environment" \
+   "variable must be defined for TI secure devices." \
+   "$@ was NOT created!"; cp $< $@
+endif
+endif
+
+
 # Standard X-LOADER target (QPSI, NOR flash)
 u-boot-spl_HS_X-LOADER: $(obj)/u-boot-spl.bin
$(call if_changed,mkomapsecimg)
 
-# For MLO targets (SD card boot) the final file name
-# that is copied to the SD card fAT partition must
-# be MLO, so we make a copy of the output file to a
-# new file with that name
+# For MLO targets (SD card boot) the final file name that is copied to the SD
+# card FAT partition must be MLO, so we make a copy of the output file to a new
+# file with that name
 u-boot-spl_HS_MLO: $(obj)/u-boot-spl.bin
$(call if_changed,mkomapsecimg)
@if [ -f $@ ]; then \
@@ -51,16 +70,44 @@ u-boot-spl_HS_ULO: $(obj)/u-boot-spl.bin
 u-boot-spl_HS_ISSW: $(obj)/u-boot-spl.bin
$(call if_changed,mkomapsecimg)
 
-# For SPI flash on AM335x and AM43xx, these
-# require special byte swap handling so we use
-# the SPI_X-LOADER target instead of X-LOADER
-# and let the create-boot-image.sh script handle
-# that
+# For SPI flash on AM335x and AM43xx, these require special byte swap handling
+# so we use the SPI_X-LOADER target instead of X-LOADER and let the
+# create-boot-image.sh script handle that
 u-boot-spl_HS_SPI_X-LOADER: $(obj)/u-boot-spl.bin
$(call if_changed,mkomapsecimg)
 
-# For supporting single stage XiP QSPI on AM43xx, the
-# image is a full u-boot file, not an SPL. In this case
-# the mkomapsecimg command looks for a u-boot-HS_* prefix
+# For supporting single stage XiP QSPI on AM43xx, the image is a full u-boot
+# file, not an SPL. In this case the mkomapsecimg command looks for a
+# u-boot-HS_* prefix
 u-boot_HS_XIP_X-LOADER: $(obj)/u-boot.bin
$(call if_changed,mkomapsecimg)
+
+# For supporting the SPL loading and interpreting of FIT images whose
+# components are pre-processed before being integrated into the FIT image in
+# order to secure them in some way
+ifdef CONFIG_SPL_LOAD_FIT
+
+MKIMAGEFLAGS_u-boot_HS.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
+   -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
+   -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
+   $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST)))
+
+OF_LIST_TARGETS = $(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst 
",,$(CONFIG_OF_LIST)))
+$(OF_LIST_TARGETS): dtbs
+
+%_HS.dtb: %.dtb
+   $(call if_changed,omapsecureimg)
+   $(Q)if [ -f $@ ]; then \
+   cp -f $@ $<; \
+   fi
+
+u-boot-nodtb_HS.bin: u-boot-nodtb.bin
+   $(call if_changed,omapsecureimg)
+
+u-boot_HS.img: u-boot-nodtb_HS.bin u-boot.img $(patsubst 
%.dtb,%_HS.dtb,$(OF_LIST_TARGETS))
+   $(call if_changed,mkimage)
+   $(Q)if [ -f $@ ]; then \
+   cp -f $@ u-boot.img; \
+   fi
+
+endif
-- 
2.6.4


[U-Boot] [PATCH v2 1/9] arm: cache: add missing dummy functions for when dcache disabled

2016-06-24 Thread Andreas Dannenberg
From: Daniel Allred 

Adds missing flush_dcache_range and invalidate_dcache_range dummy
(empty) placeholder functions to the #else portion of the #ifndef
CONFIG_SYS_DCACHE_OFF, where full implementations of these functions
are defined.

Signed-off-by: Daniel Allred 
Signed-off-by: Andreas Dannenberg 
Reviewed-by: Simon Glass 
Reviewed-by: Tom Rini 
---
 arch/arm/cpu/armv7/cache_v7.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c
index dc309da..24fe0c5 100644
--- a/arch/arm/cpu/armv7/cache_v7.c
+++ b/arch/arm/cpu/armv7/cache_v7.c
@@ -195,6 +195,14 @@ void flush_dcache_all(void)
 {
 }
 
+void invalidate_dcache_range(unsigned long start, unsigned long stop)
+{
+}
+
+void flush_dcache_range(unsigned long start, unsigned long stop)
+{
+}
+
 void arm_init_before_mmu(void)
 {
 }
-- 
2.6.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 2/9] arm: omap-common: add secure smc entry

2016-06-24 Thread Andreas Dannenberg
From: Daniel Allred 

Add an interface for calling secure ROM APIs across a range of OMAP and
OMAP compatible high-security (HS) device variants. While at it, also
perform minor cleanup/alignment without any change in functionality.

Signed-off-by: Daniel Allred 
Signed-off-by: Andreas Dannenberg 
Reviewed-by: Simon Glass 
Reviewed-by: Tom Rini 
---
 arch/arm/cpu/armv7/omap-common/lowlevel_init.S | 45 --
 arch/arm/include/asm/omap_common.h |  6 
 2 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/lowlevel_init.S 
b/arch/arm/cpu/armv7/omap-common/lowlevel_init.S
index 5283135..66a3b3d 100644
--- a/arch/arm/cpu/armv7/omap-common/lowlevel_init.S
+++ b/arch/arm/cpu/armv7/omap-common/lowlevel_init.S
@@ -16,9 +16,10 @@
 #include 
 #include 
 
+.arch_extension sec
+
 #ifdef CONFIG_SPL
 ENTRY(save_boot_params)
-
ldr r1, =OMAP_SRAM_SCRATCH_BOOT_PARAMS
str r0, [r1]
b   save_boot_params_ret
@@ -26,14 +27,40 @@ ENDPROC(save_boot_params)
 #endif
 
 ENTRY(omap_smc1)
-   PUSH{r4-r12, lr}@ save registers - ROM code may pollute
+   push{r4-r12, lr}@ save registers - ROM code may pollute
@ our registers
-   MOV r12, r0 @ Service
-   MOV r0, r1  @ Argument
-   DSB
-   DMB
-   .word   0xe1600070  @ SMC #0 - hand assembled for GCC versions
-   @ call ROM Code API for the service requested
+   mov r12, r0 @ Service
+   mov r0, r1  @ Argument
 
-   POP {r4-r12, pc}
+   dsb
+   dmb
+   smc 0   @ SMC #0 to enter monitor mode
+   @ call ROM Code API for the service requested
+   pop {r4-r12, pc}
 ENDPROC(omap_smc1)
+
+ENTRY(omap_smc_sec)
+   push{r4-r12, lr}@ save registers - ROM code may pollute
+   @ our registers
+   mov r6, #0xFF   @ Indicate new Task call
+   mov r12, #0x00  @ Secure Service ID in R12
+
+   dsb
+   dmb
+   smc 0   @ SMC #0 to enter monitor mode
+
+   b   omap_smc_sec_end @ exit at end of the service execution
+   nop
+
+   @ In case of IRQ happening in Secure, then ARM will branch here.
+   @ At that moment, IRQ will be pending and ARM will jump to Non Secure
+   @ IRQ handler
+   mov r12, #0xFE
+
+   dsb
+   dmb
+   smc 0   @ SMC #0 to enter monitor mode
+
+omap_smc_sec_end:
+   pop {r4-r12, pc}
+ENDPROC(omap_smc_sec)
diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index 07f3848..605c549 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -627,6 +627,12 @@ void recalibrate_iodelay(void);
 
 void omap_smc1(u32 service, u32 val);
 
+/*
+ * Low-level helper function used when performing secure ROM calls on high-
+ * security (HS) device variants by doing a specially-formed smc entry.
+ */
+u32 omap_smc_sec(u32 service, u32 proc_id, u32 flag, u32 *params);
+
 void enable_edma3_clocks(void);
 void disable_edma3_clocks(void);
 
-- 
2.6.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 9/9] doc: Update info on using secure devices from TI

2016-06-24 Thread Andreas Dannenberg
Adds information regarding SPL handling the loading and processing of
secured u-boot images as part of the second stage boot the SPL does.
Introduces the description of a new interface script in the TI SECDEV
Package which handles the creation and prep of secured binary images.

Signed-off-by: Daniel Allred 
Signed-off-by: Andreas Dannenberg 
---
 doc/README.ti-secure | 177 +++
 1 file changed, 123 insertions(+), 54 deletions(-)

diff --git a/doc/README.ti-secure b/doc/README.ti-secure
index 7fc9b9b..54c996d 100644
--- a/doc/README.ti-secure
+++ b/doc/README.ti-secure
@@ -19,69 +19,80 @@ control restrictions. Access must be requested and granted 
by TI before the
 package is viewable and downloadable. Contact TI, either online or by way
 of a local TI representative, to request access.
 
-When CONFIG_TI_SECURE_DEVICE is set, the U-Boot SPL build process requires
-the presence and use of these tools in order to create a viable boot image.
-The build process will look for the environment variable TI_SECURE_DEV_PKG,
-which should be the path of the installed SECDEV package. If the
-TI_SECURE_DEV_PKG variable is not defined or if it is defined but doesn't
-point to a valid SECDEV package, a warning is issued during the build to
-indicate that a final secure bootable image was not created.
-
-Within the SECDEV package exists an image creation script:
-
-${TI_SECURE_DEV_PKG}/scripts/create-boot-image.sh
-
-This is called as part of the SPL/u-boot build process. As the secure boot
-image formats and requirements differ between secure SOC from TI, the
-purpose of this script is to abstract these details as much as possible.
-
-The script is basically the only required interface to the TI SECDEV package
-for secure TI devices.
-
-Invoking the script for AM43xx Secure Devices
-=
-
-create-boot-image.sh
-
- is a value that specifies the type of the image to generate OR
-the action the image generation tool will take. Valid values are:
-   SPI_X-LOADER - Generates an image for SPI flash (byte swapped)
-   XIP_X-LOADER - Generates a single stage u-boot for NOR/QSPI XiP
-   ISSW - Generates an image for all other boot modes
-
- is the full path and filename of the public world boot loader
-binary file (depending on the boot media, this is usually either
-u-boot-spl.bin or u-boot.bin).
-
- is the full path and filename of the final secure image. The
-output binary images should be used in place of the standard non-secure
-binary images (see the platform-specific user's guides and releases notes
-for how the non-secure images are typically used)
+Booting of U-Boot SPL
+=
+
+   When CONFIG_TI_SECURE_DEVICE is set, the U-Boot SPL build process
+   requires the presence and use of these tools in order to create a
+   viable boot image. The build process will look for the environment
+   variable TI_SECURE_DEV_PKG, which should be the path of the installed
+   SECDEV package. If the TI_SECURE_DEV_PKG variable is not defined or
+   if it is defined but doesn't point to a valid SECDEV package, a
+   warning is issued during the build to indicate that a final secure
+   bootable image was not created.
+
+   Within the SECDEV package exists an image creation script:
+
+   ${TI_SECURE_DEV_PKG}/scripts/create-boot-image.sh
+
+   This is called as part of the SPL/u-boot build process. As the secure
+   boot image formats and requirements differ between secure SOC from TI,
+   the purpose of this script is to abstract these details as much as
+   possible.
+
+   The script is basically the only required interface to the TI SECDEV
+   package for creating a bootable SPL image for secure TI devices.
+
+   Invoking the script for AM43xx Secure Devices
+   =
+
+   create-boot-image.sh \
+  
+
+is a value that specifies the type of the image to
+   generate OR the action the image generation tool will take. Valid
+   values are:
+   SPI_X-LOADER - Generates an image for SPI flash (byte
+   swapped)
+   XIP_X-LOADER - Generates a single stage u-boot for
+   NOR/QSPI XiP
+   ISSW - Generates an image for all other boot modes
+
+is the full path and filename of the public world boot
+   loaderbinary file (depending on the boot media, this is usually
+   either u-boot-spl.bin or u-boot.bin).
+
+is the full path and filename of the final secure
+   image. The output binary images should be used in place of the standard
+   non-secure binary images (see the platform-specific user's guides and
+   releases notes for how the non-secure images are typically used)
u-boot-spl_HS_SPI_X-LOADER - byte swapped boot image for SPI flash
u-boot_HS_XIP_X-LO

[U-Boot] [PATCH v2 0/9] Secure Boot by Authenticating/Decrypting SPL FIT blobs

2016-06-24 Thread Andreas Dannenberg
This is an updated version of a patch series that introduces a generic way
to optionally post-process blobs as they get extracted by the SPL from the
u-boot.img FIT image, and uses this scheme to perform some authentication/
decryption related processing on TI's high-secure (HS) SoC variants. For
additional background please see here [1].

Despite there being a few changes (see below) based on previous feedback
(thanks!) I did carry forward most of the Reviewed-by: tags as I felt the
fundamental approach and most if not all of the building blocks pretty much
stayed intact, I hope that's okay.

I've also completely re-rested the series on all applicable HS devices and
checked for any build issues as well as runtime issues without findings.

Changes PATCH->PATCH v2:
- Added some glue code to suppress SPL "Authentication passed" log messages
  in case of UART/Y-Modem boot (thanks Lokesh)
- Dropped the .NOTPARALLEL make hack when building the 'dtbs' target. Now, we
  rely on Yamada-san's patch [2] that fixes this on a more global scale
- Fixed some typos (thanks Yamada-san)
- Turned the __weak function call for inserting a post-processing function
  into a Kconfig option (thanks Simon). Also enabled that Kconfig option
  on applicable AM43xx HS, AM57xx HS, DRA7xx HS, and DRA72xx HS device
  variants defconfig files (note there is a dependency on [3] which renames
  the AM437x HS defconfig file)
- Introduced a new header file omap_sec_common.h for commom security API as
  using omap_common.h as done previously led to issues trying to use this file
  on AM43xx type devices. This device family (and AM335x as well) is not
  supported by omap_common.h, and trying to include this file into AM43xx board
  files leads to all kinds of issues (the registers and definitions are simply
  not compatible)
- Re-ordered the series so that the Kconfig option is introduced after all
  of the building blocks have been put into place (generic infrastructure and
  the TI-specific implementation).
- Minor readme update to account for the new Kconfig option

Changes RFC->PATCH:
- Update of README.ti-secure
- Unification of some of the secure ROM API call stuff between AM43xx and
  OMAP5-based platforms by moving those into common files
- Replacement of puts() with printf()
- Minor build simplification/cleanup
- Addition of "Reviewed-by:" comments for files that were pretty much carried
  over from the RFC as-is
- Addition of AM437x HS device build support (was missing in RFC)
- Removal of some redundant conditional compile directives
- Rebased on upstream U-Boot commit "Prepare v2016.07-rc2"


--
Andreas Dannenberg
Texas Instruments Inc


[1] http://lists.denx.de/pipermail/u-boot/2016-June/258716.html
[2] http://lists.denx.de/pipermail/u-boot/2016-June/258912.html
[3] http://lists.denx.de/pipermail/u-boot/2016-June/258896.html

Andreas Dannenberg (5):
  arm: omap-common: add secure rom call API for secure devices
  arm: omap-common: secure ROM signature verify API
  arm: omap-common: Update to generate secure U-Boot FIT blob
  arm: omap5: add U-Boot FIT signing and SPL image post-processing
  doc: Update info on using secure devices from TI

Daniel Allred (3):
  arm: cache: add missing dummy functions for when dcache disabled
  arm: omap-common: add secure smc entry
  spl: fit: add support for post-processing of images

Madan Srinivas (1):
  arm: am4x: add U-Boot FIT signing and SPL image post-processing

 Kconfig |   4 +
 arch/arm/cpu/armv7/am33xx/config.mk |   1 +
 arch/arm/cpu/armv7/cache_v7.c   |   8 ++
 arch/arm/cpu/armv7/omap-common/Makefile |   2 +
 arch/arm/cpu/armv7/omap-common/config_secure.mk |  75 --
 arch/arm/cpu/armv7/omap-common/lowlevel_init.S  |  45 --
 arch/arm/cpu/armv7/omap-common/sec-common.c | 138 ++
 arch/arm/cpu/armv7/omap5/config.mk  |   3 +
 arch/arm/include/asm/omap_common.h  |   6 +
 arch/arm/include/asm/omap_sec_common.h  |  30 
 board/ti/am43xx/board.c |   8 ++
 board/ti/am57xx/board.c |   8 ++
 board/ti/dra7xx/evm.c   |   9 ++
 common/spl/spl_fit.c|  21 ++-
 configs/am43xx_hs_evm_defconfig |   1 +
 configs/am57xx_hs_evm_defconfig |   1 +
 configs/dra7xx_hs_evm_defconfig |   1 +
 doc/README.ti-secure| 177 
 include/image.h |  17 +++
 19 files changed, 473 insertions(+), 82 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/omap-common/sec-common.c
 create mode 100644 arch/arm/include/asm/omap_sec_common.h

-- 
2.6.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH V2 1/3] mmc: fsl: reset to normal boot mode when eMMC fast boot

2016-06-24 Thread york sun
On 06/24/2016 02:39 AM, Peng Fan wrote:
> Hi York, Stefano
>
> Any comments on this patch set? Would you kindly pick up this patch set?

Technically Panto is the maintainer of MMC. Since this set is dealing 
with FSL mmc controller, I will pick it up if Panto doesn't mind.

York


>
> Thanks,
> Peng.
> On Wed, Jun 15, 2016 at 10:53:00AM +0800, Peng Fan wrote:
>> When booting in eMMC fast boot, MMC host does not exit from
>> boot mode after bootrom loading image. So the first command
>> 'CMD0' sent in uboot will pull down the CMD line to low and
>> cause errors.
>>
>> This patch cleans the MMC boot register in "mmc_init" to put the
>> MMC host back to normal mode.
>>
>> Also clear DLL_CTRL delay line settings at USDHC initialization
>> to eliminate the pre-settings from boot rom.
>>
>> Signed-off-by: Peng Fan 
>> Cc: Pantelis Antoniou 
>> Cc: York Sun 
>> Cc: Stefano Babic 
>> Cc: Fabio Estevam 
>> ---
>>
>> V2:
>> Rebased to lastest u-boot master
>>
>> drivers/mmc/fsl_esdhc.c | 38 +-
>> include/fsl_esdhc.h |  6 ++
>> 2 files changed, 35 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
>> index 57ad975..9cd582f 100644
>> --- a/drivers/mmc/fsl_esdhc.c
>> +++ b/drivers/mmc/fsl_esdhc.c
>> @@ -56,21 +56,27 @@ struct fsl_esdhc {
>>  uintfevt;   /* Force event register */
>>  uintadmaes; /* ADMA error status register */
>>  uintadsaddr;/* ADMA system address register */
>> -charreserved2[100]; /* reserved */
>> -uintvendorspec; /* Vendor Specific register */
>> -charreserved3[56];  /* reserved */
>> +charreserved2[4];
>> +uintdllctrl;
>> +uintdllstat;
>> +uintclktunectrlstatus;
>> +charreserved3[84];
>> +uintvendorspec;
>> +uintmmcboot;
>> +uintvendorspec2;
>> +charreserved4[48];
>>  uinthostver;/* Host controller version register */
>> -charreserved4[4];   /* reserved */
>> -uintdmaerraddr; /* DMA error address register */
>>  charreserved5[4];   /* reserved */
>> -uintdmaerrattr; /* DMA error attribute register */
>> +uintdmaerraddr; /* DMA error address register */
>>  charreserved6[4];   /* reserved */
>> +uintdmaerrattr; /* DMA error attribute register */
>> +charreserved7[4];   /* reserved */
>>  uinthostcapblt2;/* Host controller capabilities register 2 */
>> -charreserved7[8];   /* reserved */
>> +charreserved8[8];   /* reserved */
>>  uinttcr;/* Tuning control register */
>> -charreserved8[28];  /* reserved */
>> +charreserved9[28];  /* reserved */
>>  uintsddirctl;   /* SD direction control register */
>> -charreserved9[712]; /* reserved */
>> +charreserved10[712];/* reserved */
>>  uintscr;/* eSDHC control register */
>> };
>>
>> @@ -616,6 +622,20 @@ static int esdhc_init(struct mmc *mmc)
>>  while ((esdhc_read32(®s->sysctl) & SYSCTL_RSTA) && --timeout)
>>  udelay(1000);
>>
>> +#if defined(CONFIG_FSL_USDHC)
>> +/* RSTA doesn't reset MMC_BOOT register, so manually reset it */
>> +esdhc_write32(®s->mmcboot, 0x0);
>> +/* Reset MIX_CTRL and CLK_TUNE_CTRL_STATUS regs to 0 */
>> +esdhc_write32(®s->mixctrl, 0x0);
>> +esdhc_write32(®s->clktunectrlstatus, 0x0);
>> +
>> +/* Put VEND_SPEC to default value */
>> +esdhc_write32(®s->vendorspec, VENDORSPEC_INIT);
>> +
>> +/* Disable DLL_CTRL delay line */
>> +esdhc_write32(®s->dllctrl, 0x0);
>> +#endif
>> +
>> #ifndef ARCH_MXC
>>  /* Enable cache snooping */
>>  esdhc_write32(®s->scr, 0x0040);
>> diff --git a/include/fsl_esdhc.h b/include/fsl_esdhc.h
>> index fa760a5..78c67c8 100644
>> --- a/include/fsl_esdhc.h
>> +++ b/include/fsl_esdhc.h
>> @@ -35,6 +35,12 @@
>> #define SYSCTL_RSTC  0x0200
>> #define SYSCTL_RSTD  0x0400
>>
>> +#define VENDORSPEC_CKEN 0x4000
>> +#define VENDORSPEC_PEREN0x2000
>> +#define VENDORSPEC_HCKEN0x1000
>> +#define VENDORSPEC_IPGEN0x0800
>> +#define VENDORSPEC_INIT 0x20007809
>> +
>> #define IRQSTAT  0x0002e030
>> #define IRQSTAT_DMAE (0x1000)
>> #define IRQSTAT_AC12E(0x0100)
>> --
>> 2.6.2
>>
>

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5 0/8] ARMv7: PSCI: add PSCI v1.0 support

2016-06-24 Thread york sun
On 06/15/2016 12:16 AM, Chen-Yu Tsai wrote:
> Hi,
>
> On Tue, Jun 14, 2016 at 3:01 PM,   wrote:
>> From: Hongbo Zhang 
>>
>> v5 changes:
>> - Give up fixing the potential bug of PSCI stack overlap with secure text end
>> when there is more CPUs in system. Because I just want to keep this series as
>> simple as it could be: adding basic PSCI v1.0 support and adding more PSCI
>> v1.0 implements of our platform.
>> While too compplicated patches in assembly language won't call for effective
>> reviews, even I think there is potential bug of PSCI stack, let's fix it in
>> sepetated patch later.
>
> I've done some patches fixing the stack allocation issue:
>
> https://github.com/wens/u-boot-sunxi/commits/c-psci-part2
>
> These patches are ready, but I want to add a secure data section still.
> The data section will be for variables such as target PC, core/cluster
> power status, context ID, etc.. IMHO this is better than putting stuff
> at the top or bottom of the stack, and can also be referenced directly.
>


Chenyu,

I see you have been working on PSCI for ARMv7. Can you review Hongbo's 
patch set and give your comment or ack?

York


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH V2] net: NFS: Add NFSv3 support

2016-06-24 Thread Tom Rini
On Fri, Jun 24, 2016 at 09:45:38AM +0200, Guillaume Gardet wrote:
> 
> 
> Le 23/06/2016 21:08, Tom Rini a écrit :
> >On Thu, Jun 23, 2016 at 11:10:26AM +0200, Guillaume GARDET wrote:
> >
> >>This patch enables NFSv3 support.
> >>If NFSv2 is available use it as usual.
> >>If NFSv2 is not available, but NFSv3 is available, use NFSv3.
> >>If NFSv2 and NFSv3 are not available, print an error message since NFSv4 is 
> >>not supported.
> >>
> >>Tested on iMX6 sabrelite with 4 Linux NFS servers:
> >>   * NFSv2 + NFSv3 + NFSv4 server: use NFSv2 protocol
> >>   * NFSv2 + NFSv3 server: use NFSv3 protocol
> >>   * NFSv3 + NFSv4 server: use NFSv3 protocol
> >>   * NFSv3 server: use NFSv3 protocol
> >So, why do we have v2+v3+v4 -> v2 and not v2+v3+v4 -> v3, when we do
> >v2+v3 -> v3 and v3+v4 -> v3 ?  We should be consistent in preferring
> >either v2 over v3 or v3 over v2.  Thanks!
> >
> 
> Sorry, it is a typo error. Please read: "NFSv2 + NFSv3 server: use NFSv2 
> protocol".
> 
> As long as NFSv2 is available, we use it. Otherwise, we use v3 if
> available. As explained above.

OK, that makes sense, thanks!  Joe, I assume you can just fix that in
the commit message when you pick this up.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] Message handling problem in dwc2_otg driver

2016-06-24 Thread Gyorgy Kovesdi
Hi,

I am using u-boot revision d141e218f3195e305c1521a0d67c81b7cb504b71
(dec 28 2015).
The platform is socfpga cyclone-V.

I connected some different USB devices to my USB port, and some of them
have problems. Especially, if i connect another linux box with CDC mass
storage or ethernet emulation, the device is not detected.

I found that the problem is the NAK message handling: if i connect a
pendrive then no NAK messages returned, but using CDC mass storage
device, there are a lot of them. The problem is that the NAK messages
are not handled at all: if such one received, the driver enters an
endless loop (in file dwc2_otg-hcd.c: see the /* TODO: no endless loop
*/ comment).

AFAIK, the NAK handling is basically necessary for USB communication: i
do not understand how can it work without NAK handling at all. Am i the
only one having NAK messages in this case?

I need some help to resolve the NAK handling here.

Thanx in advance
Gyorgy Kovesdi
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/3] tools: patman: Handle missing 'END' for 'Cover-letter'

2016-06-24 Thread Bin Meng
If 'END' is missing in a 'Cover-letter' section, and that section
happens to show up at the very end of the commit message, patman
fails to generate cover letter for us. Handle this in CloseCommit
of patchstream.

Signed-off-by: Bin Meng 
---

 tools/patman/patchstream.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index eeeb5ea..5573326 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -112,6 +112,11 @@ class PatchStream:
 if self.commit and self.is_log:
 self.series.AddCommit(self.commit)
 self.commit = None
+# If 'END' is missing in a 'Cover-letter' section, and that section
+# happens to show up at the very end of the commit message, this is
+# the chance for us to fix it up.
+if self.in_section == 'cover' and self.is_log:
+self.series.cover = self.section
 
 def ProcessLine(self, line):
 """Process a single line of a patch file or commit log
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/3] tools: patman: Handle tag sections without an 'END'

2016-06-24 Thread Bin Meng
'Cover-letter', 'Series-notes' and 'Commit-notes' tags require an
'END' to be put at the end of its section. When 'END' is missing,
patman generates incorrect patches. This adds codes to handle such
scenario.

Signed-off-by: Bin Meng 
---

 tools/patman/patchstream.py | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index 27d031e..eeeb5ea 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -168,6 +168,25 @@ class PatchStream:
 elif commit_match:
 self.state = STATE_MSG_HEADER
 
+# If a tag is detected, but we are already in a section,
+# this means 'END' is missing for that section, fix it up.
+if series_tag_match or commit_tag_match or \
+   cover_cc_match or signoff_match:
+if self.in_section:
+if self.in_section == 'cover':
+self.series.cover = self.section
+elif self.in_section == 'notes':
+if self.is_log:
+self.series.notes += self.section
+elif self.in_section == 'commit-notes':
+if self.is_log:
+self.commit.notes += self.section
+else:
+self.warn.append("Unknown section '%s'" % self.in_section)
+self.in_section = None
+self.skip_blank = True
+self.section = []
+
 # If we are in a section, keep collecting lines until we see END
 if self.in_section:
 if line == 'END':
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/3] tools: patman: Handle missing blank line for 'Series-changes'

2016-06-24 Thread Bin Meng
'Series-changes' uses blank line to indicate its end. If that is
missing, series internal state variable 'in_change' may be wrong.
Correct its state.

Signed-off-by: Bin Meng 
---

 tools/patman/patchstream.py | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index 5573326..338b581 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -173,10 +173,10 @@ class PatchStream:
 elif commit_match:
 self.state = STATE_MSG_HEADER
 
-# If a tag is detected, but we are already in a section,
-# this means 'END' is missing for that section, fix it up.
 if series_tag_match or commit_tag_match or \
cover_cc_match or signoff_match:
+# If a tag is detected, but we are already in a section,
+# this means 'END' is missing for that section, fix it up.
 if self.in_section:
 if self.in_section == 'cover':
 self.series.cover = self.section
@@ -191,6 +191,10 @@ class PatchStream:
 self.in_section = None
 self.skip_blank = True
 self.section = []
+# If a tag is detected, but we are already in a change list,
+# that means a blank line is missing, fix it up.
+if self.in_change:
+self.in_change = 0
 
 # If we are in a section, keep collecting lines until we see END
 if self.in_section:
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] pci: tegra: actually program REFCLK_CFG* on recent SoCs

2016-06-24 Thread Stephen Warren
From: Stephen Warren 

On recent SoCs, tegra_pcie_phy_enable() isn't called; but instead
tegra_pcie_enable_controller() calls tegra_xusb_phy_enable(). However,
part of tegra_pcie_phy_enable() needs to happen in all cases. Move that
code to tegra_pcie_port_enable() instead.

For reference, NVIDIA's downstream Linux kernel performs this operation
in tegra_pcie_enable_rp_features(), which is called immediately after
tegra_pcie_port_enable(). Since that function doesn't exist in the U-Boot
driver, we'll just add it to the tail of tegra_pcie_port_enable() instead.

Signed-off-by: Stephen Warren 
---
 drivers/pci/pci_tegra.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/pci_tegra.c b/drivers/pci/pci_tegra.c
index 1aa56fc93739..352cdef56ab4 100644
--- a/drivers/pci/pci_tegra.c
+++ b/drivers/pci/pci_tegra.c
@@ -620,11 +620,6 @@ static int tegra_pcie_phy_enable(struct tegra_pcie *pcie)
value |= PADS_PLL_CTL_RST_B4SM;
pads_writel(pcie, value, soc->pads_pll_ctl);
 
-   /* configure the reference clock driver */
-   pads_writel(pcie, soc->pads_refclk_cfg0, PADS_REFCLK_CFG0);
-   if (soc->num_ports > 2)
-   pads_writel(pcie, soc->pads_refclk_cfg1, PADS_REFCLK_CFG1);
-
/* wait for the PLL to lock */
err = tegra_pcie_pll_wait(pcie, 500);
if (err < 0) {
@@ -818,20 +813,21 @@ static void tegra_pcie_port_reset(struct tegra_pcie_port 
*port)
 
 static void tegra_pcie_port_enable(struct tegra_pcie_port *port)
 {
-   const struct tegra_pcie_soc *soc = port->pcie->soc;
+   struct tegra_pcie *pcie = port->pcie;
+   const struct tegra_pcie_soc *soc = pcie->soc;
unsigned long ctrl = tegra_pcie_port_get_pex_ctrl(port);
unsigned long value;
 
/* enable reference clock */
-   value = afi_readl(port->pcie, ctrl);
+   value = afi_readl(pcie, ctrl);
value |= AFI_PEX_CTRL_REFCLK_EN;
 
-   if (port->pcie->soc->has_pex_clkreq_en)
+   if (pcie->soc->has_pex_clkreq_en)
value |= AFI_PEX_CTRL_CLKREQ_EN;
 
value |= AFI_PEX_CTRL_OVERRIDE_EN;
 
-   afi_writel(port->pcie, value, ctrl);
+   afi_writel(pcie, value, ctrl);
 
tegra_pcie_port_reset(port);
 
@@ -840,6 +836,11 @@ static void tegra_pcie_port_enable(struct tegra_pcie_port 
*port)
value |= RP_VEND_CTL2_PCA_ENABLE;
rp_writel(port, value, RP_VEND_CTL2);
}
+
+   /* configure the reference clock driver */
+   pads_writel(pcie, soc->pads_refclk_cfg0, PADS_REFCLK_CFG0);
+   if (soc->num_ports > 2)
+   pads_writel(pcie, soc->pads_refclk_cfg1, PADS_REFCLK_CFG1);
 }
 
 static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port)
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 09/12] libfdt: Add fdt_getprop_namelen_w

2016-06-24 Thread Maxime Ripard
Add a function to retrieve a writeable property only by the first
characters of its name.

Signed-off-by: Maxime Ripard 
---
 include/libfdt.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index dbe8a0efca87..b8758de3ae54 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int 
offset,
  */
 const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
const char *name, int namelen, int *lenp);
+static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
+ const char *name, int namelen,
+ int *lenp)
+{
+   return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
+ namelen, lenp);
+}
 
 /**
  * fdt_getprop - retrieve the value of a given property
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 12/12] tests: Introduce DT overlay tests

2016-06-24 Thread Maxime Ripard
This adds a bunch of unit tests for the "fdt apply" command.

They've all been run successfully in the sandbox. However, as you still
require an out-of-tree dtc with overlay support, this is disabled by
default.

Acked-by: Simon Glass 
Acked-by: Pantelis Antoniou 
Signed-off-by: Maxime Ripard 
---
 Makefile  |   1 +
 include/test/overlay.h|  16 +++
 include/test/suites.h |   1 +
 test/Kconfig  |   1 +
 test/cmd_ut.c |   6 +
 test/overlay/Kconfig  |  11 ++
 test/overlay/Makefile |  15 +++
 test/overlay/cmd_ut_overlay.c | 243 ++
 test/overlay/test-fdt-base.dts|  21 
 test/overlay/test-fdt-overlay.dts |  88 ++
 10 files changed, 403 insertions(+)
 create mode 100644 include/test/overlay.h
 create mode 100644 test/overlay/Kconfig
 create mode 100644 test/overlay/Makefile
 create mode 100644 test/overlay/cmd_ut_overlay.c
 create mode 100644 test/overlay/test-fdt-base.dts
 create mode 100644 test/overlay/test-fdt-overlay.dts

diff --git a/Makefile b/Makefile
index d0e7a8a4ecc7..88353d091be8 100644
--- a/Makefile
+++ b/Makefile
@@ -665,6 +665,7 @@ libs-$(CONFIG_HAS_POST) += post/
 libs-y += test/
 libs-y += test/dm/
 libs-$(CONFIG_UT_ENV) += test/env/
+libs-$(CONFIG_UT_OVERLAY) += test/overlay/
 
 libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
 
diff --git a/include/test/overlay.h b/include/test/overlay.h
new file mode 100644
index ..392f28ff8405
--- /dev/null
+++ b/include/test/overlay.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __TEST_OVERLAY_H__
+#define __TEST_OVERLAY_H__
+
+#include 
+
+/* Declare a new environment test */
+#define OVERLAY_TEST(_name, _flags)UNIT_TEST(_name, _flags, overlay_test)
+
+#endif /* __TEST_OVERLAY_H__ */
diff --git a/include/test/suites.h b/include/test/suites.h
index f5790333ff8e..0e94feb07a79 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -10,6 +10,7 @@
 
 int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
 #endif /* __TEST_SUITES_H__ */
diff --git a/test/Kconfig b/test/Kconfig
index d71c332eee27..3643761bc6ef 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -17,3 +17,4 @@ config UT_TIME
 
 source "test/dm/Kconfig"
 source "test/env/Kconfig"
+source "test/overlay/Kconfig"
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f6e1f413db7f..14333423a178 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -19,6 +19,9 @@ static cmd_tbl_t cmd_ut_sub[] = {
 #if defined(CONFIG_UT_ENV)
U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""),
 #endif
+#ifdef CONFIG_UT_OVERLAY
+   U_BOOT_CMD_MKENT(overlay, CONFIG_SYS_MAXARGS, 1, do_ut_overlay, "", ""),
+#endif
 #ifdef CONFIG_UT_TIME
U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),
 #endif
@@ -68,6 +71,9 @@ static char ut_help_text[] =
 #ifdef CONFIG_UT_ENV
"ut env [test-name]\n"
 #endif
+#ifdef CONFIG_UT_OVERLAY
+   "ut overlay [test-name]\n"
+#endif
 #ifdef CONFIG_UT_TIME
"ut time - Very basic test of time functions\n"
 #endif
diff --git a/test/overlay/Kconfig b/test/overlay/Kconfig
new file mode 100644
index ..13c85428cbaa
--- /dev/null
+++ b/test/overlay/Kconfig
@@ -0,0 +1,11 @@
+config UT_OVERLAY
+   bool "Enable Device Tree Overlays Unit Tests"
+   depends on OF_LIBFDT_OVERLAY
+   depends on UNIT_TEST
+   help
+ This enables the 'ut overlay' command which runs a series of unit
+ tests on the fdt overlay code.
+ If all is well then all tests pass although there will be a few
+ messages printed along the way.
+ Be warned that it requires an out-of-tree dtc compiler with patches
+ to support the DT overlays, otherwise it will fail.
diff --git a/test/overlay/Makefile b/test/overlay/Makefile
new file mode 100644
index ..907f08544619
--- /dev/null
+++ b/test/overlay/Makefile
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2016 NextThing Co
+# Copyright (c) 2016 Free Electrons
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+# Test files
+obj-y += cmd_ut_overlay.o
+
+DTC_FLAGS += -@
+
+# DT overlays
+obj-y += test-fdt-base.dtb.o
+obj-y += test-fdt-overlay.dtb.o
diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c
new file mode 100644
index ..4a9b3398d119
--- /dev/null
+++ b/test/overlay/cmd_ut_overlay.c
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#in

[U-Boot] [PATCH v3 08/12] libfdt: Add fdt_path_offset_namelen

2016-06-24 Thread Maxime Ripard
Add a namelen variant of fdt_path_offset to retrieve the node offset using
only a fixed number of characters.

Signed-off-by: Maxime Ripard 
---
 include/libfdt.h| 16 +++-
 lib/libfdt/fdt_ro.c | 18 ++
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/include/libfdt.h b/include/libfdt.h
index 2c8a42bcb667..dbe8a0efca87 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -365,6 +365,17 @@ int fdt_subnode_offset_namelen(const void *fdt, int 
parentoffset,
  */
 int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
 
+/**
+ * fdt_path_offset_namelen - find a tree node based on substring
+ * @fdt: pointer to the device tree blob
+ * @path: full path of the node to locate
+ * @namelen: number of characters of name to consider
+ *
+ * Identical to fdt_path_offset(), but only examine the first
+ * namelen characters of path for matching the node path.
+ */
+int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
+
 /**
  * fdt_path_offset - find a tree node by its full path
  * @fdt: pointer to the device tree blob
@@ -387,7 +398,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, 
const char *name);
  * -FDT_ERR_BADSTRUCTURE,
  * -FDT_ERR_TRUNCATED, standard meanings.
  */
-int fdt_path_offset(const void *fdt, const char *path);
+static inline int fdt_path_offset(const void *fdt, const char *path)
+{
+   return fdt_path_offset_namelen(fdt, path, strlen(path));
+}
 
 /**
  * fdt_get_name - retrieve the name of a given node
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 503150ef1dc5..05344d3eebfe 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -145,10 +145,10 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
  * "foo/bar:option" and "bar:option/otheroption", both of which happen, so
  * first searching for either ':' or '/' does not work.
  */
-static const char *fdt_path_next_seperator(const char *path)
+static const char *fdt_path_next_seperator(const void *path, int len)
 {
-   const char *sep1 = strchr(path, '/');
-   const char *sep2 = strchr(path, ':');
+   const void *sep1 = memchr(path, '/', len);
+   const void *sep2 = memchr(path, ':', len);
 
if (sep1 && sep2)
return (sep1 < sep2) ? sep1 : sep2;
@@ -158,9 +158,9 @@ static const char *fdt_path_next_seperator(const char *path)
return sep2;
 }
 
-int fdt_path_offset(const void *fdt, const char *path)
+int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
 {
-   const char *end = path + strlen(path);
+   const char *end = path + namelen;
const char *p = path;
int offset = 0;
 
@@ -168,7 +168,7 @@ int fdt_path_offset(const void *fdt, const char *path)
 
/* see if we have an alias */
if (*path != '/') {
-   const char *q = fdt_path_next_seperator(path);
+   const char *q = fdt_path_next_seperator(path, namelen);
 
if (!q)
q = end;
@@ -181,14 +181,16 @@ int fdt_path_offset(const void *fdt, const char *path)
p = q;
}
 
-   while (*p) {
+   while (*p && (p < end)) {
const char *q;
 
while (*p == '/')
p++;
+
if (*p == '\0' || *p == ':')
return offset;
-   q = fdt_path_next_seperator(p);
+
+   q = fdt_path_next_seperator(p, end - p);
if (!q)
q = end;
 
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 11/12] cmd: fdt: add fdt overlay application subcommand

2016-06-24 Thread Maxime Ripard
The device tree overlays are a good way to deal with user-modifyable
boards or boards with some kind of an expansion mechanism where we can
easily plug new board in (like the BBB or the raspberry pi).

However, so far, the usual mechanism to deal with it was to have in Linux
some driver detecting the expansion boards plugged in and then request
these overlays using the firmware interface.

That works in most cases, but in some cases, you might want to have the
overlays applied before the userspace comes in. Either because the new
board requires some kind of an early initialization, or because your root
filesystem is accessed through that expansion board.

The easiest solution in such a case is to simply have the component before
Linux applying that overlay, removing all these drawbacks.

Reviewed-by: Stefan Agner 
Acked-by: Pantelis Antoniou 
Acked-by: Simon Glass 
Signed-off-by: Maxime Ripard 
---
 cmd/fdt.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 0f5923e75a41..58af7727ba08 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -639,6 +639,27 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 #endif
 
}
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+   /* apply an overlay */
+   else if (strncmp(argv[1], "ap", 2) == 0) {
+   unsigned long addr;
+   struct fdt_header *blob;
+
+   if (argc != 3)
+   return CMD_RET_USAGE;
+
+   if (!working_fdt)
+   return CMD_RET_FAILURE;
+
+   addr = simple_strtoul(argv[2], NULL, 16);
+   blob = map_sysmem(addr, 0);
+   if (!fdt_valid(&blob))
+   return CMD_RET_FAILURE;
+
+   if (fdt_overlay_apply(working_fdt, blob))
+   return CMD_RET_FAILURE;
+   }
+#endif
/* resize the fdt */
else if (strncmp(argv[1], "re", 2) == 0) {
fdt_shrink_to_minimum(working_fdt);
@@ -1025,6 +1046,9 @@ static int fdt_print(const char *pathp, char *prop, int 
depth)
 #ifdef CONFIG_SYS_LONGHELP
 static char fdt_help_text[] =
"addr [-c]   []   - Set the [control] fdt location to 
\n"
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+   "fdt apply - Apply overlay to the DT\n"
+#endif
 #ifdef CONFIG_OF_BOARD_SETUP
"fdt boardsetup  - Do board-specific set up\n"
 #endif
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 06/12] libfdt: Add max phandle retrieval function

2016-06-24 Thread Maxime Ripard
Add a function to retrieve the highest phandle in a given device tree.

Signed-off-by: Maxime Ripard 
Reviewed-by: Stefan Agner 
---
 include/libfdt.h| 13 +
 lib/libfdt/fdt_ro.c | 26 ++
 2 files changed, 39 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index fbbe58ceb3f1..4643be5adf39 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -283,6 +283,19 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
  */
 const char *fdt_string(const void *fdt, int stroffset);
 
+/**
+ * fdt_get_max_phandle - retrieves the highest phandle in a tree
+ * @fdt: pointer to the device tree blob
+ *
+ * fdt_get_max_phandle retrieves the highest phandle in the given
+ * device tree
+ *
+ * returns:
+ *  the highest phandle on success
+ *  0, if an error occurred
+ */
+uint32_t fdt_get_max_phandle(const void *fdt);
+
 /**
  * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
  * @fdt: pointer to the device tree blob
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 12214c2dc2b5..503150ef1dc5 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -47,6 +47,32 @@ static int _fdt_string_eq(const void *fdt, int stroffset,
return (strnlen(p, len + 1) == len) && (memcmp(p, s, len) == 0);
 }
 
+uint32_t fdt_get_max_phandle(const void *fdt)
+{
+   uint32_t max_phandle = 0;
+   int offset;
+
+   for (offset = fdt_next_node(fdt, -1, NULL);;
+offset = fdt_next_node(fdt, offset, NULL)) {
+   uint32_t phandle;
+
+   if (offset == -FDT_ERR_NOTFOUND)
+   return max_phandle;
+
+   if (offset < 0)
+   return 0;
+
+   phandle = fdt_get_phandle(fdt, offset);
+   if (phandle == (uint32_t)-1)
+   return 0;
+
+   if (phandle > max_phandle)
+   max_phandle = phandle;
+   }
+
+   return 0;
+}
+
 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
 {
FDT_CHECK_HEADER(fdt);
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 10/12] libfdt: Add overlay application function

2016-06-24 Thread Maxime Ripard
The device tree overlays are a good way to deal with user-modifyable
boards or boards with some kind of an expansion mechanism where we can
easily plug new board in (like the BBB, the Raspberry Pi or the CHIP).

Add a new function to merge overlays with a base device tree.

Signed-off-by: Maxime Ripard 
---
 include/libfdt.h |  30 
 lib/Kconfig  |   5 +
 lib/libfdt/Makefile  |   2 +
 lib/libfdt/fdt_overlay.c | 381 +++
 4 files changed, 418 insertions(+)
 create mode 100644 lib/libfdt/fdt_overlay.c

diff --git a/include/libfdt.h b/include/libfdt.h
index b8758de3ae54..039ecb0c1ba7 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -1747,6 +1747,36 @@ int fdt_add_subnode(void *fdt, int parentoffset, const 
char *name);
  */
 int fdt_del_node(void *fdt, int nodeoffset);
 
+/**
+ * fdt_overlay_apply - Applies a DT overlay on a base DT
+ * @fdt: pointer to the base device tree blob
+ * @fdto: pointer to the device tree overlay blob
+ *
+ * fdt_overlay_apply() will apply the given device tree overlay on the
+ * given base device tree.
+ *
+ * Expect the base device tree to be modified, even if the function
+ * returns an error.
+ *
+ * returns:
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there's not enough space in the base device tree
+ * -FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or
+ * properties in the base DT
+ * -FDT_ERR_BADPHANDLE, the phandles in the overlay do not have the right
+ * magic
+ * -FDT_ERR_INTERNAL,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADOFFSET,
+ * -FDT_ERR_BADPATH,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_overlay_apply(void *fdt, void *fdto);
+
 /**/
 /* Debugging / informational functions*/
 /**/
diff --git a/lib/Kconfig b/lib/Kconfig
index 02ca4058d37e..16ff01a2cd37 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -139,6 +139,11 @@ config OF_LIBFDT
  particular compatible nodes. The library operates on a flattened
  version of the device tree.
 
+config OF_LIBFDT_OVERLAY
+   bool "Enable the FDT library overlay support"
+   help
+ This enables the FDT library (libfdt) overlay support.
+
 config SPL_OF_LIBFDT
bool "Enable the FDT library for SPL"
default y if SPL_OF_CONTROL
diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile
index 8b86c15904cb..6ef8290f4e09 100644
--- a/lib/libfdt/Makefile
+++ b/lib/libfdt/Makefile
@@ -15,3 +15,5 @@ obj-y += \
fdt_empty_tree.o \
fdt_addresses.o \
fdt_region.o
+
+obj-$(CONFIG_OF_LIBFDT_OVERLAY) += fdt_overlay.o
diff --git a/lib/libfdt/fdt_overlay.c b/lib/libfdt/fdt_overlay.c
new file mode 100644
index ..5835a90afafe
--- /dev/null
+++ b/lib/libfdt/fdt_overlay.c
@@ -0,0 +1,381 @@
+#include "libfdt_env.h"
+
+#include 
+#include 
+
+#include "libfdt_internal.h"
+
+static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
+{
+   const uint32_t *val;
+   int len;
+
+   val = fdt_getprop(fdto, fragment, "target", &len);
+   if (!val || (*val == 0x) || (len != sizeof(*val)))
+   return 0;
+
+   return fdt32_to_cpu(*val);
+}
+
+static int overlay_get_target(const void *fdt, const void *fdto,
+ int fragment)
+{
+   uint32_t phandle;
+   const char *path;
+
+   /* Try first to do a phandle based lookup */
+   phandle = overlay_get_target_phandle(fdto, fragment);
+   if (phandle)
+   return fdt_node_offset_by_phandle(fdt, phandle);
+
+   /* And then a path based lookup */
+   path = fdt_getprop(fdto, fragment, "target-path", NULL);
+   if (!path)
+   return -FDT_ERR_NOTFOUND;
+
+   return fdt_path_offset(fdt, path);
+}
+
+static int overlay_phandle_add_offset(void *fdt, int node,
+ const char *name, uint32_t delta)
+{
+   const uint32_t *val;
+   uint32_t adj_val;
+   int len;
+
+   val = fdt_getprop(fdt, node, name, &len);
+   if (!val)
+   return len;
+
+   if (len != sizeof(*val))
+   return -FDT_ERR_BADSTRUCTURE;
+
+   adj_val = fdt32_to_cpu(*val);
+   adj_val += delta;
+
+   return fdt_setprop_inplace_u32(fdt, node, name, adj_val);
+}
+
+static int overlay_adjust_node_phandles(void *fdto, int node,
+   uint32_t delta)
+{
+   bool found = false;
+   int child;
+   int ret;
+
+   ret = overlay_phandle_add_offset(fdto, node, "phandle", delta);
+   if (ret && ret != -FDT_ERR_NOTFOUND)
+   return ret;
+
+   if (!ret)
+   foun

[U-Boot] [PATCH v3 07/12] libfdt: Add fdt_setprop_inplace_by_index

2016-06-24 Thread Maxime Ripard
Add a function to modify inplace a property starting from a given index.

This is especially useful when the property is an array of values, and you
want to update one of them without changing the DT size.

Signed-off-by: Maxime Ripard 
---
 include/libfdt.h | 34 +++---
 lib/libfdt/fdt_wip.c | 13 -
 2 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/include/libfdt.h b/include/libfdt.h
index 4643be5adf39..2c8a42bcb667 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -1032,6 +1032,27 @@ int fdt_size_cells(const void *fdt, int nodeoffset);
 /* Write-in-place functions   */
 /**/
 
+/**
+ * fdt_setprop_inplace_namelen_by_index - change a property's value,
+ *but not its size
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @namelen: number of characters of name to consider
+ * @index: index of the property to change in the array
+ * @val: pointer to data to replace the property value with
+ * @len: length of the property value
+ *
+ * Identical to fdt_setprop_inplace(), but modifies the given property
+ * starting from the given index, and using only the first characters
+ * of the name. It is useful when you want to manipulate only one value of
+ * an array and you have a string that doesn't end with \0.
+ */
+int fdt_setprop_inplace_namelen_by_index(void *fdt, int nodeoffset,
+const char *name, int namelen,
+uint32_t index, const void *val,
+int len);
+
 /**
  * fdt_setprop_inplace - change a property's value, but not its size
  * @fdt: pointer to the device tree blob
@@ -1060,8 +1081,13 @@ int fdt_size_cells(const void *fdt, int nodeoffset);
  * -FDT_ERR_BADSTRUCTURE,
  * -FDT_ERR_TRUNCATED, standard meanings
  */
-int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
-   const void *val, int len);
+static inline int fdt_setprop_inplace(void *fdt, int nodeoffset,
+ const char *name, const void *val,
+ int len)
+{
+   return fdt_setprop_inplace_namelen_by_index(fdt, nodeoffset, name,
+   strlen(name), 0, val, len);
+}
 
 /**
  * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property
@@ -1095,7 +1121,9 @@ static inline int fdt_setprop_inplace_u32(void *fdt, int 
nodeoffset,
  const char *name, uint32_t val)
 {
fdt32_t tmp = cpu_to_fdt32(val);
-   return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+   return fdt_setprop_inplace_namelen_by_index(fdt, nodeoffset,
+   name, strlen(name),
+   0, &tmp, sizeof(tmp));
 }
 
 /**
diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c
index 9fe988655fe3..737769fa59e2 100644
--- a/lib/libfdt/fdt_wip.c
+++ b/lib/libfdt/fdt_wip.c
@@ -14,20 +14,23 @@
 
 #include "libfdt_internal.h"
 
-int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
-   const void *val, int len)
+int fdt_setprop_inplace_namelen_by_index(void *fdt, int nodeoffset,
+const char *name, int namelen,
+uint32_t index, const void *val,
+int len)
 {
void *propval;
int proplen;
 
-   propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen);
+   propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen,
+   &proplen);
if (!propval)
return proplen;
 
-   if (proplen != len)
+   if (proplen < (len + index))
return -FDT_ERR_NOSPACE;
 
-   memcpy(propval, val, len);
+   memcpy(propval + index, val, len);
return 0;
 }
 
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 02/12] scripts: Makefile.lib: Sanitize DTB names

2016-06-24 Thread Maxime Ripard
Having dashes as a separator in the DTB name is a quite common practice.

However, the current code to generate objects from DTBs assumes the
separator is an underscore, leading to a compilation error when building a
device tree with dashes.

Replace all the dashes in the DTB name to generate the symbols name, which
should solve this issue.

Acked-by: Simon Glass 
Acked-by: Pantelis Antoniou 
Signed-off-by: Maxime Ripard 
---
 scripts/Makefile.lib | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index e720562623c9..45a0e1d486c0 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -275,11 +275,11 @@ cmd_dt_S_dtb= 
\
 (  \
echo '.section .dtb.init.rodata,"a"';   \
echo '.balign 16';  \
-   echo '.global __dtb_$(*F)_begin';   \
-   echo '__dtb_$(*F)_begin:';  \
+   echo '.global __dtb_$(subst -,_,$(*F))_begin';  \
+   echo '__dtb_$(subst -,_,$(*F))_begin:'; \
echo '.incbin "$<" ';   \
-   echo '__dtb_$(*F)_end:';\
-   echo '.global __dtb_$(*F)_end'; \
+   echo '__dtb_$(subst -,_,$(*F))_end:';   \
+   echo '.global __dtb_$(subst -,_,$(*F))_end';\
echo '.balign 16';  \
 ) > $@
 
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 05/12] libfdt: Add iterator over properties

2016-06-24 Thread Maxime Ripard
Implement a macro based on fdt_first_property_offset and
fdt_next_property_offset that provides a convenience to iterate over all
the properties of a given node.

Signed-off-by: Maxime Ripard 
---
 include/libfdt.h | 24 
 1 file changed, 24 insertions(+)

diff --git a/include/libfdt.h b/include/libfdt.h
index 74b1d149c2dd..fbbe58ceb3f1 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -440,6 +440,30 @@ int fdt_first_property_offset(const void *fdt, int 
nodeoffset);
  */
 int fdt_next_property_offset(const void *fdt, int offset);
 
+/**
+ * fdt_for_each_property - iterate over all properties of a node
+ * @property_offset:   property offset (int)
+ * @fdt:   FDT blob (const void *)
+ * @node:  node offset (int)
+ *
+ * This is actually a wrapper around a for loop and would be used like so:
+ *
+ * fdt_for_each_property(fdt, node, property) {
+ * ...
+ * use property
+ * ...
+ * }
+ *
+ * Note that this is implemented as a macro and property is used as
+ * iterator in the loop. It should therefore be a locally allocated
+ * variable. The node variable on the other hand is never modified, so
+ * it can be constant or even a literal.
+ */
+#define fdt_for_each_property_offset(property, fdt, node)  \
+   for (property = fdt_first_property_offset(fdt, node);   \
+property >= 0; \
+property = fdt_next_property_offset(fdt, property))
+
 /**
  * fdt_get_property_by_offset - retrieve the property at a given offset
  * @fdt: pointer to the device tree blob
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 00/12] cmd: fdt: Add device tree overlays support

2016-06-24 Thread Maxime Ripard
Hi,

The device tree overlays are a great solution to the issue raised by
the bunch expandable boards we find everywhere these days, like the
Beaglebone, Raspberry Pi or CHIP.

However, most of the time, the overlays are applied through a
mechanism involving the firmware request interface in Linux, that is
only fully functional once the userspace has been mounted and is
running.

Some expansion boards might need to be enabled before that, because
they simply need to patch the DT early on, or need to be initialized
early in order to be fully functional, or because they provide access
to the root filesystem.

In these cases, having the bootloader applying the overlay before
Linux starts seems like the easiest solution.

This implementation doesn't provide all the Linux fancyness though,
there's no transactional application, which means that if the overlay
cannot be applied for a reason while you're still halfway through the
application, you're probably screwed. It also cannot remove an
overlay, but I don't think that it is currently a use-case.

There's still a bunch of work to extend the libfdt unit tests to test
the new functions introduced, but these patches will be submitted
in a near future.

Let me know what you think,
Maxime

Changes from v2:
  - Add Kconfig option for the libfdt overlay support
  - Reworked the code to deal with Pantelis and David numerous
comments, among which:
* Remove the need for malloc in the overlay code, and added some
  libfdt functions to do that
* Remove the DT magic in case of an error to not be able to use it
  anymore
* Removed the fdt_ and _ function prefix for the static functions
* Plus the usual bunch of rework, error checking and optimizations.

  - Added new tests to deal with bugs reported by David (the overlay
was not applying when you add a subnode declared that was already
in the base device tree, and using a local phandle was only
working if the property storing it only had a length of 4).

Changes from v1:
  - Moved the overlay code to libfdt
  - Added unit tests
  - Refactored the code to reduce the amount of memory allocation
  - No longer modify the overlay itself, but create a copy to operate
on instead.
  - Removed the limitations on the fixups path, names and properties
length
  - Fixed a few things here and there according to comments 

Maxime Ripard (12):
  cmd: fdt: Narrow the check for fdt addr
  scripts: Makefile.lib: Sanitize DTB names
  vsprintf: Include stdarg for va_list
  libfdt: Add new headers and defines
  libfdt: Add iterator over properties
  libfdt: Add max phandle retrieval function
  libfdt: Add fdt_setprop_inplace_by_index
  libfdt: Add fdt_path_offset_namelen
  libfdt: Add fdt_getprop_namelen_w
  libfdt: Add overlay application function
  cmd: fdt: add fdt overlay application subcommand
  tests: Introduce DT overlay tests

 Makefile  |   1 +
 cmd/fdt.c |  26 ++-
 include/libfdt.h  | 124 -
 include/libfdt_env.h  |   6 +
 include/test/overlay.h|  16 ++
 include/test/suites.h |   1 +
 include/vsprintf.h|   2 +
 lib/Kconfig   |   5 +
 lib/libfdt/Makefile   |   2 +
 lib/libfdt/fdt_overlay.c  | 381 ++
 lib/libfdt/fdt_ro.c   |  44 -
 lib/libfdt/fdt_wip.c  |  13 +-
 scripts/Makefile.lib  |   8 +-
 test/Kconfig  |   1 +
 test/cmd_ut.c |   6 +
 test/overlay/Kconfig  |  11 ++
 test/overlay/Makefile |  15 ++
 test/overlay/cmd_ut_overlay.c | 243 
 test/overlay/test-fdt-base.dts|  21 +++
 test/overlay/test-fdt-overlay.dts |  88 +
 20 files changed, 992 insertions(+), 22 deletions(-)
 create mode 100644 include/test/overlay.h
 create mode 100644 lib/libfdt/fdt_overlay.c
 create mode 100644 test/overlay/Kconfig
 create mode 100644 test/overlay/Makefile
 create mode 100644 test/overlay/cmd_ut_overlay.c
 create mode 100644 test/overlay/test-fdt-base.dts
 create mode 100644 test/overlay/test-fdt-overlay.dts

-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 01/12] cmd: fdt: Narrow the check for fdt addr

2016-06-24 Thread Maxime Ripard
The current code only checks if the fdt subcommand is fdt addr by checking
whether it starts with 'a'.

Since this is a pretty widely used letter, narrow down that check a bit.

Acked-by: Simon Glass 
Acked-by: Pantelis Antoniou 
Signed-off-by: Maxime Ripard 
---
 cmd/fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 898217ffe5f8..0f5923e75a41 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -87,7 +87,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
/*
 * Set the address of the fdt
 */
-   if (argv[1][0] == 'a') {
+   if (strncmp(argv[1], "ad", 2) == 0) {
unsigned long addr;
int control = 0;
struct fdt_header *blob;
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 04/12] libfdt: Add new headers and defines

2016-06-24 Thread Maxime Ripard
The libfdt overlay support introduces a bunch of new includes and
functions.

Make sure we are able to build it by adding the needed glue.

Signed-off-by: Maxime Ripard 
---
 include/libfdt_env.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/libfdt_env.h b/include/libfdt_env.h
index 273b5d30f867..6c6845f76cf7 100644
--- a/include/libfdt_env.h
+++ b/include/libfdt_env.h
@@ -23,6 +23,12 @@ typedef __be64 fdt64_t;
 #define fdt64_to_cpu(x)be64_to_cpu(x)
 #define cpu_to_fdt64(x)cpu_to_be64(x)
 
+#ifdef __UBOOT__
+#include 
+
+#define strtoul(cp, endp, base)simple_strtoul(cp, endp, base)
+#endif
+
 /* adding a ramdisk needs 0x44 bytes in version 2008.10 */
 #define FDT_RAMDISK_OVERHEAD   0x80
 
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 03/12] vsprintf: Include stdarg for va_list

2016-06-24 Thread Maxime Ripard
vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass 
Acked-by: Pantelis Antoniou 
Signed-off-by: Maxime Ripard 
---
 include/vsprintf.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/vsprintf.h b/include/vsprintf.h
index 376f5dd32499..60e91d119eee 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -8,6 +8,8 @@
 #ifndef __VSPRINTF_H
 #define __VSPRINTF_H
 
+#include 
+
 ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
 
 /**
-- 
2.9.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] error: sdhci_send_command: Timeout for status update!

2016-06-24 Thread Masahiro Yamada
2016-06-24 7:06 GMT+09:00 Steve Rae :
> Stefan,
>
> I am asking you about this code, because of this:
>   commit 29905a4 - mmc: sdhci: Use timer based timeout detection in
> sdhci_send_command()
>
> Occasionally, I am seeing failures when writing to flash on my device:
>
>   Flashing sparse image at offset 2078720
>   Flashing Sparse Image
>   sdhci_send_command: Timeout for status update!
>   mmc fail to send stop cmd
>   write_sparse_image: Write failed, block #2181088 [0]
>
> I can eliminate this error if I kludge the following code:
>
> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
> index 5c71ab8..854f7ce 100644
> --- a/drivers/mmc/sdhci.c
> +++ b/drivers/mmc/sdhci.c
> @@ -243,9 +243,9 @@ static int sdhci_send_command(struct mmc *mmc,
> struct mmc_cmd *cmd,
> if (stat & SDHCI_INT_ERROR)
> break;
> } while (((stat & mask) != mask) &&
> -(get_timer(start) < CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT));
> +(get_timer(start) < 600 
> /*CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT*/));
>
> -   if (get_timer(start) >= CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT) {
> +   if (get_timer(start) >= 600 /*CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT*/) {
> if (host->quirks & SDHCI_QUIRK_BROKEN_R1B)
> return 0;
> else {
>
> I don't know much about this - I arrived at 600 by trial and error
> (500 fails...)
> Any ideas?
>
>

Hi Steve,

You are not alone.

I am also suffering this too short timeout value.

I sent this patch about two months ago.
http://patchwork.ozlabs.org/patch/615994/

But, nothing happened.




-- 
Best Regards
Masahiro Yamada
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] sunxi: Add defconfig and DTS file for Allwinner R16 EVB (Parrot)

2016-06-24 Thread Quentin Schulz
The Parrot Board is an evaluation board with an Allwinner R16 (assumed
to be close to an Allwinner A33), 4GB of eMMC, 512MB of RAM, USB host
and OTG, a WiFi/Bluetooth combo chip, a micro SD Card reader, 2
controllable buttons, an LVDS port with separated backlight and
capacitive touch panel ports, an audio/microphone jack, a camera CSI
port, 2 sets of 22 GPIOs and an accelerometer.

The DTS file is identical to the one submitted to the upstream kernel.

Signed-off-by: Quentin Schulz 
---
 arch/arm/dts/Makefile |   3 +-
 arch/arm/dts/sun8i-r16-parrot.dts | 348 ++
 board/sunxi/MAINTAINERS   |   5 +
 configs/parrot_r16_defconfig  |  38 +
 4 files changed, 393 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/sun8i-r16-parrot.dts
 create mode 100644 configs/parrot_r16_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index de75e24..db1824a 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -230,7 +230,8 @@ dtb-$(CONFIG_MACH_SUN8I_A23) += \
 dtb-$(CONFIG_MACH_SUN8I_A33) += \
sun8i-a33-ga10h-v1.1.dtb \
sun8i-a33-q8-tablet.dtb \
-   sun8i-a33-sinlinx-sina33.dtb
+   sun8i-a33-sinlinx-sina33.dtb \
+   sun8i-r16-parrot.dtb
 dtb-$(CONFIG_MACH_SUN8I_A83T) += \
sun8i-a83t-allwinner-h8homlet-v2.dtb \
sun8i-a83t-cubietruck-plus.dtb \
diff --git a/arch/arm/dts/sun8i-r16-parrot.dts 
b/arch/arm/dts/sun8i-r16-parrot.dts
new file mode 100644
index 000..39c40be
--- /dev/null
+++ b/arch/arm/dts/sun8i-r16-parrot.dts
@@ -0,0 +1,348 @@
+/*
+ * Copyright 2016 Quentin Schulz
+ *
+ * Quentin Schulz 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+#include "sun8i-a33.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+#include 
+#include 
+
+/ {
+   model = "Allwinner R16 EVB (Parrot)";
+   compatible = "allwinner,parrot", "allwinner,sun8i-a33";
+
+   aliases {
+   serial0 = &uart0;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 = <&led_pins_parrot>;
+
+   led1 {
+   label = "parrot:led1:usr";
+   gpio = <&pio 4 17 GPIO_ACTIVE_HIGH>; /* PE17 */
+   };
+
+   led2 {
+   label = "parrot:led2:usr";
+   gpio = <&pio 4 16 GPIO_ACTIVE_HIGH>; /* PE16 */
+   };
+   };
+
+   wifi_pwrseq: wifi_pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&r_pio 0 6 GPIO_ACTIVE_LOW>; /* PL06 */
+   };
+
+};
+
+&ehci0 {
+   status = "okay";
+};
+
+&i2c1 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c1_pins_a>;
+   status = "okay";
+
+   /* FIXME: An as-yet-unknown accelerometer is connected to this i2c bus. 
*/
+};
+
+&lradc {
+   vref-supply = <®_aldo3>;
+   status = "okay";
+
+   button@0 {
+

[U-Boot] U-Boot SPL/Falcon mode Support on Minnowboard Max

2016-06-24 Thread vinoth eswaran
Hello,

I have gone through the document in U-boot Readme.falcon in which it
explains we can skip loading the u-boot and load the Linux kernel directly.
This will save time for systems that looks to optimize the start up time.

In the document its mentioned that the "spl_start_uboot()" - as the
required function to be implemented as board specific to support this
functionality.

I have checked the code and found no such function is defined for x86. Does
that mean that Falcon mode is not supported in x86 arhitectures??


Mit Freundlichen Grüßen
VinothKumar
+49 1798909072
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] uImage load address and entry point with Minnowboard

2016-06-24 Thread Robert P. J. Day
On Fri, 24 Jun 2016, Wolfgang Denk wrote:

> Dear Vinoth,
>
> In message 
>  you 
> wrote:
> >
> > I am using the following command to create uImage. Here in the architecture
> > argument I am not seeing any option corresponding to the Intel-x86_64. So I
> > had used x86, which I am not sure is valid or not. The kernel is 64 bit.
> >
> > mkimage -A x86 -O linux -T kernel -C none -a 0x10 -e 0x0 -n Linux
> > -d vmlinux-4.4.6-ina uImage
> > Image Name:   Linux
> > Created:  Fri Jun 24 10:35:40 2016
> > Image Type:   Intel x86 Linux Kernel Image (uncompressed)
> > Data Size:21966248 Bytes = 21451.41 kB = 20.95 MB
> > Load Address: 0010
> > Entry Point:  
>
> This makes no sense to me.  When the kernel image is loaded to RAM
> starting at address 0x0010, then ther eis no valid code at address
> 0x.  So 0x cannot be a valid entry oint address.  The
> entry point address must be somewhare in the range between "load
> address" and "load address + size of uncompressed kernel image".
>
> > Error: Invalid Boot Flag (found 0x, expected 0xaa55)
> > Setup at 0x00
> > Magic signature not found
> >
> > Is is I need to load setup.bin also?

  i'm sure i'm not adding much to this discussion, but 0xaa55 is the
last two bytes of an MBR that identifies that 512-byte block as a
legitimate master boot record, so *something* is looking for an MBR
and not finding it.

rday

-- 


Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca

Twitter:   http://twitter.com/rpjday
LinkedIn:   http://ca.linkedin.com/in/rpjday


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] uImage load address and entry point with Minnowboard

2016-06-24 Thread Wolfgang Denk
Dear Vinoth,

In message  
you wrote:
> 
> I am using the following command to create uImage. Here in the architecture
> argument I am not seeing any option corresponding to the Intel-x86_64. So I
> had used x86, which I am not sure is valid or not. The kernel is 64 bit.
> 
> mkimage -A x86 -O linux -T kernel -C none -a 0x10 -e 0x0 -n Linux
> -d vmlinux-4.4.6-ina uImage
> Image Name:   Linux
> Created:  Fri Jun 24 10:35:40 2016
> Image Type:   Intel x86 Linux Kernel Image (uncompressed)
> Data Size:21966248 Bytes = 21451.41 kB = 20.95 MB
> Load Address: 0010
> Entry Point:  

This makes no sense to me.  When the kernel image is loaded to RAM
starting at address 0x0010, then ther eis no valid code at address
0x.  So 0x cannot be a valid entry oint address.  The
entry point address must be somewhare in the range between "load
address" and "load address + size of uncompressed kernel image".

> Error: Invalid Boot Flag (found 0x, expected 0xaa55)
> Setup at 0x00
> Magic signature not found
> 
> Is is I need to load setup.bin also?

I have no idea.  I didn't know that you were asking for x86...  I'm
not an expert in this area.  I added Simon and Bin to cc: who might be
in a much better position to answer such a question.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
To be is to program.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] uImage load address and entry point with Minnowboard

2016-06-24 Thread vinoth eswaran
Dear Mr.Wolfgang Denk,

Your reply had helped me a lot in figuring out the solution, but I run into
another issue.

I had identified the kernel file where load address is defined:
kexec-bzimage64.c:#define MIN_KERNEL_LOAD_ADDR0x10

I am using the following command to create uImage. Here in the architecture
argument I am not seeing any option corresponding to the Intel-x86_64. So I
had used x86, which I am not sure is valid or not. The kernel is 64 bit.

mkimage -A x86 -O linux -T kernel -C none -a 0x10 -e 0x0 -n Linux
-d vmlinux-4.4.6-ina uImage
Image Name:   Linux
Created:  Fri Jun 24 10:35:40 2016
Image Type:   Intel x86 Linux Kernel Image (uncompressed)
Data Size:21966248 Bytes = 21451.41 kB = 20.95 MB
Load Address: 0010
Entry Point:  

The bootcmd is "bootcmd fatload mmc 1:1 0200 uImage \; bootm 0200".
Now after copying the kernel to RAM I am seeing the following error
messages:

Error: Invalid Boot Flag (found 0x, expected 0xaa55)
Setup at 0x00
Magic signature not found

Is is I need to load setup.bin also?

After Starting Kernel I am seeing the following message:

Invalid Opcode (Undefined Opcode)
EIP: 0010:[<0058>] EFLAGS: 00010006
Original EIP :[<849a4058>]
EAX: 05050616 EBX:  ECX:  EDX: 
ESI:  EDI:  EBP:  ESP: 7b348150
 DS: 0018 ES: 0018 FS: 0020 GS: 0018 SS: 0018
CR0: 0033 CR2:  CR3:  CR4: 0600
DR0:  DR1:  DR2:  DR3: 
DR6: 0ff0 DR7: 0400
Stack:
0x7b348190 : 0x9000
0x7b34818c : 0x7b5cf088
0x7b348188 : 0x0007
0x7b348184 : 0x7b5ae4e8
0x7b348180 : 0x0001
0x7b34817c : 0x
0x7b348178 : 0x7b3481bc
0x7b348174 : 0x0001
0x7b348170 : 0xcb6e3ac1
0x7b34816c : 0x7b55f663
0x7b348168 : 0x7b36035c
0x7b348164 : 0x
0x7b348160 : 0x0400
0x7b34815c : 0x7b5cf088
0x7b348158 : 0x
0x7b348154 : 0x
--->0x7b348150 : 0x9000
0x7b34814c : 0x00010006
0x7b348148 : 0x0010
0x7b348144 : 0x0058
### ERROR ### Please RESET the board ###

I didn't understand what#s happening here? Do I need to load the *.dtb file
also or this will be done internally by the u-boot.

Thanks & Regards,
Vinothkumar

On Thu, Jun 23, 2016 at 8:21 PM, Wolfgang Denk  wrote:

> Dear Vinoth,
>
> In message  bka8eswmtg-hgz8opc+i1h0bjwc0_c1uc...@mail.gmail.com> you wrote:
> >
> > 1) What's the address in the bootcmd corresponds to , I think it is
>
> Define "bootcmd" - this can be anything.
>
> > the address where we want the u-boot to load the Linux kernel image
> > into RAM
> >
> > For ex: fatload mmc 0:1 0100 bzImage; zboot 0100
>
> This does not apply to your previous question.  We were talking about
> the address entries in uImage files - but there you use a bzImage
> which does not include the uImage header, and so it doesn not have any
> "load address" or "entry point address" settings stored in the image.
> Here you need to know these yourself.
>
> > Here 0100 is the address and bzImage is the compressed Linux
> > kernel stored in mmc0 partition1. Once the Kernel is copied to RAM we
> > are using zboot command to start the kernel, so after it Kernel
> > unpacks itself and starts running
>
> Correct - but this is a totally different scenario.
>
> Note also that th enotation of "kernel unpacks itself" is dependent on
> the image type and to some parts on the architecture.
>
> > 2) I want to use uncompressed Kernel(vmlinux) instead of bzImage.
> > U-boot directly doesn't support running vmlinux, so I need to generate
> > the uImage using the mkImage tool. So the payload in my case in
> > uncompressed kernel.  To generate this I want two addresses , load
> > address and entry point address. You have mentioned that the addresses
> > are often fixed. How can I get these addresses?
>
> They are defined in the kerel build process; check Linux Makefiles,
> and/or study the linker commands used when linking the kernel image.
>
> > I am using the same address in bootcmd: fatload mmc 0:1 0100
> > uImage; bootm 0100
>
> In this case 0x0100 is what I usually call the "download address",
> i. e. the location where the uImage is stored in memory.  This has
> nothing to do with the load address or entry pint address (except that
> you will likely run into trouble if these should be the same or close
> to it).
>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
> You get a wonderful view from the point of no return.
> - Terry Pratchett, _Making_Money_
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH V2 1/3] mmc: fsl: reset to normal boot mode when eMMC fast boot

2016-06-24 Thread Peng Fan
Hi York, Stefano

Any comments on this patch set? Would you kindly pick up this patch set?

Thanks,
Peng.
On Wed, Jun 15, 2016 at 10:53:00AM +0800, Peng Fan wrote:
>When booting in eMMC fast boot, MMC host does not exit from
>boot mode after bootrom loading image. So the first command
>'CMD0' sent in uboot will pull down the CMD line to low and
>cause errors.
>
>This patch cleans the MMC boot register in "mmc_init" to put the
>MMC host back to normal mode.
>
>Also clear DLL_CTRL delay line settings at USDHC initialization
>to eliminate the pre-settings from boot rom.
>
>Signed-off-by: Peng Fan 
>Cc: Pantelis Antoniou 
>Cc: York Sun 
>Cc: Stefano Babic 
>Cc: Fabio Estevam 
>---
>
>V2:
> Rebased to lastest u-boot master
>
> drivers/mmc/fsl_esdhc.c | 38 +-
> include/fsl_esdhc.h |  6 ++
> 2 files changed, 35 insertions(+), 9 deletions(-)
>
>diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
>index 57ad975..9cd582f 100644
>--- a/drivers/mmc/fsl_esdhc.c
>+++ b/drivers/mmc/fsl_esdhc.c
>@@ -56,21 +56,27 @@ struct fsl_esdhc {
>   uintfevt;   /* Force event register */
>   uintadmaes; /* ADMA error status register */
>   uintadsaddr;/* ADMA system address register */
>-  charreserved2[100]; /* reserved */
>-  uintvendorspec; /* Vendor Specific register */
>-  charreserved3[56];  /* reserved */
>+  charreserved2[4];
>+  uintdllctrl;
>+  uintdllstat;
>+  uintclktunectrlstatus;
>+  charreserved3[84];
>+  uintvendorspec;
>+  uintmmcboot;
>+  uintvendorspec2;
>+  charreserved4[48];
>   uinthostver;/* Host controller version register */
>-  charreserved4[4];   /* reserved */
>-  uintdmaerraddr; /* DMA error address register */
>   charreserved5[4];   /* reserved */
>-  uintdmaerrattr; /* DMA error attribute register */
>+  uintdmaerraddr; /* DMA error address register */
>   charreserved6[4];   /* reserved */
>+  uintdmaerrattr; /* DMA error attribute register */
>+  charreserved7[4];   /* reserved */
>   uinthostcapblt2;/* Host controller capabilities register 2 */
>-  charreserved7[8];   /* reserved */
>+  charreserved8[8];   /* reserved */
>   uinttcr;/* Tuning control register */
>-  charreserved8[28];  /* reserved */
>+  charreserved9[28];  /* reserved */
>   uintsddirctl;   /* SD direction control register */
>-  charreserved9[712]; /* reserved */
>+  charreserved10[712];/* reserved */
>   uintscr;/* eSDHC control register */
> };
> 
>@@ -616,6 +622,20 @@ static int esdhc_init(struct mmc *mmc)
>   while ((esdhc_read32(®s->sysctl) & SYSCTL_RSTA) && --timeout)
>   udelay(1000);
> 
>+#if defined(CONFIG_FSL_USDHC)
>+  /* RSTA doesn't reset MMC_BOOT register, so manually reset it */
>+  esdhc_write32(®s->mmcboot, 0x0);
>+  /* Reset MIX_CTRL and CLK_TUNE_CTRL_STATUS regs to 0 */
>+  esdhc_write32(®s->mixctrl, 0x0);
>+  esdhc_write32(®s->clktunectrlstatus, 0x0);
>+
>+  /* Put VEND_SPEC to default value */
>+  esdhc_write32(®s->vendorspec, VENDORSPEC_INIT);
>+
>+  /* Disable DLL_CTRL delay line */
>+  esdhc_write32(®s->dllctrl, 0x0);
>+#endif
>+
> #ifndef ARCH_MXC
>   /* Enable cache snooping */
>   esdhc_write32(®s->scr, 0x0040);
>diff --git a/include/fsl_esdhc.h b/include/fsl_esdhc.h
>index fa760a5..78c67c8 100644
>--- a/include/fsl_esdhc.h
>+++ b/include/fsl_esdhc.h
>@@ -35,6 +35,12 @@
> #define SYSCTL_RSTC   0x0200
> #define SYSCTL_RSTD   0x0400
> 
>+#define VENDORSPEC_CKEN   0x4000
>+#define VENDORSPEC_PEREN  0x2000
>+#define VENDORSPEC_HCKEN  0x1000
>+#define VENDORSPEC_IPGEN  0x0800
>+#define VENDORSPEC_INIT   0x20007809
>+
> #define IRQSTAT   0x0002e030
> #define IRQSTAT_DMAE  (0x1000)
> #define IRQSTAT_AC12E (0x0100)
>-- 
>2.6.2
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH v1 6/6] dfu: spl: am335x: SPL-DFU support for am335x

2016-06-24 Thread B, Ravi
Hi Lukasz

>>  
>>  config SPL_DFU
>>  bool "Enable SPL with DFU to load binaries to bootdevices using USB"
>> -depends on USB && CMD_DFU && TARGET_DRA7XX_EVM
>> +depends on USB && CMD_DFU && (TARGET_DRA7XX_EVM ||

>Here also please remove not needed dependencies (CMD_DFU).

Ok. Will remove it.

>> TARGET_AM335X_EVM) help
>>Currently the SPL does not have capability to load the
>>binaries or boot images to boot devices like eMMC,SPI,etc.
>> diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index 

Regards
Ravi 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH v1 4/6] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform

2016-06-24 Thread B, Ravi
Hi Lukasz

>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  
>>  #include "mux_data.h"
>>  #include "../common/board_detect.h"
>> @@ -706,6 +707,22 @@ int spl_start_uboot(void)  }  #endif
>>  
>> +#ifdef CONFIG_SPL_DFU
>> +int spl_run_dfu(void)

>We can replace int with bool here.

Ok, make sense.

>> +{
>> +int os_boot = 0;
>> +#ifdef CONFIG_SPL_DFU_SF
>> +spl_dfu_cmd(0, "dfu_alt_info_qspi", "sf", "0:0:6400:0");
   ^^^
   could you add some
   description to this
   magic value (as e.g.
   comment) or replace
   it with some #define?

Ok, I can use default CONFIG_XX use for SPI and make string to pass.

Regards
Ravi 

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH v1 5/6] dfu: spl: dra7x: enable SPL-dfu support for dra7x platform

2016-06-24 Thread B, Ravi
Hi Lukasz

>>  /* USB Device Firmware Update support */  #define 
>> CONFIG_USB_FUNCTION_DFU  #define CONFIG_DFU_RAM
>> -
>> -#define CONFIG_DFU_MMC
>> -#define CONFIG_DFU_RAM

>Please correct me if I am wrong, but from this patch it seems like you disable 
>MMC and RAM DFU support in the fully-fledge u-boot on your dra7xx board. Is 
>this intentional?

Actually, for SPL-DFU, I want to enable DFU_RAM in order to reduce the foot 
print. Then the user must rebuild full fledge u-boot without SPL-DFU and load 
to RAM.

>  #define CONFIG_DFU_SF
> +#ifndef CONFIG_SPL_DFU
> +#define CONFIG_DFU_MMC
> +#endif

Here I have included DFU_MMC if SPL_DFU (from menuconfig) is not defined.

Regards
Ravi 
  


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH v1 6/6] dfu: spl: am335x: SPL-DFU support for am335x

2016-06-24 Thread Lukasz Majewski
Hi Ravi,

> enable the SPL-DFU support for am335x platform.
> 
> Signed-off-by: Ravi Babu 
> ---
>  Kconfig  |2 +-
>  board/ti/am335x/board.c  |   15 +++
>  common/spl/spl_dfu.c |1 +
>  include/configs/am335x_evm.h |   17 -
>  4 files changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/Kconfig b/Kconfig
> index 969641e..c4eb4bd 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -287,7 +287,7 @@ config SPL_LOAD_FIT
>  
>  config SPL_DFU
>   bool "Enable SPL with DFU to load binaries to bootdevices
> using USB"
> - depends on USB && CMD_DFU && TARGET_DRA7XX_EVM
> + depends on USB && CMD_DFU && (TARGET_DRA7XX_EVM ||

Here also please remove not needed dependencies (CMD_DFU).

> TARGET_AM335X_EVM) help
> Currently the SPL does not have capability to load the
> binaries or boot images to boot devices like eMMC,SPI,etc.
> diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
> index 690c298..fe56004 100644
> --- a/board/ti/am335x/board.c
> +++ b/board/ti/am335x/board.c
> @@ -246,6 +246,21 @@ const struct dpll_params dpll_ddr_evm_sk = {
>  const struct dpll_params dpll_ddr_bone_black = {
>   400, OSC-1, 1, -1, -1, -1, -1};
>  
> +#ifdef CONFIG_SPL_DFU
> +int spl_run_dfu(void)
> +{
> + int os_boot = 0;
> +#ifdef CONFIG_SPL_DFU_SF
> + spl_dfu_cmd(0, "dfu_alt_info_qspi", "sf", "0:0:2400:0");
   ^^^
the same comment as in
the previous patch.
Please replace this
magic value to
something more
descriptive.
> +#endif
> +#ifdef CONFIG_SPL_DFU_RAM
> + spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
> + spl_dfu_ram_load_image();
> + os_boot = 1;
> +#endif
> + return os_boot;
> +}
> +#endif
>  void am33xx_spl_board_init(void)
>  {
>   int mpu_vdd;
> diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
> index 8b8432b..f2badb6 100644
> --- a/common/spl/spl_dfu.c
> +++ b/common/spl/spl_dfu.c
> @@ -143,6 +143,7 @@ int spl_dfu_ram_load_image(void)
>   struct spl_load_info load;
>   debug("Found FIT\n");
>   load.priv = NULL;
> + load.bl_len = 1;
>   load.read = spl_fit_ram_read;
>  
>   err = spl_load_simple_fit(&load, (ulong)filename,
> header); diff --git a/include/configs/am335x_evm.h
> b/include/configs/am335x_evm.h index 1139526..558be7b 100644
> --- a/include/configs/am335x_evm.h
> +++ b/include/configs/am335x_evm.h
> @@ -187,6 +187,9 @@
>   NETARGS \
>   DFUARGS \
>   BOOTENV
> +#else
> +#define CONFIG_EXTRA_ENV_SETTINGS \
> + DFUARGS
>  #endif
>  
>  /* NS16550 Configuration */
> @@ -297,12 +300,14 @@
>  #define CONFIG_AM335X_USB1_MODE MUSB_HOST
>  
>  #ifndef CONFIG_SPL_USBETH_SUPPORT
> +#ifndef CONFIG_SPL_DFU
>  /* Fastboot */
>  #define CONFIG_USB_FUNCTION_FASTBOOT
>  #define CONFIG_CMD_FASTBOOT
>  #define CONFIG_ANDROID_BOOT_IMAGE
>  #define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR
>  #define CONFIG_FASTBOOT_BUF_SIZE 0x0700
> +#endif
>  
>  /* To support eMMC booting */
>  #define CONFIG_STORAGE_EMMC
> @@ -314,9 +319,11 @@
>  #endif
>  
>  #ifdef CONFIG_USB_MUSB_GADGET
> +#ifndef CONFIG_SPL_DFU
>  #define CONFIG_USB_ETHER
>  #define CONFIG_USB_ETH_RNDIS
>  #define CONFIG_USBNET_HOST_ADDR  "de:ad:be:af:00:00"
> +#endif
>  #endif /* CONFIG_USB_MUSB_GADGET */
>  
>  /*
> @@ -348,9 +355,9 @@
>  #endif
>  
>  /* USB Device Firmware Update support */
> -#ifndef CONFIG_SPL_BUILD
>  #define CONFIG_USB_FUNCTION_DFU
>  #define CONFIG_DFU_MMC
> +#define CONFIG_DFU_RAM
>  #define DFU_ALT_INFO_MMC \
>   "dfu_alt_info_mmc=" \
>   "boot part 0 1;" \
> @@ -364,6 +371,7 @@
>   "spl-os-image fat 0 1;" \
>   "u-boot.img fat 0 1;" \
>   "uEnv.txt fat 0 1\0"
> +#ifndef CONFIG_SPL_DFU
>  #ifdef CONFIG_NAND
>  #define CONFIG_DFU_NAND
>  #define DFU_ALT_INFO_NAND \
> @@ -379,17 +387,24 @@
>  #else
>  #define DFU_ALT_INFO_NAND ""
>  #endif
> +#endif
>  #define CONFIG_DFU_RAM
>  #define DFU_ALT_INFO_RAM \
>   "dfu_alt_info_ram=" \
>   "kernel ram 0x8020 0xD8;" \
>   "fdt ram 0x80F8 0x8;" \
>   "ramdisk ram 0x8100 0x400\0"
> +#ifndef CONFIG_SPL_DFU
>  #define DFUARGS \
>   "dfu_alt_info_emmc=rawemmc raw 0 3751936\0" \
>   DFU_ALT_INFO_MMC \
>   DFU_ALT_INFO_RAM \
>   DFU_ALT_INFO_NAND
> +#else
> +#define DFUARGS \
> + "dfu_alt_info_emmc=rawemmc raw 0 3751936\0" \
> + DFU_ALT_INFO_MMC \
> + DFU_ALT_INFO_RAM
>  #endif
>  
>  /*



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
___

Re: [U-Boot] [RFC PATCH v1 5/6] dfu: spl: dra7x: enable SPL-dfu support for dra7x platform

2016-06-24 Thread Lukasz Majewski
Hi Ravi,

> Enable the SPL-DFU support for dra7x platform.
> 
> Signed-off-by: Ravi Babu 
> ---
>  include/configs/dra7xx_evm.h  |8 
>  include/configs/ti_omap5_common.h |2 --
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/include/configs/dra7xx_evm.h
> b/include/configs/dra7xx_evm.h index e7fb469..686f5d4 100644
> --- a/include/configs/dra7xx_evm.h
> +++ b/include/configs/dra7xx_evm.h
> @@ -44,7 +44,6 @@
>  
>  #define CONFIG_SYS_OMAP_ABE_SYSCK
>  
> -#ifndef CONFIG_SPL_BUILD
>  /* Define the default GPT table for eMMC */
>  #define PARTS_DEFAULT \
>   /* Linux partitions */ \
> @@ -119,6 +118,7 @@
>   DFU_ALT_INFO_QSPI
>  
>  /* Fastboot */
> +#ifndef CONFIG_SPL_BUILD
>  #define CONFIG_USB_FUNCTION_FASTBOOT
>  #define CONFIG_CMD_FASTBOOT
>  #define CONFIG_ANDROID_BOOT_IMAGE
> @@ -216,10 +216,10 @@
>  /* USB Device Firmware Update support */
>  #define CONFIG_USB_FUNCTION_DFU
>  #define CONFIG_DFU_RAM
> -
> -#define CONFIG_DFU_MMC
> -#define CONFIG_DFU_RAM

Please correct me if I am wrong, but from this patch it seems like you
disable MMC and RAM DFU support in the fully-fledge u-boot on your
dra7xx board. Is this intentional?

>  #define CONFIG_DFU_SF
> +#ifndef CONFIG_SPL_DFU
> +#define CONFIG_DFU_MMC
> +#endif
>  
>  /* SATA */
>  #define CONFIG_BOARD_LATE_INIT
> diff --git a/include/configs/ti_omap5_common.h
> b/include/configs/ti_omap5_common.h index 59f0f70..f9c6576 100644
> --- a/include/configs/ti_omap5_common.h
> +++ b/include/configs/ti_omap5_common.h
> @@ -66,7 +66,6 @@
>  #define DFUARGS
>  #endif
>  
> -#ifndef CONFIG_SPL_BUILD
>  #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
>  #define CONFIG_EXTRA_ENV_SETTINGS \
>   DEFAULT_LINUX_BOOT_ENV \
> @@ -136,7 +135,6 @@
>   "setenv mmcroot /dev/mmcblk0p2 rw; " \
>   "run mmcboot;" \
>   ""
> -#endif
>  
>  /*
>   * SPL related defines.  The Public RAM memory map the ROM defines
> the



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH v1 4/6] dra7x: spl: dfu: adding SPL-DFU support for dra7x platform

2016-06-24 Thread Lukasz Majewski
Hi Ravi,

> Adding SPL-DFU support for dra7x platform. The DFU
> support for dra7x includes QSPI, MMC/SD and eMMC
> memory devices. The SPL-DFU memory devices can be
> selected through meunconfig->Boot Images.
> ---
>  board/ti/dra7xx/evm.c |   17 +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
> index c5f7190..bd1f5be 100644
> --- a/board/ti/dra7xx/evm.c
> +++ b/board/ti/dra7xx/evm.c
> @@ -29,6 +29,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "mux_data.h"
>  #include "../common/board_detect.h"
> @@ -706,6 +707,22 @@ int spl_start_uboot(void)
>  }
>  #endif
>  
> +#ifdef CONFIG_SPL_DFU
> +int spl_run_dfu(void)

We can replace int with bool here.

> +{
> + int os_boot = 0;
> +#ifdef CONFIG_SPL_DFU_SF
> + spl_dfu_cmd(0, "dfu_alt_info_qspi", "sf", "0:0:6400:0");
   ^^^
   could you add some
   description to this
   magic value (as e.g.
   comment) or replace
   it with some #define?
> +#endif
> +#ifdef CONFIG_SPL_DFU_RAM
> + spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
> + spl_dfu_ram_load_image();
> + os_boot = 1;
> +#endif
> + return os_boot;
> +}
> +#endif
> +
>  #ifdef CONFIG_DRIVER_TI_CPSW
>  extern u32 *const omap_si_rev;
>  



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH v1 2/6] spl: dfu: adding dfu support functions for SPL-DFU

2016-06-24 Thread B, Ravi
> > diff --git a/include/spl.h b/include/spl.h index af02a6d..8849678 
> > 100644
> > --- a/include/spl.h
> > +++ b/include/spl.h
> > @@ -139,4 +139,14 @@ void spl_board_init(void);
> >   */
> >  bool spl_was_boot_source(void);
> >  
> > +/* spl dfu functions */
> > +/* spl_dfu_mmc - run dfu command with chosen mmc device interface
> > + * @param usb_index - usb controller number
> > + * @param mmc_dev -  mmc device nubmer
> > + *
> > + * @return 0 on success, otherwise error code  */ int spl_dfu_mmc(int 
> > +usb_index, int mmc_dev, char *dfu_alt_info); int spl_dfu_cmd(int 
> > +usbctrl, char *dfu_alt_info, char *interface,
> > char *devstr); +int spl_dfu_ram_load_image(void);

> I think that it would be nice to have doxygen like (/**
/*
.. )
> Function description comments for each function.

> In this way we would have high quality comments in the code.

Ok, sure.

Regards
Ravi


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH v1 3/6] dfu: spl: add generic spl-dfu function in common-spl

2016-06-24 Thread Lukasz Majewski
Hi Ravi,

> Add generic spl-dfu function in common-spl, specific
> implemention for configuring dfu memory device is
> done in platform board specific source file.
> 
> Signed-off-by: Ravi Babu 
> ---
>  common/spl/spl.c |9 +
>  include/spl.h|1 +
>  2 files changed, 10 insertions(+)
> 
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 82e7f58..0726378 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -273,6 +273,11 @@ static void announce_boot_device(u32 boot_device)
>  static inline void announce_boot_device(u32 boot_device) { }
>  #endif
>  
> +__weak int spl_run_dfu(void)
> +{
> + return 0;
> +}
> +
>  static int spl_load_image(u32 boot_device)
>  {
>   switch (boot_device) {
> @@ -367,6 +372,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>   spl_board_init();
>  #endif
>  
> + if (spl_run_dfu())
> + goto os_boot;
> +
>   board_boot_order(spl_boot_list);
>   for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
>   spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
> @@ -381,6 +389,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>   hang();
>   }
>  
> +os_boot:
>   switch (spl_image.os) {
>   case IH_OS_U_BOOT:
>   debug("Jumping to U-Boot\n");
> diff --git a/include/spl.h b/include/spl.h
> index 8849678..f21a76a 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -149,4 +149,5 @@ bool spl_was_boot_source(void);
>  int spl_dfu_mmc(int usb_index, int mmc_dev, char *dfu_alt_info);
>  int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface,
> char *devstr); int spl_dfu_ram_load_image(void);
> +int spl_run_dfu(void);
>  #endif

Reviewed-by: Lukasz Majewski 

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH v1 2/6] spl: dfu: adding dfu support functions for SPL-DFU

2016-06-24 Thread Lukasz Majewski
Hi Ravi,

> Adding support functions to run dfu commands
> 
> Signed-off-by: Ravi Babu 
> ---
>  common/spl/Makefile  |1 +
>  common/spl/spl_dfu.c |  153
> ++
> include/spl.h|   10  3 files changed, 164 insertions(+)
>  create mode 100644 common/spl/spl_dfu.c
> 
> diff --git a/common/spl/Makefile b/common/spl/Makefile
> index 2e0f695..7a34697 100644
> --- a/common/spl/Makefile
> +++ b/common/spl/Makefile
> @@ -21,4 +21,5 @@ obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
>  obj-$(CONFIG_SPL_FAT_SUPPORT) += spl_fat.o
>  obj-$(CONFIG_SPL_EXT_SUPPORT) += spl_ext.o
>  obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o
> +obj-$(CONFIG_SPL_DFU) += spl_dfu.o
>  endif
> diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
> new file mode 100644
> index 000..8b8432b
> --- /dev/null
> +++ b/common/spl/spl_dfu.c
> @@ -0,0 +1,153 @@
> +/*
> + * (C) Copyright 2010

IMHO, now we have 2016 :-)

> + * Texas Instruments, 
> + *
> + * Ravi B 
> + *
> + * SPDX-License-Identifier:  GPL-2.0+
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static int run_dfu(int usb_index, char *interface, char *devstring)
> +{
> + int ret;
> +
> + ret = dfu_init_env_entities(interface, devstring);
> + if (ret)
> + goto done;
> +
> + ret = CMD_RET_SUCCESS;
> +
> + board_usb_init(usb_index, USB_INIT_DEVICE);
> + g_dnl_clear_detach();
> + g_dnl_register("usb_dnl_dfu");
> +
> + while (1) {
> + if (ctrlc())
> + goto exit;
> +
> + if (dfu_get_defer_flush()) {
> + /*
> +  * Call to usb_gadget_handle_interrupts() is
> necessary
> +  * to act on ZLP OUT transaction from HOST
> PC after
> +  * transmitting the whole file.
> +  *
> +  * If this ZLP OUT packet is NAK'ed, the
> HOST libusb
> +  * function fails after timeout (by default
> it is set to
> +  * 5 seconds). In such situation the
> dfu-util program
> +  * exits with error message.
> +  */
> + usb_gadget_handle_interrupts(usb_index);
> + ret = dfu_flush(dfu_get_defer_flush(), NULL,
> 0, 0);
> + dfu_set_defer_flush(NULL);
> + if (ret) {
> + error("Deferred dfu_flush()
> failed!");
> + goto exit;
> + }
> + }
> +
> + WATCHDOG_RESET();
> + usb_gadget_handle_interrupts(usb_index);
> + }
> +exit:
> + g_dnl_unregister();
> + board_usb_cleanup(usb_index, USB_INIT_DEVICE);
> +done:
> + dfu_free_entities();
> + g_dnl_clear_detach();
> +
> + return ret;
> +}
> +
> +int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface,
> char *devstr) +{
> + char *str_env;
> + int ret;
> +
> + /* set default environment */
> + set_default_env(0);
> + str_env = getenv(dfu_alt_info);
> + if (!str_env) {
> + error("\"dfu_alt_info\" env variable not
> defined!\n");
> + return -EINVAL;
> + }
> +
> + ret = setenv("dfu_alt_info", str_env);
> + if (ret) {
> + error("unable to set env variable
> \"dfu_alt_info\"!\n");
> + return -EINVAL;
> + }
> +
> + /* invoke dfu command */
> + return run_dfu(usbctrl, interface, devstr);
> +}
> +
> +int spl_dfu_mmc(int usb_index, int mmc_dev, char *dfu_alt_info)
> +{
> + struct mmc *mmcdev;
> + struct mmc **mmc = &mmcdev;
> + int device = mmc_dev;
> + int ret;
> +
> + /* initialize the mmc module */
> + mmc_initialize(0);
> +
> + *mmc = find_mmc_device(device);
> + if (!*mmc) {
> + error("failed to find mmc device %d\n", device);
> + return -ENODEV;
> + }
> +
> + ret = mmc_init(*mmc);
> + if (ret) {
> + error("spl: mmc init failed with error: %d\n", ret);
> + return ret;
> + }
> +
> + return spl_dfu_cmd(usb_index, dfu_alt_info, "mmc", mmc_dev ?
> "1" : "0"); +}
> +
> +ulong spl_fit_ram_read(struct spl_load_info *load, ulong sector,
> ulong count,
> +   void *buf)
> +{
> + memcpy(buf, (void *)sector, count);
> + return count;
> +}
> +
> +int spl_dfu_ram_load_image(void)
> +{
> + int err = 0;
> + struct image_header *header;
> + unsigned int addr = 0x8020;

This 0x8020 constant should be defined in the Kconfig
or ./include/dra7xx.h file.

Maybe it would be beneficial to get this value from envs (maybe
"loadadr" env would appropriate to be reused here?).
Nothing also prevents us from defining new one.

> + char *filename = (char *)addr;
> +
> +  

Re: [U-Boot] [RFC PATCH v1 1/6] spl: dfu: add dfu support in SPL

2016-06-24 Thread B, Ravi
Hi Lukasz

> > Traditionally the DFU support is available only as part 2nd stage boot 
> > loader(u-boot) and DFU is not supported in SPL.
> > 
> > The SPL-DFU feature is useful for boards which has only USB inteface 
> > and do not have external interface like ethernet or MMC/SD to boot the 
> > board.
> > 
> > This patch add DFU support in SPL to flash boot inital binary images 
> > to factory or bare-metal boards to memory devices like SPI, eMMC, 
> > MMC/SD card using USB interface.
> > 
> > This SPL-DFU support can be enabled through
> > Menuconfig->Boot Images->Enable SPL-DFU support
> > 
> > Signed-off-by: Ravi Babu 
> > ---
> >  Kconfig  |   33 +
> >  common/Makefile  |   26 +++---
> >  common/command.c |2 +-
> >  scripts/Makefile.spl |   13 +
> >  4 files changed, 66 insertions(+), 8 deletions(-)
> > 
> > diff --git a/Kconfig b/Kconfig
> > index f53759a..969641e 100644
> > --- a/Kconfig
> > +++ b/Kconfig
> > @@ -285,6 +285,39 @@ config SPL_LOAD_FIT
> >   particular it can handle selecting from multiple device tree and 
> > passing the correct one to U-Boot.
> >  
> > +config SPL_DFU
> > +   bool "Enable SPL with DFU to load binaries to bootdevices
> > using USB"
> > +   depends on USB && CMD_DFU && TARGET_DRA7XX_EVM

> Is this dependency correct? Especially the CONFIG_CMD_DFU? As fair as I 
> remember, we don't need "dfu" command to make SPL dfu working.

I do agree, I did not use  cmd/dfu.c. Will clean it up.

> What we do need are
> CONFIG_USB_GADGET_DOWNLOAD,CONFIG_USB_FUNCTION_THOR,
> CONFIG_USB_FUNCTION_DFU, etc.

Regards
Ravi 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH v1 1/6] spl: dfu: add dfu support in SPL

2016-06-24 Thread Lukasz Majewski
Hi Ravi,

> Traditionally the DFU support is available only
> as part 2nd stage boot loader(u-boot) and DFU
> is not supported in SPL.
> 
> The SPL-DFU feature is useful for boards which has
> only USB inteface and do not have external interface
> like ethernet or MMC/SD to boot the board.
> 
> This patch add DFU support in SPL to flash boot inital
> binary images to factory or bare-metal boards to
> memory devices like SPI, eMMC, MMC/SD card using
> USB interface.
> 
> This SPL-DFU support can be enabled through
> Menuconfig->Boot Images->Enable SPL-DFU support
> 
> Signed-off-by: Ravi Babu 
> ---
>  Kconfig  |   33 +
>  common/Makefile  |   26 +++---
>  common/command.c |2 +-
>  scripts/Makefile.spl |   13 +
>  4 files changed, 66 insertions(+), 8 deletions(-)
> 
> diff --git a/Kconfig b/Kconfig
> index f53759a..969641e 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -285,6 +285,39 @@ config SPL_LOAD_FIT
> particular it can handle selecting from multiple device
> tree and passing the correct one to U-Boot.
>  
> +config SPL_DFU
> + bool "Enable SPL with DFU to load binaries to bootdevices
> using USB"
> + depends on USB && CMD_DFU && TARGET_DRA7XX_EVM

Is this dependency correct? Especially the CONFIG_CMD_DFU? As fair as I
remember, we don't need "dfu" command to make SPL dfu working.

What we do need are
CONFIG_USB_GADGET_DOWNLOAD,CONFIG_USB_FUNCTION_THOR, 
CONFIG_USB_FUNCTION_DFU, etc.

> + help
> +   Currently the SPL does not have capability to load the
> +   binaries or boot images to boot devices like eMMC,SPI,etc.
> +   This feature enables the DFU (Device Firmware Upgarde) in
> SPL with
> +   RAM device as default bootdevice. The ROM code will load
> and execute
> +   the SPL/MLO dfu image. The user can flash the binaries to
> selected
> +   dfu device partition from host-pc using dfu-utils.
> + This feature will be useful to flash the binaries to
> factory
> +   or bare-metal boards using USB interface.
> +
> +choice
> + bool "DFU device selection"
> + depends on CMD_DFU && SPL_DFU
> +
> +config SPL_DFU_RAM
> + bool "RAM device"
> + depends on CMD_DFU
> + help
> +  select DDR memory device for flashing binary images to
> +  the selected partition using DFU.
> +
> +config SPL_DFU_SF
> + bool "SPI device"
> + depends on CMD_DFU && SPL_DFU
> + help
> +  select SPI flash memory device for flashing binary images to
> +  the selected partition using DFU.
> +
> +endchoice
> +
>  config SYS_CLK_FREQ
>   depends on ARC || ARCH_SUNXI
>   int "CPU clock frequency"
> diff --git a/common/Makefile b/common/Makefile
> index b23f312..0fa441f 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -6,15 +6,30 @@
>  #
>  
>  # core
> -ifndef CONFIG_SPL_BUILD
> -obj-y += init/
> -obj-y += main.o
> -obj-y += exports.o
> +
> +CONFIG_INC_DFU=y
> +ifdef CONFIG_SPL_BUILD
> +ifndef CONFIG_SPL_DFU
> +CONFIG_INC_DFU=n
> +endif
> +endif
> +
> +ifeq ($(CONFIG_INC_DFU),y)
>  obj-y += hash.o
>  ifdef CONFIG_SYS_HUSH_PARSER
>  obj-y += cli_hush.o
>  endif
>  
> +obj-y += env_attr.o
> +obj-y += env_callback.o
> +obj-y += env_flags.o
> +endif
> +
> +ifndef CONFIG_SPL_BUILD
> +obj-y += init/
> +obj-y += main.o
> +obj-y += exports.o
> +
>  # This option is not just y/n - it can have a numeric value
>  ifdef CONFIG_BOOTDELAY
>  obj-y += autoboot.o
> @@ -34,9 +49,6 @@ obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
>  obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
>  
>  # environment
> -obj-y += env_attr.o
> -obj-y += env_callback.o
> -obj-y += env_flags.o
>  obj-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o
>  obj-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o
>  extra-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o
> diff --git a/common/command.c b/common/command.c
> index e5d9b9c..d1c049c 100644
> --- a/common/command.c
> +++ b/common/command.c
> @@ -520,7 +520,7 @@ enum command_ret_t cmd_process(int flag, int
> argc, char * const argv[], if (argc > cmdtp->maxargs)
>   rc = CMD_RET_USAGE;
>  
> -#if defined(CONFIG_CMD_BOOTD)
> +#if defined(CONFIG_CMD_BOOTD) && !defined(CONFIG_SPL_BUILD)
>   /* avoid "bootd" recursion */
>   else if (cmdtp->cmd == do_bootd) {
>   if (flag & CMD_FLAG_BOOTD) {
> diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
> index ec8d8f1..be74991 100644
> --- a/scripts/Makefile.spl
> +++ b/scripts/Makefile.spl
> @@ -35,6 +35,13 @@ else
>  SPL_BIN := u-boot-spl
>  endif
>  
> +CONFIG_INC_DFU=y
> +ifdef CONFIG_SPL_BUILD
> +ifndef CONFIG_SPL_DFU
> +CONFIG_INC_DFU=n
> +endif
> +endif
> +
>  include $(srctree)/config.mk
>  include $(srctree)/arch/$(ARCH)/Makefile
>  
> @@ -56,6 +63,12 @@ libs-y += common/init/
>  libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/
>  libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
>  libs-y += drivers/
> +ifeq ($(CONFIG_INC_DFU),y)
> +libs-y += d

[U-Boot] [PATCH][v3] armv8: fsl-layerscape: Append "A" in SoC name for ARM based SoCs

2016-06-24 Thread Prabhakar Kushwaha
Freescale ARMv8 SoC name ends with "A" to represent ARM SoCs.
like LS2080A, LS1043A, LS1012A.

So append "A" at the last of SoCs.

Signed-off-by: Pratiyush Mohan Srivastava 
Signed-off-by: Prabhakar Kushwaha 
---
Changes for v2: Updated the description
Changes for v3: Apped "A" uniformly across the files

 arch/arm/cpu/armv8/fsl-layerscape/soc.c|  4 ++--
 arch/arm/include/asm/arch-fsl-layerscape/cpu.h | 14 +++---
 arch/arm/include/asm/arch-fsl-layerscape/soc.h | 14 +++---
 drivers/usb/common/fsl-errata.c|  4 ++--
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index d8ec426..f62b78d 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -28,7 +28,7 @@ bool soc_has_dp_ddr(void)
u32 svr = gur_in32(&gur->svr);
 
/* LS2085A has DP_DDR */
-   if (SVR_SOC_VER(svr) == SVR_LS2085)
+   if (SVR_SOC_VER(svr) == SVR_LS2085A)
return true;
 
return false;
@@ -40,7 +40,7 @@ bool soc_has_aiop(void)
u32 svr = gur_in32(&gur->svr);
 
/* LS2085A has AIOP */
-   if (SVR_SOC_VER(svr) == SVR_LS2085)
+   if (SVR_SOC_VER(svr) == SVR_LS2085A)
return true;
 
return false;
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/cpu.h 
b/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
index df877dd..197b0eb 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
@@ -8,13 +8,13 @@
 #define _FSL_LAYERSCAPE_CPU_H
 
 static struct cpu_type cpu_type_list[] = {
-   CPU_TYPE_ENTRY(LS2080, LS2080, 8),
-   CPU_TYPE_ENTRY(LS2085, LS2085, 8),
-   CPU_TYPE_ENTRY(LS2045, LS2045, 4),
-   CPU_TYPE_ENTRY(LS1043, LS1043, 4),
-   CPU_TYPE_ENTRY(LS1023, LS1023, 2),
-   CPU_TYPE_ENTRY(LS2040, LS2040, 4),
-   CPU_TYPE_ENTRY(LS1012, LS1012, 1),
+   CPU_TYPE_ENTRY(LS2080A, LS2080A, 8),
+   CPU_TYPE_ENTRY(LS2085A, LS2085A, 8),
+   CPU_TYPE_ENTRY(LS2045A, LS2045A, 4),
+   CPU_TYPE_ENTRY(LS1043A, LS1043A, 4),
+   CPU_TYPE_ENTRY(LS1023A, LS1023A, 2),
+   CPU_TYPE_ENTRY(LS2040A, LS2040A, 4),
+   CPU_TYPE_ENTRY(LS1012A, LS1012A, 1),
 };
 
 #ifndef CONFIG_SYS_DCACHE_OFF
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/soc.h 
b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
index 2cb6c54..39e8c7a 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/soc.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
@@ -41,13 +41,13 @@ struct cpu_type {
{ .name = #n, .soc_ver = SVR_##v, .num_cores = (nc)}
 
 #define SVR_WO_E   0xFE
-#define SVR_LS1012 0x870400
-#define SVR_LS1043 0x879200
-#define SVR_LS1023 0x879208
-#define SVR_LS2045 0x870120
-#define SVR_LS2080 0x870110
-#define SVR_LS2085 0x870100
-#define SVR_LS2040 0x870130
+#define SVR_LS1012A0x870400
+#define SVR_LS1043A0x879200
+#define SVR_LS1023A0x879208
+#define SVR_LS2045A0x870120
+#define SVR_LS2080A0x870110
+#define SVR_LS2085A0x870100
+#define SVR_LS2040A0x870130
 
 #define SVR_MAJ(svr)   (((svr) >> 4) & 0xf)
 #define SVR_MIN(svr)   (((svr) >> 0) & 0xf)
diff --git a/drivers/usb/common/fsl-errata.c b/drivers/usb/common/fsl-errata.c
index ebe60a8..183bf2b 100644
--- a/drivers/usb/common/fsl-errata.c
+++ b/drivers/usb/common/fsl-errata.c
@@ -182,8 +182,8 @@ bool has_erratum_a008751(void)
 
switch (soc) {
 #ifdef CONFIG_ARM64
-   case SVR_LS2080:
-   case SVR_LS2085:
+   case SVR_LS2080A:
+   case SVR_LS2085A:
return IS_SVR_REV(svr, 1, 0);
 #endif
}
-- 
1.9.1


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH V2] net: NFS: Add NFSv3 support

2016-06-24 Thread Guillaume Gardet



Le 23/06/2016 21:08, Tom Rini a écrit :

On Thu, Jun 23, 2016 at 11:10:26AM +0200, Guillaume GARDET wrote:


This patch enables NFSv3 support.
If NFSv2 is available use it as usual.
If NFSv2 is not available, but NFSv3 is available, use NFSv3.
If NFSv2 and NFSv3 are not available, print an error message since NFSv4 is not 
supported.

Tested on iMX6 sabrelite with 4 Linux NFS servers:
   * NFSv2 + NFSv3 + NFSv4 server: use NFSv2 protocol
   * NFSv2 + NFSv3 server: use NFSv3 protocol
   * NFSv3 + NFSv4 server: use NFSv3 protocol
   * NFSv3 server: use NFSv3 protocol

So, why do we have v2+v3+v4 -> v2 and not v2+v3+v4 -> v3, when we do
v2+v3 -> v3 and v3+v4 -> v3 ?  We should be consistent in preferring
either v2 over v3 or v3 over v2.  Thanks!



Sorry, it is a typo error. Please read: "NFSv2 + NFSv3 server: use NFSv2 
protocol".

As long as NFSv2 is available, we use it. Otherwise, we use v3 if available. As 
explained above.


Guillaume

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot