platform/kernel/u-boot.git
5 years agoMAINTAINERS: assign lib/charset.c
Heinrich Schuchardt [Thu, 5 Jul 2018 17:43:50 +0000 (19:43 +0200)]
MAINTAINERS: assign lib/charset.c

lib/charset.c is only used by the EFI subsystem.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_selftest: unit test for GetTime()
Heinrich Schuchardt [Sat, 7 Jul 2018 21:39:16 +0000 (23:39 +0200)]
efi_selftest: unit test for GetTime()

Provide a unit test for the GetTime() runtime service.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_selftest: support printing leading zeroes
Heinrich Schuchardt [Sat, 7 Jul 2018 21:39:15 +0000 (23:39 +0200)]
efi_selftest: support printing leading zeroes

Allow specifying the precision when printing integers, e.g.

efi_st_printf("%.4u-%.2u-%.2u\n", year, month, day);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: complete implementation of GetTime()
Heinrich Schuchardt [Sat, 7 Jul 2018 21:39:14 +0000 (23:39 +0200)]
efi_loader: complete implementation of GetTime()

Implement the missing parts of the GetTime() runtime service.

Fill seconds.
Fill daylight saving time flag correctly.
Provide dummy values for capabilities.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: remove unused efi_get_time_init()
Heinrich Schuchardt [Sat, 7 Jul 2018 21:39:13 +0000 (23:39 +0200)]
efi_loader: remove unused efi_get_time_init()

Remove unused function efi_get_time_init().

Initialization of the RTC has to be done in board bring up not in the EFI
subsystem.

There is no RTC device in the UEFI spec. The RTC is only accessed through
the runtime services.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agortc: remove CONFIG_CMD_DATE dependency
Heinrich Schuchardt [Sat, 7 Jul 2018 21:39:12 +0000 (23:39 +0200)]
rtc: remove CONFIG_CMD_DATE dependency

The EFI subsystem accesses the real time clock and is enabled by default.
So we should drop any CONFIG_CMD_DATE dependency from the real time clock
drivers.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_selftest: unit test for CalculateCrc32()
Heinrich Schuchardt [Sat, 7 Jul 2018 13:36:07 +0000 (15:36 +0200)]
efi_selftest: unit test for CalculateCrc32()

This unit test checks the CalculateCrc32 bootservice and checks the
headers of the system table, the boot services tablle, and the runtime
services table before and after ExitBootServices().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_selftest: check crc32 for InstallConfigurationTable
Heinrich Schuchardt [Sat, 7 Jul 2018 13:36:06 +0000 (15:36 +0200)]
efi_selftest: check crc32 for InstallConfigurationTable

InstallConfigurationTable() may change the number of installed
configuration tables.

Check the crc32 of the system table.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: update crc32 in InstallConfigurationTable
Heinrich Schuchardt [Sat, 7 Jul 2018 13:36:05 +0000 (15:36 +0200)]
efi_loader: update crc32 in InstallConfigurationTable

If the number of installed tables is changed in
InstallConfigurationTable() update the crc32 of the system table.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: correct signature of CalculateCrc32()
Heinrich Schuchardt [Sat, 7 Jul 2018 13:36:04 +0000 (15:36 +0200)]
efi_loader: correct signature of CalculateCrc32()

Use const for the buffer. We are not changing the buffer.
Use efi_uintn_t where prescribed by the UEFI spec.
Prefer u32 over uint32_t.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_selftest: test InstallConfigurationTable()
Heinrich Schuchardt [Thu, 28 Jun 2018 10:45:33 +0000 (12:45 +0200)]
efi_selftest: test InstallConfigurationTable()

Provide a unit test for InstallConfigurationTable().

A table is installed, updated, removed. The table entry and the
triggering of events is checked.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: allocate configuration table array
Heinrich Schuchardt [Thu, 28 Jun 2018 10:45:32 +0000 (12:45 +0200)]
efi_loader: allocate configuration table array

The system table contains a link to the list of configurations tables.
These include the device tree, SMBIOS table, and the ACPI table.

This array is currently statically linked. With the patch it is allocated
as EFI_RUNTIME_SERVICES_DATA. Due to the structure of the system table we
cannot work with a linked list here.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: calculate crc32 for EFI tables
Heinrich Schuchardt [Thu, 28 Jun 2018 10:45:31 +0000 (12:45 +0200)]
efi_loader: calculate crc32 for EFI tables

For the boot and runtime services tables and for the system table the
crc32 has to be set in the header.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: provide firmware revision
Heinrich Schuchardt [Thu, 28 Jun 2018 10:45:30 +0000 (12:45 +0200)]
efi_loader: provide firmware revision

Provide a firmware revision in the system table using the Makefile
variables VERSION and PATCHLEVEL, e.g. 0x20180700 for v2018.07.

Correct the type of the firmware vendor. It is a u16* pointer.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: correct headersize EFI tables
Heinrich Schuchardt [Thu, 28 Jun 2018 10:45:29 +0000 (12:45 +0200)]
efi_loader: correct headersize EFI tables

The headersize field has to be set to the size of the whole table
including the header.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: correct EFI_RUNTIME_SERVICES_SIGNATURE
Heinrich Schuchardt [Thu, 28 Jun 2018 10:45:28 +0000 (12:45 +0200)]
efi_loader: correct EFI_RUNTIME_SERVICES_SIGNATURE

The value for EFI_RUNTIME_SERVICES_SIGNATURE does not match the
UEFI spec 2.7.

Reported-by: Takahiro Akashi <takahiro.akashi@linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: specify UEFI spec revision
Heinrich Schuchardt [Thu, 28 Jun 2018 10:45:27 +0000 (12:45 +0200)]
efi_loader: specify UEFI spec revision

Both in the boot and the runtime services tables we have to specify the
UEFI spec revision. The same value is already used for the system
table. So let's use a common constant.

In the boot services table we have to provide the header signature.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: clear screen has to reset cursor position
Heinrich Schuchardt [Thu, 5 Jul 2018 06:18:00 +0000 (08:18 +0200)]
efi_loader: clear screen has to reset cursor position

After clearing the screen the cursor position is row 0, column 0.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset()
Heinrich Schuchardt [Thu, 5 Jul 2018 06:17:59 +0000 (08:17 +0200)]
efi_loader: EFI_SIMPLE_TEXT_INPUT_PROTOCOL.Reset()

Implement the reset service of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL.

This should resolve the error reported by the SCT in
Protocol/SimpleTextIn/BlackBoxTest/SimpleTextInBBTestFunction.c:193

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: set revision in loaded image protocol
Heinrich Schuchardt [Thu, 5 Jul 2018 06:17:58 +0000 (08:17 +0200)]
efi_loader: set revision in loaded image protocol

The revision number has to be set in the loaded image protocol.

The problem was detected by running the SCT in
Protocol/LoadedImage/BlackBoxTest/LoadedImageBBTestMain.c:890

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_driver: set DM_FLAG_NAME_ALLOCED flag
Heinrich Schuchardt [Sat, 30 Jun 2018 05:11:32 +0000 (07:11 +0200)]
efi_driver: set DM_FLAG_NAME_ALLOCED flag

Set the DM_FLAG_NAME_ALLOCED flag to avoid a memory leak when the block
device is removed.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_selftest: test writing to file
Heinrich Schuchardt [Mon, 2 Jul 2018 00:41:24 +0000 (02:41 +0200)]
efi_selftest: test writing to file

Provide a unit test for writing to a FAT file system.
Add some additional comments in block device unit test.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agofs: fat: cannot write to subdirectories
Heinrich Schuchardt [Mon, 2 Jul 2018 00:41:23 +0000 (02:41 +0200)]
fs: fat: cannot write to subdirectories

fs_fat_write() is not able to write to subdirectories.

Currently if a filepath with a leading slash is passed, the slash is
treated as part of the filename to be created in the root directory.

Strip leading (back-)slashes.

Check that the remaining filename does not contain any illegal characters
(<>:"/\|?*). This way we will throw an error when trying to write to a
subdirectory.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: check map_key in ExitBootServices
Heinrich Schuchardt [Mon, 2 Jul 2018 10:53:55 +0000 (12:53 +0200)]
efi_loader: check map_key in ExitBootServices

The UEFI spec requires that the memory map key is checked in
ExitBootServices().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: check parameters of GetMemoryMap
Heinrich Schuchardt [Mon, 2 Jul 2018 10:53:54 +0000 (12:53 +0200)]
efi_loader: check parameters of GetMemoryMap

Check the parameters of boottime service GetMemoryMap().
Return EFI_INVALID_PARAMETER where required by the UEFI spec.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: check parameters in memory allocation
Heinrich Schuchardt [Mon, 2 Jul 2018 10:53:53 +0000 (12:53 +0200)]
efi_loader: check parameters in memory allocation

If no pointer is provided throw an error.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: check parameters of CreateEvent
Heinrich Schuchardt [Mon, 2 Jul 2018 10:53:52 +0000 (12:53 +0200)]
efi_loader: check parameters of CreateEvent

Rigorously check the TPL level and the event type.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agox86: Add efi_loader bits to x86_64 linker script
Alexander Graf [Tue, 10 Jul 2018 23:39:31 +0000 (01:39 +0200)]
x86: Add efi_loader bits to x86_64 linker script

The x86_64 linker script was missing efi runtime information. Add it.

Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: Rename sections to allow for implicit data
Alexander Graf [Tue, 12 Jun 2018 05:48:37 +0000 (07:48 +0200)]
efi_loader: Rename sections to allow for implicit data

Some times gcc may generate data that is then used within code that may
be part of an efi runtime section. That data could be jump tables,
constants or strings.

In order to make sure we catch these, we need to ensure that gcc emits
them into a section that we can relocate together with all the other
efi runtime bits. This only works if the -ffunction-sections and
-fdata-sections flags are passed and the efi runtime functions are
in a section that starts with ".text".

Up to now we had all efi runtime bits in sections that did not
interfere with the normal section naming scheme, but this forces
us to do so. Hence we need to move the efi_loader text/data/rodata
sections before the global *(.text*) catch-all section.

With this patch in place, we should hopefully have an easier time
to extend the efi runtime functionality in the future.

Signed-off-by: Alexander Graf <agraf@suse.de>
[agraf: Fix x86_64 breakage]

5 years agoefi: Drop error return in efi_carve_out_dt_rsv()
Simon Glass [Mon, 18 Jun 2018 14:08:28 +0000 (08:08 -0600)]
efi: Drop error return in efi_carve_out_dt_rsv()

This function currently returns an error code, but never uses it. There is
no function comment so it is not obvious why. Presuambly the error is not
important.

Update the function to explain its purpose and why it ignores the error.
Drop the useful error return value.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi: Tidy up device-tree-size calculation in copy_fdt()
Simon Glass [Mon, 18 Jun 2018 14:08:25 +0000 (08:08 -0600)]
efi: Tidy up device-tree-size calculation in copy_fdt()

This is a bit confusing at present since it adds 4KB to the pointer, then
rounds it up. It looks like a bug, but is not.

Move the 4KB addition into a separate statement and expand the comment.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_selftest: Clean up a few comments and messages
Simon Glass [Mon, 18 Jun 2018 14:08:21 +0000 (08:08 -0600)]
efi_selftest: Clean up a few comments and messages

Fix the 'amp' typo, expand on what 'steps' is and fix a few other minor
things.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agovsprintf: Handle NULL with %pU
Simon Glass [Mon, 18 Jun 2018 14:08:20 +0000 (08:08 -0600)]
vsprintf: Handle NULL with %pU

At present a NULL pointer passed to printf for a %pU argument will cause
U-Boot to access memory at 0. Fix this by adding a check, and print
"(null)" instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexander Graf <agraf@suse.de>
[agraf: s/(null)/<NULL>/]
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: Expose U-Boot addresses in memory map for sandbox
Alexander Graf [Mon, 18 Jun 2018 15:23:15 +0000 (17:23 +0200)]
efi_loader: Expose U-Boot addresses in memory map for sandbox

We currently expose host addresses in the EFI memory map. That can be
bad if we ever want to use sandbox to boot strap a real kernel, because
then the kernel would fetch its memory table from our host virtual address
map. But to make that use case work, we would need to have full control
over the address space the EFI application sees.

So let's expose only U-Boot addresses to the guest until we get to the
point of allocation. EFI's allocation functions are fun - they can take
U-Boot addresses as input values for hints and return host addresses as
allocation results through the same uint64_t * parameter. So we need to
be extra careful on what to pass in when.

With this patch I am successfully able to run the efi selftest suite as
well as grub.efi on aarch64.

Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi: sandbox: Adjust memory usage for sandbox
Simon Glass [Mon, 18 Jun 2018 15:23:12 +0000 (17:23 +0200)]
efi: sandbox: Adjust memory usage for sandbox

With sandbox the U-Boot code is not mapped into the sandbox memory range
so does not need to be excluded when allocating EFI memory. Update the EFI
memory init code to take account of that.

Signed-off-by: Simon Glass <sjg@chromium.org>
[agraf: Remove map_sysmem() call and header reference]
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: Use common elf.h reloc defines
Alexander Graf [Mon, 18 Jun 2018 15:23:11 +0000 (17:23 +0200)]
efi_loader: Use common elf.h reloc defines

Now that elf.h contains relocation defines for all architectures
we care about, let's just include it unconditionally and refer to
the defines.

Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoelf: Move x86 reloc defines to common elf.h
Alexander Graf [Mon, 18 Jun 2018 15:23:10 +0000 (17:23 +0200)]
elf: Move x86 reloc defines to common elf.h

We need to know about x86 relocation definitions even in cases where
we don't officially build against the x86 target, such as with sandbox.

So let's move the x86 definitions into the common elf header, where all
other architectures already have them.

Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: Move to compiler based target architecture determination
Alexander Graf [Mon, 18 Jun 2018 15:23:08 +0000 (17:23 +0200)]
efi_loader: Move to compiler based target architecture determination

Thanks to CONFIG_SANDBOX, we can not rely on config options to tell us
what CPU architecture we're running on.

The compiler however does know that, so let's just move the ifdefs over
to compiler based defines rather than kconfig based options.

Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: Introduce ms abi vararg helpers
Alexander Graf [Mon, 18 Jun 2018 15:23:05 +0000 (17:23 +0200)]
efi_loader: Introduce ms abi vararg helpers

Varargs differ between sysv and ms abi. On x86_64 we have to follow the ms
abi though, so we also need to make sure we use x86_64 varargs helpers.

This patch introduces generic efi vararg helpers that adhere to the
respective EFI ABI. That way we can deal with them properly from efi
loader code and properly interpret variable arguments.

This fixes the InstallMultipleProtocolInterfaces tests in the efi selftests
on x86_64 for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: Disable miniapps on sandbox
Alexander Graf [Mon, 18 Jun 2018 15:23:03 +0000 (17:23 +0200)]
efi_loader: Disable miniapps on sandbox

In the sandbox environment we can not easily build efi stub binaries
right now, so let's disable the respective test cases for the efi
selftest suite.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: efi_allocate_pages is too restrictive
Heinrich Schuchardt [Mon, 18 Jun 2018 15:23:02 +0000 (17:23 +0200)]
efi_loader: efi_allocate_pages is too restrictive

When running on the sandbox the stack is not necessarily at a higher memory
address than the highest free memory.

There is no reason why the checking of the highest memory address should be
more restrictive for EFI_ALLOCATE_ANY_PAGES than for
EFI_ALLOCATE_MAX_ADDRESS.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
[agraf: use -1ULL instead]
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: Allow SMBIOS tables in highmem
Alexander Graf [Mon, 18 Jun 2018 15:23:00 +0000 (17:23 +0200)]
efi_loader: Allow SMBIOS tables in highmem

We try hard to make sure that SMBIOS tables live in the lower 32bit.
However, when we can not find any space at all there, we should not
error out but instead just fall back to map them in the full address
space instead.

This can for example happen on systems that do not have any RAM mapped
in the lower 32bits of address space. In that case having any SMBIOS
tables at all is better than having none.

Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: Use map_sysmem() in bootefi command
Alexander Graf [Mon, 18 Jun 2018 15:22:58 +0000 (17:22 +0200)]
efi_loader: Use map_sysmem() in bootefi command

The bootefi command gets a few addresses as values passed in. In sandbox,
these values are in U-Boot address space, so we need to make sure we
explicitly call map_sysmem() on them to be able to access them.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: Use compiler constants for image loader
Alexander Graf [Mon, 18 Jun 2018 15:22:57 +0000 (17:22 +0200)]
efi_loader: Use compiler constants for image loader

The EFI image loader tries to determine which target architecture we're
working with to only load PE binaries that match.

So far this has worked based on CONFIG defines, because the target CPU
was always indicated by a config define. With sandbox however, this is
not longer true as all sandbox targets only encompass a single CONFIG
option and so we need to use compiler defines to determine the CPU
architecture.

Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoRevert "efi_loader: no support for ARMV7_NONSEC=y"
Mark Kettenis [Fri, 15 Jun 2018 21:47:15 +0000 (23:47 +0200)]
Revert "efi_loader: no support for ARMV7_NONSEC=y"

This reverts commit c524997acb3d322e1bbd36c06ad02ef589705e7c.

Booting ARMv7 in non-secure mode using bootefi works now.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoARM: HYP/non-sec: enable ARMV7_LPAE if HYP mode is supported
Mark Kettenis [Fri, 15 Jun 2018 21:47:14 +0000 (23:47 +0200)]
ARM: HYP/non-sec: enable ARMV7_LPAE if HYP mode is supported

ARMV7_LPAE is required in order to enable the MMU in HYP mode.
And we really want to enable the MMU in HYP mode such that we can
enable the the caches.  Otherwise U-Boot code (such as the EFI
implementation) that runs in HYP mode will run at a snils pace.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: ARM: don't attempt to enter non-secure mode twice
Mark Kettenis [Fri, 15 Jun 2018 21:47:13 +0000 (23:47 +0200)]
efi_loader: ARM: don't attempt to enter non-secure mode twice

Multiple EFI binaries may be executed in sequence.  So if we already
are in non-secure mode after running the first one we should skip
the switching code since it no longer works once we're non-secure.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_loader: ARM: run EFI payloads non-secure
Mark Kettenis [Fri, 15 Jun 2018 21:47:12 +0000 (23:47 +0200)]
efi_loader: ARM: run EFI payloads non-secure

If desired (and possible) switch into HYP mode or non-secure SVC mode
before calling the entry point of an EFI application.  This allows
U-Boot to provide a usable PSCI implementation and makes it possible
to boot kernels into hypervisor mode using an EFI bootloader.

Based on diffs from Heinrich Schuchardt and Alexander Graf.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
[agraf: Fix indentation]
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoARM: HYP/non-sec: migrate stack
Mark Kettenis [Fri, 15 Jun 2018 21:47:11 +0000 (23:47 +0200)]
ARM: HYP/non-sec: migrate stack

The current code that switches into HYP mode doesn't bother to set
up a stack for HYP mode.  This doesn't work for EFI applications
as they expect a usable stack.  Fix this by migrating the stack
pointer from SP_svc to SP_hyp while in Monitor mode.
This restores the stack pointer when we drop into HYP mode.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agoefi_selftest: update .gitignore
Heinrich Schuchardt [Fri, 15 Jun 2018 04:02:18 +0000 (06:02 +0200)]
efi_selftest: update .gitignore

The following generated files should be ignored by git:
efi_miniapp_file_image_exit.h
efi_miniapp_file_image_return.h

*.so files are normally deleted during the build but should be
ignored too.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
5 years agomtd: nand: add new enum for storing ECC algorithm
Rafał Miłecki [Tue, 10 Jul 2018 09:48:08 +0000 (11:48 +0200)]
mtd: nand: add new enum for storing ECC algorithm

Our nand_ecc_modes_t is already a bit abused by value NAND_ECC_SOFT_BCH.
This enum should store ECC mode only and putting algorithm details there
is a bad idea. It would result in too many values impossible to support
in a sane way.

To solve this problem let's add a new enum. We'll have to modify all
drivers to set it properly but once it's done it'll be possible to drop
NAND_ECC_SOFT_BCH. That will result in a cleaner design and more
possibilities like setting ECC algorithm for hardware ECC mode.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: b0fcd8ab7b3c89b5da7fff5224d06ed73e7a33cc]
[Philippe Reynes: adapt code to u-boot]
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
5 years agoARM: configs: omap3_logic: remove Legacy OMAP3 USB driver
Adam Ford [Fri, 13 Jul 2018 20:27:13 +0000 (15:27 -0500)]
ARM: configs: omap3_logic: remove Legacy OMAP3 USB driver

Only the MUSB driver is currently supported on the omap3_logic
boards.  The driver is using the new-musb and not the legacy
version, so this patch removes the dead code references.

Signed-off-by: Adam Ford <aford173@gmail.com>
5 years agoConvert CONFIG_DA8XX_GPIO to Kconfig
Adam Ford [Tue, 10 Jul 2018 12:01:20 +0000 (07:01 -0500)]
Convert CONFIG_DA8XX_GPIO to Kconfig

This converts the following to Kconfig:
   CONFIG_DA8XX_GPIO

Signed-off-by: Adam Ford <aford173@gmail.com>
5 years agoARM: DTS: am3517-evm-u-boot: Mark MMC1 with cd-inverted
Adam Ford [Tue, 10 Jul 2018 10:23:37 +0000 (05:23 -0500)]
ARM: DTS: am3517-evm-u-boot: Mark MMC1 with cd-inverted

In order to use the device tree for MMC, the card-detect pin
needs to be inverted.  This patch places this into the
am3517-evm-u-boot.dtsi file to keep the main DTS and DTSI files
clean and in-sync with Linux

Signed-off-by: Adam Ford <aford173@gmail.com>
5 years agoARM: dts: am3517-evm-uboot: Add reg-shift for UART
Adam Ford [Tue, 10 Jul 2018 10:04:38 +0000 (05:04 -0500)]
ARM: dts: am3517-evm-uboot: Add reg-shift for UART

With the resync of the omap3.dtsi file, the reg-shift was removed
so it breaks the UART.  Adding the reg-shift into the
am3517-evm-u-boot.dtsi keeps the reg-shift for U-Boot, but keeps
the dts/dtsi files clean from Linux.

Signed-off-by: Adam Ford <aford173@gmail.com>
5 years agodoc: Replace DocBook with sphinx-based docs
Mario Six [Tue, 10 Jul 2018 06:40:17 +0000 (08:40 +0200)]
doc: Replace DocBook with sphinx-based docs

The Linux kernel moved to sphinx-based documentation and got rid of the
DocBook based documentation quite a while ago. Hence, the DocBook
documentation for U-Boot should be converted as well.

To achieve this, import the necessary files from Linux v4.17, and
convert the current DocBook documentation (three files altogether) to
sphinx/reStructuredText.

For now, all old DocBook documentation was merged into a single
handbook, tentatively named "U-Boot Hacker Manual".

For some source files, the documentation style was changed to comply
with kernel-doc; no functional changes were applied.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
5 years agoARM: DTS: Resync Logic PD SOM-LV 37xx devkit with Linux 4.18-RC4
Adam Ford [Tue, 10 Jul 2018 01:18:44 +0000 (20:18 -0500)]
ARM: DTS: Resync Logic PD SOM-LV 37xx devkit with Linux 4.18-RC4

There have been some significant changes to the DM37 SOM-LV device
tree.  This patch re-syncs it with Linux.

Signed-off-by: Adam Ford <aford173@gmail.com>
5 years agoARM: DTS: Resync LogicPD-Torpedo-37xx-devkit with Linux 4.18-RC4
Adam Ford [Tue, 10 Jul 2018 01:18:14 +0000 (20:18 -0500)]
ARM: DTS: Resync LogicPD-Torpedo-37xx-devkit with Linux 4.18-RC4

There have been some refactoring of the DTS files for the Logic PD
DM37 Torpedo.  This patch re-sync's the DTS files with Linux

Signed-off-by: Adam Ford <aford173@gmail.com>
5 years agoARM: dts: Resync OMAP3 and omap36xx with Linux 4.18-RC4
Adam Ford [Tue, 10 Jul 2018 01:14:25 +0000 (20:14 -0500)]
ARM: dts: Resync OMAP3 and omap36xx with Linux 4.18-RC4

There have been several minor changes to the OMAP3.dtsi, so this
patch re-syncs it with Linux.  An addition include/dt-binding was
also brought with it.

Signed-off-by: Adam Ford <aford173@gmail.com>
5 years agoARM: DTS: Resync am3517-evm.dts with Linux 4.18-rc4
Adam Ford [Tue, 10 Jul 2018 00:52:48 +0000 (19:52 -0500)]
ARM: DTS: Resync am3517-evm.dts with Linux 4.18-rc4

Several changes have been made to the AM3517-evm and the underlying
am3517.dtsi file.  This patch re-sync's the DTS and DTSI files with
Linux.

Signed-off-by: Adam Ford <aford173@gmail.com>
5 years agom68k: m5253evbe: Remove this board
Tom Rini [Mon, 9 Jul 2018 14:44:51 +0000 (10:44 -0400)]
m68k: m5253evbe: Remove this board

The m5253evbe board has been marked as orphan since June of 2014 and
should have been dropped a while ago.  Do so now.

Signed-off-by: Tom Rini <trini@konsulko.com>
5 years agospi: stm32_qspi: rework mode management
Christophe Kerello [Mon, 9 Jul 2018 13:32:38 +0000 (15:32 +0200)]
spi: stm32_qspi: rework mode management

This patch solves quad read issue with Macronix/Micron spi nor.

Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
5 years agospi: stm32_qspi: assign functional operation mode in _stm32_qspi_gen_ccr
Christophe Kerello [Mon, 9 Jul 2018 13:32:37 +0000 (15:32 +0200)]
spi: stm32_qspi: assign functional operation mode in _stm32_qspi_gen_ccr

This patch assigns the functional operation mode in _stm32_qspi_gen_ccr
function.

Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
5 years agobios_emulator: remove assignment without effect
Heinrich Schuchardt [Sun, 18 Mar 2018 10:01:23 +0000 (11:01 +0100)]
bios_emulator: remove assignment without effect

Assigning a parameter which is not used afterwards has not effect.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
5 years agoMerge branch 'master' of git://git.denx.de/u-boot-imx
Tom Rini [Mon, 23 Jul 2018 14:51:13 +0000 (10:51 -0400)]
Merge branch 'master' of git://git.denx.de/u-boot-imx

trini: Update colibri-imx6ull to use Kconfig for mtdparts related
options.

Signed-off-by: Tom Rini <trini@konsulko.com>
5 years agoconfigs: imx6q_logic: Cleanup ramdiskaddr and fdtaddr
Adam Ford [Fri, 20 Jul 2018 13:25:53 +0000 (08:25 -0500)]
configs: imx6q_logic: Cleanup ramdiskaddr and fdtaddr

There are already definitions for ramdisk_addr_r and fdt_addr_r, so
having a duplicate copy called ramdiskaddr and fdtaddr is confusing.
This patch converts any references to ramdisk_addr_r and fdt_addr_r
and removes the duplicates.

Signed-off-by: Adam Ford <aford173@gmail.com>
5 years agomx25: fix the offset between the USB ports' registers
Martin Kaiser [Mon, 16 Jul 2018 20:11:57 +0000 (22:11 +0200)]
mx25: fix the offset between the USB ports' registers

The USBOH module on imx25 chips contains two USB controllers which are
called USB OTG Controller and USB Host Controller. Each one has its EHCI
root hub. The OTG Controller's EHCI registers start at offset 0, the Host
Controller's registers start at offset 0x400.

We set CONFIG_MXC_USB_PORT=0 to select the OTG Controller and 1 for the
Host Controller. Therefore, IMX_USB_PORT_OFFSET must be 0x400. Using
this setting, the Host Controller starts working on my imx25 board.

Please note that the imx25 reference manual claims that the Host
Controller's registers start at 0x200. This is not correct. The Linux
Kernel uses the correct offset 0x400 in imx25.dtsi.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
5 years agotools/imximage: get HAB information from header
Holger Dengler [Fri, 6 Jul 2018 14:10:00 +0000 (16:10 +0200)]
tools/imximage: get HAB information from header

Signing parts of a u-boot imximage for image verification in High
Assurance Boot (HAB) in a post-build process, requires some
information from the imximage header. Currently, this information is
only provided during the image build, which makes the transfer of this
information to the post-build process harder than necessary.

The i.MX HAB information (start and length) can be calculated either
by using information from the image-configuration file, or from the
information in the flash header of the imximage.
The advantage of using information from flash header is, that they are
not only available during image creation, but also available if
existing images are processed.

Example:
$ tools/mkimage -l u-boot.imx
Image Type:   Freescale IMX Boot Image
Image Ver:    2 (i.MX53/6/7 compatible)
Mode:         DCD
Data Size:    483328 Bytes = 472.00 KiB = 0.46 MiB
Load Address: 877ff420
Entry Point:  87800000
HAB Blocks:   0x877ff400 0x00000000 0x00071c00
DCD Blocks:   0x00910000 0x0000002c 0x00000208

Signed-off-by: Holger Dengler <dengler@linutronix.de>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
5 years agoARM: dh_imx6: enable GigaDevice, Macronix, and Winbond SPI Flash support in Kconfig
Ludwig Zenz [Fri, 6 Jul 2018 09:26:03 +0000 (11:26 +0200)]
ARM: dh_imx6: enable GigaDevice, Macronix, and Winbond SPI Flash support in Kconfig

In preparation for delivery bottlenecks, enable support for GigaDevice, Macronix, and Winbond nor flash chips.

Signed-off-by: Ludwig Zenz <lzenz@dh-electronics.de>
5 years agoimx: i.mx6q: imx6q_logic: Migrate to SPL and enable SDP
Adam Ford [Fri, 6 Jul 2018 01:58:24 +0000 (20:58 -0500)]
imx: i.mx6q: imx6q_logic: Migrate to SPL and enable SDP

Since the vast majority of i.MX6 boards are migrating to SPL,
this patch converts im6q_logic to SPL and enables the SDP for
loading SPL and u-boot.img over USB.  The Falcon mode only
supports NAND flash as of now due to limited space/RAM, but
all i.MX6D/Q SOM's from Logic PD have internal NAND from which
to boot.

Signed-off-by: Adam Ford <aford173@gmail.com>
5 years agoARM: imx6: DHCOM i.MX6 PDK: ddr init for 32bit bus and 4GBit chips
Ludwig Zenz [Thu, 5 Jul 2018 07:23:48 +0000 (09:23 +0200)]
ARM: imx6: DHCOM i.MX6 PDK: ddr init for 32bit bus and 4GBit chips

Support 1GIB + 2GIB DDR3 with 64bit bus width and 512MIB + 1GIB with 32bit bus width

Signed-off-by: Ludwig Zenz <lzenz@dh-electronics.de>
5 years agoARM: imx6: configure ddrcode pins in spl DHCOM i.MX6 PDK
Ludwig Zenz [Thu, 5 Jul 2018 07:23:47 +0000 (09:23 +0200)]
ARM: imx6: configure ddrcode pins in spl DHCOM i.MX6 PDK

Preperation for conditional DDR3 initialization based on GPIO codes.

Signed-off-by: Ludwig Zenz <lzenz@dh-electronics.de>
5 years agoRevert "ARM: imx6: Disable DDR DRAM calibration DHCOM i.MX6 PDK"
Ludwig Zenz [Thu, 5 Jul 2018 07:23:46 +0000 (09:23 +0200)]
Revert "ARM: imx6: Disable DDR DRAM calibration DHCOM i.MX6 PDK"

This reverts commit a637fe6f27fd4c19ef9f43a5f871c244581422ac.

The DDR DRAM calibration was enhanced by write leveling correction code.
It can be used with T-topology now.

Signed-off-by: Ludwig Zenz <lzenz@dh-electronics.de>
5 years agopico-imx7d: Add new pico-pi config
Otavio Salvador [Fri, 29 Jun 2018 18:19:21 +0000 (15:19 -0300)]
pico-imx7d: Add new pico-pi config

The new config skips the boot menu which asks which board is in
use. This is useful to allow direct booting of image without user
iteration.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: README: Drop old instructions about secure mode
Otavio Salvador [Fri, 29 Jun 2018 18:19:20 +0000 (15:19 -0300)]
pico-imx7d: README: Drop old instructions about secure mode

Our default config already has the secure mode supported, so the
manual step is not required anymore.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: README: Use dfu-util to flash U-Boot
Otavio Salvador [Fri, 29 Jun 2018 18:19:19 +0000 (15:19 -0300)]
pico-imx7d: README: Use dfu-util to flash U-Boot

The DFU allows a more user friendly use as the details where the
bootloader is installed are abstracted.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Enable auxiliary code support
Otavio Salvador [Fri, 29 Jun 2018 18:19:18 +0000 (15:19 -0300)]
pico-imx7d: Enable auxiliary code support

This enables the "bootaux" command so a firmware can be loaded inside
the M4 MCU.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Allow default fdtfile to be overridden by defconfig
Otavio Salvador [Fri, 29 Jun 2018 18:19:17 +0000 (15:19 -0300)]
pico-imx7d: Allow default fdtfile to be overridden by defconfig

This allow the addition of extra default configurations for each
baseboard, removing the boot menu when user boots for the first time.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Do not override addrmap5
Fabio Estevam [Fri, 29 Jun 2018 18:19:16 +0000 (15:19 -0300)]
pico-imx7d: Do not override addrmap5

The addrmap5 value is the same for the 512MB and 1GB variants,
so there is no need to override it.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Enable CONFIG_ARMV7_BOOT_SEC_DEFAULT
Fabio Estevam [Fri, 29 Jun 2018 18:19:15 +0000 (15:19 -0300)]
pico-imx7d: Enable CONFIG_ARMV7_BOOT_SEC_DEFAULT

Currently the CAAM driver fails to be probed:

caam 30900000.caam: Entropy delay = 3200
caam 30900000.caam: failed to acquire DECO 0
caam 30900000.caam: failed to instantiate RNG

CAAM needs to be initialized in secure world, so enable
CONFIG_ARMV7_BOOT_SEC_DEFAULT to allow the driver to
probe successfully.

Tested with kernel mainline version 4.17.2.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Add Falcon mode support
Fabio Estevam [Fri, 29 Jun 2018 18:19:14 +0000 (15:19 -0300)]
pico-imx7d: Add Falcon mode support

Falcon mode boots the kernel directly from SPL, without loading
the full U-Boot.

As pico-imx7d does not have a GPIO for selecting Falcon versus
normal mode, enter in Falcon mode when the customer selects
the CONFIG_SPL_OS_BOOT option in menuconfig.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Add bootmenu to choose the baseboard
Otavio Salvador [Fri, 29 Jun 2018 18:19:13 +0000 (15:19 -0300)]
pico-imx7d: Add bootmenu to choose the baseboard

Currently the baseboards do not offer a way to autodetect which one is
in use, so we ask the user if no value has been set.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Add support for update SPL using DFU
Fabio Berton [Fri, 29 Jun 2018 18:19:12 +0000 (15:19 -0300)]
pico-imx7d: Add support for update SPL using DFU

Add spl entry on dfu_alt_info to be able to update U-Boot with SPL
for pico imx7d board.

Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Add SPL support
Fabio Estevam [Fri, 29 Jun 2018 18:19:11 +0000 (15:19 -0300)]
pico-imx7d: Add SPL support

Convert pico-imx7d to SPL support.

There are two variants of pico-imx7d SOMs:
- One with 512MB of RAM
- One with 1GB of RAM

The 512MB module contains two Hynix H5TC2G63GFR-PBA.
The 1GB module contains two Hynix H5TC4G63GFR-PBA.

The RAM size is determined in runtime by reading GPIO1_12.

While at it, also add USB Serial Download mode support as it
is very helpful for loading SPL and u-boot.img via imx_usb_loader.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Add fastboot support
Fabio Estevam [Fri, 29 Jun 2018 18:19:10 +0000 (15:19 -0300)]
pico-imx7d: Add fastboot support

fastboot tool is a convenient way to flash the eMMC, so
add support for it.

Examples of usages:

On the pico-imx7d U-Boot prompt:

=> fastboot 0

On the Linux PC connected via USB:

1. Retrieving the U-Boot version

$ sudo fastboot getvar bootloader-version -i 0x0525
bootloader-version: U-Boot 2018.07-rc1-03888-gde846f9
finished. total time: 0.000s

2. Resetting the board

$ sudo fastboot reboot -i 0x0525

(this causes the pico-imx7d to reboot)

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Add default DFU targets
Otavio Salvador [Fri, 29 Jun 2018 18:19:09 +0000 (15:19 -0300)]
pico-imx7d: Add default DFU targets

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Add GPT partitioning support
Otavio Salvador [Fri, 29 Jun 2018 18:19:08 +0000 (15:19 -0300)]
pico-imx7d: Add GPT partitioning support

This allow the use of:

> run setup_emmc

inside of the U-Boot prompt to do the partitioning of the disk.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Fix common distro configuration behavior
Otavio Salvador [Fri, 29 Jun 2018 18:19:07 +0000 (15:19 -0300)]
pico-imx7d: Fix common distro configuration behavior

This sets DISTRO_CONFIG and BOOTCOMMAND, as well as add a `finduuid`
environment helper to allow it to properly work with Yocto Project and
other distributions using extlinux autogenerated configuration files.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agopico-imx7d: Convert to distro config
Fabio Estevam [Fri, 29 Jun 2018 18:19:06 +0000 (15:19 -0300)]
pico-imx7d: Convert to distro config

Instead of keeping a custom environment, use a more generic approach
by switching to disto config.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
5 years agoarm, imx6: add alternative PAD_CTL_DSE constants
Mark Jonas [Thu, 28 Jun 2018 13:56:18 +0000 (15:56 +0200)]
arm, imx6: add alternative PAD_CTL_DSE constants

Not all i.MX6 pads use the same drive strength table. So far only the
240 Ohm to 34 Ohm table was available. Because the constants used have
speaking names it can be confusing to use e.g. PAD_CTL_DSE_48ohm when
according to the reference manual 52 Ohm is the correct value. This
patch adds the 260 Ohm to 37 Ohm table.

For example, the IOMUXC_SW_PAD_CTL_PAD_SD2_CLK register (SD-card clock)
uses the added table.

Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
5 years agocolibri_imx7: improve DDR3 timing
Stefan Agner [Tue, 26 Jun 2018 09:10:52 +0000 (11:10 +0200)]
colibri_imx7: improve DDR3 timing

This makes sure that all Colibri iMX7 modules work with the
same timing. The changes are:
- Disable ODT on read (JEDEC standard JESD79-3F says in chapter
  5.2.3 ODT during Reads: "As the DDR3 SDRAM can not terminate
  and drive at the same time, RTT must be disabled at least half
  a clock cycle..." and also MX7D SABRESD is disabling it)
  This alone fixed memory issues for two Colibri iMX7 1GB modules
  which showed issues before
- Make sure tRFC(min) is at least 260ns
- Make sure tRC is >50.625ns
- tRP needs to be >13.125ns, we can lower from 18.75ns to 15ns
- tFAW is not relevant, leave at reset

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
5 years agocolibri_imx7: add compatible string used in vanilla Linux
Stefan Agner [Tue, 26 Jun 2018 09:10:51 +0000 (11:10 +0200)]
colibri_imx7: add compatible string used in vanilla Linux

Device trees from vanilla Linux do not specify a i.MX 7 specific
compatible string. Make sure to set partitions also when booting
upstream Linux.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
5 years agomx6cuboxi: Move the default environment for all devices
Jon Nettleton [Mon, 25 Jun 2018 10:39:03 +0000 (13:39 +0300)]
mx6cuboxi: Move the default environment for all devices

Previously we had stored the environment right after the
u-boot.img on the disk.  I never liked this because with dtbs
being included and such the image could grow in size.  Instead
we move the environment to be negatively offset from the 1MB
mark.  Almost all our images start at 4MB's, and most standard
images start at 1MB, and all our storage devices are a minimum
1MB.  Therefore we can store env there for all classes of devices
and have plenty of space in case u-boot.img needs to grow.

Signed-off-by: Jon Nettleton <jon@solid-run.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
5 years agoimx: mx7: psci: implement MIGRATE_INFO_TYPE
Stefan Agner [Sun, 24 Jun 2018 19:09:58 +0000 (21:09 +0200)]
imx: mx7: psci: implement MIGRATE_INFO_TYPE

Implement MIGRATE_INFO_TYPE. This informs Linux that no migration
for the trusted operating system is necessary:
  [    0.000000] psci: Trusted OS migration not required

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
5 years agoimx: mx7: psci: support CPU0 on/off
Stefan Agner [Sun, 24 Jun 2018 19:09:57 +0000 (21:09 +0200)]
imx: mx7: psci: support CPU0 on/off

So far psci_cpu_(on|off) only worked for CPU1. Allow to control
CPU0 too. This allows to run the Linux PSCI checker successfully:
  [    2.213447] psci_checker: PSCI checker started using 2 CPUs
  [    2.219107] psci_checker: Starting hotplug tests
  [    2.223859] psci_checker: Trying to turn off and on again all CPUs
  [    2.267191] IRQ21 no longer affine to CPU0
  [    2.293266] Retrying again to check for CPU kill
  [    2.302269] CPU0 killed.
  [    2.311648] psci_checker: Trying to turn off and on again group 0 (CPUs 0-1)
  [    2.354354] IRQ21 no longer affine to CPU0
  [    2.383222] Retrying again to check for CPU kill
  [    2.392148] CPU0 killed.
  [    2.398063] psci_checker: Hotplug tests passed OK
  [    2.402910] psci_checker: Starting suspend tests (10 cycles per state)
  [    2.410019] psci_checker: cpuidle not available on CPU 0, ignoring
  [    2.416452] psci_checker: cpuidle not available on CPU 1, ignoring
  [    2.422757] psci_checker: Could not start suspend tests on any CPU
  [    2.429370] psci_checker: PSCI checker completed

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
5 years agoimx: mx7: psci: provide complete PSCI 1.0 implementation
Stefan Agner [Sun, 24 Jun 2018 19:09:56 +0000 (21:09 +0200)]
imx: mx7: psci: provide complete PSCI 1.0 implementation

PSCI 1.0 require PSCI_VERSION, PSCI_FEATURES, AFFINITY_INFO and
CPU_SUSPEND to be implemented. Commit 0ec3d98f7692 ("mx7_common:
use psci 1.0 instead of 0.1") marked the i.MX 7 implementation to
be PSCI 1.0 compliant but failed to implement those functions.
Especially the missing PSCI version callback was noticeable when
booting Linux:

  [    0.000000] psci: probing for conduit method from DT.
  [    0.000000] psci: PSCIv65535.65535 detected in firmware.
  [    0.000000] psci: Using standard PSCI v0.2 function IDs
  [    0.000000] psci: MIGRATE_INFO_TYPE not supported.
  [    0.000000] psci: SMC Calling Convention v1.0

This patch provides a minimal implementation thereof. With this
patch applied Linux detects PSCI 1.0:

  [    0.000000] psci: probing for conduit method from DT.
  [    0.000000] psci: PSCIv1.0 detected in firmware.
  [    0.000000] psci: Using standard PSCI v0.2 function IDs
  [    0.000000] psci: MIGRATE_INFO_TYPE not supported.
  [    0.000000] psci: SMC Calling Convention v1.0

Fixes: 0ec3d98f7692 ("mx7_common: use psci 1.0 instead of 0.1")
Suggested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
5 years agoimx: mx7: psci: use C code exclusively
Stefan Agner [Sun, 24 Jun 2018 19:09:55 +0000 (21:09 +0200)]
imx: mx7: psci: use C code exclusively

There is no need for assembly in the platform specific part of
the PSCI implementation.

Note that this does not make it a complete PSCI 1.0 implementation
yet but aids to do so in upcoming patches.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
5 years agoARM: PSCI: initialize stack pointer on secondary CPUs
Stefan Agner [Sun, 24 Jun 2018 19:09:54 +0000 (21:09 +0200)]
ARM: PSCI: initialize stack pointer on secondary CPUs

A proper stack is required to safely use C code in psci_arch_cpu_entry.

Fixes: 486daaa618e1 ("arm: psci: add a weak function psci_arch_cpu_entry")
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Acked-by: Patrick DELAUNAY <Patrick.delaunay@st.com>
Tested-by: Patrick DELAUNAY <Patrick.delaunay@st.com>
5 years agoarm: imx7d: cl-som-imx7: sf: support all SF types
Uri Mashiach [Sun, 24 Jun 2018 09:13:10 +0000 (12:13 +0300)]
arm: imx7d: cl-som-imx7: sf: support all SF types

Enable the support for all SPI flash types.

Signed-off-by: Uri Mashiach <uri.mashiach@compulab.co.il>
Signed-off-by: Yaniv Levinsky <yaniv.levinsky@compulab.co.il>
5 years agoi.MX6: engicam: gpr_init can be called only for some architecture
Michael Trimarchi [Sat, 23 Jun 2018 14:10:07 +0000 (16:10 +0200)]
i.MX6: engicam: gpr_init can be called only for some architecture

Fix an invalid usage of the gpr_init function for the imx6ul
architecture

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Acked-by: Jagan Teki <jagan@amarulasolutions.com>