oweals/u-boot.git
5 years agosh: Fix SH4 build with GCC versions without -m4-nofpu
Marek Vasut [Sat, 14 Sep 2019 17:05:38 +0000 (19:05 +0200)]
sh: Fix SH4 build with GCC versions without -m4-nofpu

Pass -m4 instead of -m4-nofpu to GCC versions which do not support
the -m4-nofpu option.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 years agosh: Fix incorrect linking with new binutils
Marek Vasut [Sat, 14 Sep 2019 17:03:32 +0000 (19:03 +0200)]
sh: Fix incorrect linking with new binutils

Since binutils 2.30 , the resulting U-Boot binary was incorrectly linked
against address 0 instead of text base, fix it.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 years agoMAINTAINERS: Change fsl-qoriq, mpc86xx, mpc85xx maintainers
Priyanka Jain [Mon, 9 Sep 2019 11:25:08 +0000 (16:55 +0530)]
MAINTAINERS: Change fsl-qoriq, mpc86xx, mpc85xx maintainers

Change maintainers to Priyanka Jain for fsl-qoriq, mpc85xx

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
Acked-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
5 years agoMerge tag 'efi-2019-10-rc4-4' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Thu, 12 Sep 2019 14:35:46 +0000 (10:35 -0400)]
Merge tag 'efi-2019-10-rc4-4' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi

Pull request for UEFI sub-system for v2019.10-rc4 (4)

Fixes for the EFI_FILE_PROTOCOL:

* correctly iterate over directories
* correct Unicode conversion of file names
* parameter checks

5 years agoMerge tag 'u-boot-rockchip-20190912' of https://gitlab.denx.de/u-boot/custodians...
Tom Rini [Thu, 12 Sep 2019 03:08:34 +0000 (23:08 -0400)]
Merge tag 'u-boot-rockchip-20190912' of https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip

- add idbloader.img target for rockchip tpl+spl;
- usb ehci/ohci: go on process if clock driver don't have clk_enable();
- remove clk_enable() for rockchip clock drivers;
- add boot order for rockpro64

5 years agoefi_loader: parameter checks EFI_FILE_PROTOCOL.SetInfo()
Heinrich Schuchardt [Sun, 8 Sep 2019 09:37:07 +0000 (11:37 +0200)]
efi_loader: parameter checks EFI_FILE_PROTOCOL.SetInfo()

We do not support volume label changes. No parameter checks are needed
here.

When the info for as file is changed the buffer must always contain a file
name.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agodoc: lion_rk3368: use idbloader.img for rk3368
Matwey V. Kornilov [Tue, 3 Sep 2019 16:29:03 +0000 (19:29 +0300)]
doc: lion_rk3368: use idbloader.img for rk3368

Makefile now produces ready-to-deploy idbloader.img file.

Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
5 years agodoc: rockchip: use idbloader.img for rk3288, rk3328, rk3399
Matwey V. Kornilov [Tue, 3 Sep 2019 16:29:02 +0000 (19:29 +0300)]
doc: rockchip: use idbloader.img for rk3288, rk3328, rk3399

Makefile now produces ready-to-deploy idbloader.img file.

Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
5 years agorockchip, Makefile: add idbloader.img target
Matwey V. Kornilov [Tue, 3 Sep 2019 16:29:01 +0000 (19:29 +0300)]
rockchip, Makefile: add idbloader.img target

Many Rockchip platforms require the same u-boot deploy procedure
when TPL and SPL both enabled.

The following examples are taken from doc/README.rockchip
and board/theobroma-systems/lion_rk3368/README:

RK3288:

  ./tools/mkimage -n rk3288 -T rksd -d ./tpl/u-boot-tpl.bin out
  cat ./spl/u-boot-spl-dtb.bin >> out
  sudo dd if=out of=/dev/mmcblk0 seek=64

RK3328:

  ./tools/mkimage -n rk3328 -T rksd -d ./tpl/u-boot-tpl.bin idbloader.img
  cat ./spl/u-boot-spl.bin >> idbloader.img
  sudo dd if=idbloader.img of=/dev/mmcblk0 seek=64

RK3368:

  ./tools/mkimage -n rk3368 -T rksd -d tpl/u-boot-tpl.bin spl-3368.img
  cat spl/u-boot-spl-dtb.bin >> spl-3368.img
  dd if=spl-3368.img of=/dev/sdb seek=64

RK3399:

  ./tools/mkimage -n rk3399 -T rksd -d ./tpl/u-boot-tpl-dtb.bin out
  cat ./spl/u-boot-spl-dtb.bin >> out
  sudo dd if=out of=/dev/sdc seek=64

Here, we introduce generic idbloader.img target
which is the TPL image followed by the SPL binary.

Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
5 years agorockchip: clean makefile for misc.c
Kever Yang [Mon, 2 Sep 2019 07:59:04 +0000 (15:59 +0800)]
rockchip: clean makefile for misc.c

Use obj-$(config) instead of #ifdef $config to make the code looks
clean, and move the misc_init for U-Boot proper only.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
5 years agorockchip: not depends on TPL_BUILD for rk3188 makefile including
Kever Yang [Mon, 2 Sep 2019 07:59:03 +0000 (15:59 +0800)]
rockchip: not depends on TPL_BUILD for rk3188 makefile including

The rk3188/Makefile already depends on !TPL_BUILD, so no need to add
this again in parent Makefile, remove it.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
5 years agorockchip: clk: rk3399: remove clk_enable()
Kever Yang [Wed, 28 Aug 2019 08:23:51 +0000 (16:23 +0800)]
rockchip: clk: rk3399: remove clk_enable()

There is no real driver for clk enable/disable now, and we actually
don't need it now, remove it so that not waste CPU cycles and code size.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
5 years agorockchip: clk: rk3368: remove clk_enable()
Kever Yang [Wed, 28 Aug 2019 08:23:50 +0000 (16:23 +0800)]
rockchip: clk: rk3368: remove clk_enable()

There is no real driver for clk enable/disable now, and we actually
don't need it now, remove it so that not waste CPU cycles and code size.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
5 years agorockchip: clk: rk3328: remove clk_enable()
Kever Yang [Wed, 28 Aug 2019 08:23:49 +0000 (16:23 +0800)]
rockchip: clk: rk3328: remove clk_enable()

There is no real driver for clk enable/disable now, and we actually
don't need it now, remove it so that not waste CPU cycles and code size.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
5 years agorockchip: clk: rk3288: remove clk_enable()
Kever Yang [Wed, 28 Aug 2019 08:23:48 +0000 (16:23 +0800)]
rockchip: clk: rk3288: remove clk_enable()

There is no real driver for clk enable/disable now, and we actually
don't need it now, remove it so that not waste CPU cycles and code size.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
5 years agousb: ohci-generic: don't probe fail if there is no clk_enable() ops
Kever Yang [Wed, 28 Aug 2019 08:23:47 +0000 (16:23 +0800)]
usb: ohci-generic: don't probe fail if there is no clk_enable() ops

Some clock driver do not have a clk_enable() call back, and we should not
treat this as fail in ehci probe like other modules, eg. clk_enabl_bulk()
do not return fail if ret value is '-ENOSYS'

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
5 years agousb: ehci-generic: don't probe fail if there is no clk_enable() ops
Kever Yang [Wed, 28 Aug 2019 08:23:46 +0000 (16:23 +0800)]
usb: ehci-generic: don't probe fail if there is no clk_enable() ops

Some clock driver do not have a clk_enable() call back, and we should not
treat this as fail in ehci probe like other modules, eg. clk_enabl_bulk()
do not return fail if ret value is '-ENOSYS'

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
5 years agorockchip: rk3399: dts: add boot order for rockpro64
Kever Yang [Tue, 27 Aug 2019 03:43:32 +0000 (11:43 +0800)]
rockchip: rk3399: dts: add boot order for rockpro64

The rk3399 rockpro64 board can boot from emmc and sdcard.
TODO: add spiflash as boot device.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
5 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-x86
Tom Rini [Tue, 10 Sep 2019 12:52:00 +0000 (08:52 -0400)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-x86

- Tangier ACPI table fixes
- Support getting high memory size on QEMU x86
- Show UEFI images involved in crash for x86
- EFI loader conventional memory map fix

5 years agoMerge tag 'u-boot-amlogic-20190910' of https://gitlab.denx.de/u-boot/custodians/u...
Tom Rini [Tue, 10 Sep 2019 12:51:17 +0000 (08:51 -0400)]
Merge tag 'u-boot-amlogic-20190910' of https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic

- Add support for dis_u2_susphy_quirk in the xhci-dwc3 driver to fix boot when
a device is plugged only in the OTG capable port for libretech-ac and libretech-cc

5 years agox86: tangier: Use spaces over TABs in ASL code
Andy Shevchenko [Thu, 29 Aug 2019 14:04:21 +0000 (17:04 +0300)]
x86: tangier: Use spaces over TABs in ASL code

For sake of consistency use spaces over TABs in ASL code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agox86: tangier: Fix off-by-one error when preparing CSRT
Andy Shevchenko [Thu, 29 Aug 2019 14:04:20 +0000 (17:04 +0300)]
x86: tangier: Fix off-by-one error when preparing CSRT

Intel iDMA 32-bit controller has 17 bits for the maximum block size value.
Due to nature of the binary number representation the maximum value is
2^17 - 1. The original code misses the latter part in equation.

Fixes: 5e99fde34a77 ("x86: tangier: Populate CSRT for shared DMA controller")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agox86: tangier: Reserve PCI ECAM in motherboard resources
Andy Shevchenko [Thu, 29 Aug 2019 14:04:19 +0000 (17:04 +0300)]
x86: tangier: Reserve PCI ECAM in motherboard resources

Per PCI firmware specification the ACPI has to reserve the memory
which is defined as PCI ECAM.

Fixes: 39665beed6f7 ("x86: tangier: Enable ACPI support for Intel Tangier")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agox86: acpi: Annotate struct acpi_table_header with __packed
Andy Shevchenko [Thu, 29 Aug 2019 14:04:18 +0000 (17:04 +0300)]
x86: acpi: Annotate struct acpi_table_header with __packed

GCC 9.2 starts complaining about possible pointer misalignment of
pointers to the unpacked (alignment=4) structures in the packed
(alignment=1) ones:

  CC      arch/x86/cpu/tangier/acpi.o
arch/x86/cpu/tangier/acpi.c: In function ‘acpi_create_fadt’:
arch/x86/cpu/tangier/acpi.c:22:37: warning: taking address of packed
member of ‘struct acpi_fadt’ may result in an unaligned pointer value
[-Waddress-of-packed-member]
  22 |  struct acpi_table_header *header = &(fadt->header);

  CC      arch/x86/lib/acpi_table.o
arch/x86/lib/acpi_table.c: In function ‘acpi_create_spcr’:
arch/x86/lib/acpi_table.c:366:37: warning: taking address of packed
member of ‘struct acpi_spcr’ may result in an unaligned pointer value
[-Waddress-of-packed-member]
  366 |  struct acpi_table_header *header = &(spcr->header);

Fix the potential issues by annotating embedded structures with
__packed even though they are packed naturally.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: add GCC version number in the commit message]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
5 years agousb: xhci-dwc3: Add support for dis_u2_susphy_quirk
Neil Armstrong [Mon, 9 Sep 2019 18:52:39 +0000 (18:52 +0000)]
usb: xhci-dwc3: Add support for dis_u2_susphy_quirk

This quirk is necessary for the Amlogic GXL SoCs otherwise the
Port 2 PHY doesn't get out of suspend and U-Boot resets the board after:

XHCI timeout on event type 33... cannot recover.
BUG: failure at drivers/usb/host/xhci-ring.c:474/xhci_wait_for_event()!
BUG!

This quirk is also handled in the dwc3 core code, but until the
xhci-dwc3 driver uses the dwc3 core, the quirk must be handled here
to fix USB support on the Amlogic libretech-cc and libretech-ac board
when a device is only plugged in the OTG port.

Cc: Yuri Frolov <crashing.kernel@gmail.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Fixes: dc9cdf859e ("usb: dwc3: Add DWC3 controller driver support")
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agox86: efi_loader: Use efi_add_conventional_memory_map()
Park, Aiden [Tue, 3 Sep 2019 17:43:46 +0000 (17:43 +0000)]
x86: efi_loader: Use efi_add_conventional_memory_map()

Use efi_add_conventional_memory_map() to configure EFI conventional memory
properly with ram_top value. This will give 32-bit mode U-Boot proper
conventional memory regions even if e820 has an entry which is greater than
32-bit address space.

Signed-off-by: Aiden Park <aiden.park@intel.com>
Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
[bmeng: fixed some typos in the commit message]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
5 years agox86: show UEFI images involved in crash
Heinrich Schuchardt [Sun, 25 Aug 2019 17:55:12 +0000 (19:55 +0200)]
x86: show UEFI images involved in crash

If a crash occurs, show the loaded UEFI images to facilitate analysis.

This is an example output:

=> bootefi 0x1000000
Found 0 disks
Hello world of bugs!
Invalid Opcode (Undefined Opcode)
EIP: 0010:[<06ceb06e>] EFLAGS: 00010206
Original EIP :[<fec9906e>]
EAX: 00000000 EBX: 06cec000 ECX: 00000fd0 EDX: 00000001
ESI: 06ced18a EDI: 07d0fe10 EBP: 07fe27a0 ESP: 07d0fde0
 DS: 0018 ES: 0018 FS: 0020 GS: 0018 SS: 0018
CR0: 00000033 CR2: 00000000 CR3: 00000000 CR4: 00000000
DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
DR6: ffff0ff0 DR7: 00000400
Stack:
    0x07d0fde8 : 0x00000000
    0x07d0fde4 : 0x06ced040
--->0x07d0fde0 : 0x07fe27a0
    0x07d0fddc : 0x00010206
    0x07d0fdd8 : 0x00000010
    0x07d0fdd4 : 0x06ceb06e
UEFI image [0x06cea000:0x06cf0fff] pc=0x106e '/bug-i386.efi'
### ERROR ### Please RESET the board ###

With the additional information provided by this patch we know that the
problem occurred 0x106e after the load address of bug-i386.efi.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
5 years agodoc: slimbootloader: Update Linux booting steps on QEMU
Park, Aiden [Thu, 22 Aug 2019 21:31:31 +0000 (21:31 +0000)]
doc: slimbootloader: Update Linux booting steps on QEMU

Add steps to test Linux booting on QEMU with Yocto image.

Signed-off-by: Aiden Park <aiden.park@intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
5 years agox86: qemu: Report high memory in the E820 table
Bin Meng [Thu, 29 Aug 2019 09:53:06 +0000 (02:53 -0700)]
x86: qemu: Report high memory in the E820 table

Now that we are able to get the size of high memory from QEMU,
report its memory range as usable ram.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Aiden Park <aiden.park@intel.com>
5 years agox86: qemu: Support getting high memory size
Bin Meng [Thu, 29 Aug 2019 09:53:05 +0000 (02:53 -0700)]
x86: qemu: Support getting high memory size

At present only size of memory that is below 4GiB is retrieved from
QEMU. Add a function that gets size of memory that is above 4GiB.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Aiden Park <aiden.park@intel.com>
5 years agox86: qemu: Extract getting memory size to a separate routine
Bin Meng [Thu, 29 Aug 2019 09:53:04 +0000 (02:53 -0700)]
x86: qemu: Extract getting memory size to a separate routine

This extracts getting memory size logic in dram_init() to a separate
routine qemu_get_low_memory_size(). No functional changes.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Aiden Park <aiden.park@intel.com>
5 years agox86: Drop weak version board_get_usable_ram_top()
Bin Meng [Thu, 29 Aug 2019 09:53:03 +0000 (02:53 -0700)]
x86: Drop weak version board_get_usable_ram_top()

Every x86 platform provides board_get_usable_ram_top(), hence there
is no need to provide a weak version board_get_usable_ram_top(), not
to mention there is another weak version board_get_usable_ram_top()
in common/board_f.c.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Aiden Park <aiden.park@intel.com>
5 years agox86: acpi: Slightly reduce binary size of ACPI tables for Tangier
Andy Shevchenko [Mon, 26 Aug 2019 01:48:15 +0000 (09:48 +0800)]
x86: acpi: Slightly reduce binary size of ACPI tables for Tangier

Using ACPI predefined macros, such as Zero or One, will reduce a binary
size of resulting ACPI tables.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: manually fixed the conflicts when applying]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
5 years agotools: Add ifwitool to .gitignore
Andy Shevchenko [Mon, 19 Aug 2019 09:09:37 +0000 (12:09 +0300)]
tools: Add ifwitool to .gitignore

Follow up fix to the commit

56bf4f863075 ("x86: Add ifwitool for Intel Integrated Firmware Image")

in order to ignore created binary.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoarm: ti: Add missing "=" from previous fix
Tom Rini [Mon, 9 Sep 2019 14:55:45 +0000 (10:55 -0400)]
arm: ti: Add missing "=" from previous fix

While the original patch to fix a regression in distro boot for mmc on
these platforms had the correct syntax, I broke the change while
applying.  Add back in the missing "=" here so that the syntax is
correct.

Reported-by: Andre Heider <a.heider@gmail.com>
Fixes: 27e0f3bcf075 ("arm: ti: Fix regression in distro boot for mmc")
Signed-off-by: Tom Rini <trini@konsulko.com>
5 years agoefi_loader: check parameters EFI_FILE_PROTOCOL.GetInfo()
Heinrich Schuchardt [Sun, 8 Sep 2019 08:45:31 +0000 (10:45 +0200)]
efi_loader: check parameters EFI_FILE_PROTOCOL.GetInfo()

Check the parameters of EFI_FILE_PROTOCOL.GetInfo() to avoid possible NULL
dereference.

Check the buffer size for EFI_FILE_SYSTEM_INFO.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: volume name in EFI_FILE_PROTOCOL.GetInfo()
Heinrich Schuchardt [Sun, 8 Sep 2019 08:32:54 +0000 (10:32 +0200)]
efi_loader: volume name in EFI_FILE_PROTOCOL.GetInfo()

We cannot determine the volume name in U-Boot. Instead of providing a dummy
volume name in case of EFI_FILE_SYSTEM_INFO and EFI_UNSUPPORTED in case of
EFI_FILE_SYSTEM_VOLUME_LABEL consistently return an empty string.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: EFI_FILE_PROTOCOL rev 2 stub
Heinrich Schuchardt [Sun, 8 Sep 2019 07:35:32 +0000 (09:35 +0200)]
efi_loader: EFI_FILE_PROTOCOL rev 2 stub

The UEFI specification requires to implement version 2 of the
EFI_FILE_PROTOCOL. Provide the missing functions as stubs.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: file size checks
Heinrich Schuchardt [Sat, 7 Sep 2019 21:28:04 +0000 (23:28 +0200)]
efi_loader: file size checks

The file size has to be determined in multiple places. Factor out a common
function.

If on entry into EFI_FILE_PROTOCOL.Read() the current position is beyond
the end of the file, return EFI_DEVICE_ERROR.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: correct reading of directories
Heinrich Schuchardt [Sat, 7 Sep 2019 20:34:07 +0000 (22:34 +0200)]
efi_loader: correct reading of directories

EFI_FILE_PROTOCOL.Read() is used both to read files and directories.

When reaching the end of a directory we always have to return buffer size
zero irrespective of the incoming buffer size. (The described scenario for
a Shim quirk cannot arise because every directory has at least '.' and '..'
as entries.)

Even when the buffer_size is too small multiple times we have to keep a
reference to our last read directory entry.

When we return to the start of the directory via SetPosition() we must
remove the reference to a previously kept directory entry.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: eliminate inline function ascii2unicode()
Heinrich Schuchardt [Sat, 7 Sep 2019 19:05:45 +0000 (21:05 +0200)]
efi_loader: eliminate inline function ascii2unicode()

ascii2unicode() can only convert characters 0x00-0x7f from UTF-8 to UTF-16.
Use utf8_utf16_strcpy() instead.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: EFI_FILE_PROTOCOL.Write() check args
Heinrich Schuchardt [Fri, 6 Sep 2019 19:37:21 +0000 (21:37 +0200)]
efi_loader: EFI_FILE_PROTOCOL.Write() check args

Check the parameters passed to Write():

* cannot write to directories (UEFI SCT 2017, 5.7.3.5.15)
* cannot write to file opened read only (UEFI SCT 2017, 5.7.3.5.16)

Add missing comments.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoMerge tag 'mmc-9-6-2019' of https://gitlab.denx.de/u-boot/custodians/u-boot-mmc
Tom Rini [Mon, 9 Sep 2019 01:14:22 +0000 (21:14 -0400)]
Merge tag 'mmc-9-6-2019' of https://gitlab.denx.de/u-boot/custodians/u-boot-mmc

Bug fixes to mmc_spi
Add Aspeed SD driver
Fix dw_mmc timeout calculation
Fix timeout values passed to mmc_wait_dat0
sdhci dt caps/mask update

[trini: Fix evb-ast2500_defconfig CONFIG_MMC line]
Signed-off-by: Tom Rini <trini@konsulko.com>
5 years agoMerge branch 'master' of git://git.denx.de/u-boot-sh
Tom Rini [Sat, 7 Sep 2019 17:49:39 +0000 (13:49 -0400)]
Merge branch 'master' of git://git.denx.de/u-boot-sh

- Initial DM conversion

5 years agoMerge tag 'rpi-next-2019.10' of https://github.com/mbgg/u-boot
Tom Rini [Fri, 6 Sep 2019 23:49:51 +0000 (19:49 -0400)]
Merge tag 'rpi-next-2019.10' of https://github.com/mbgg/u-boot

- fix mailbox status register used for polling
- fix bcm2835_sdhost to wait long enough for a transfer to complete
- increase kernel image size from 8 MB to 64 MB on arm64
- add support for RPi4
- add prefixes for raspberry pi related stuff to git-mailrc

5 years agogit-mailrc: Add rpi and bcm283x maintainer
Andrei Gherzan [Wed, 24 Jul 2019 14:39:11 +0000 (15:39 +0100)]
git-mailrc: Add rpi and bcm283x maintainer

Add entries for bcm283x and rpi prefix.

Signed-off-by: Andrei Gherzan <andrei@balena.io>
[mb: add commit message]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
5 years agoRPI: Add memory map for bcm2711
Andrei Gherzan [Wed, 24 Jul 2019 14:39:10 +0000 (15:39 +0100)]
RPI: Add memory map for bcm2711

Define the memory map for the BCM2711 based on the dt configuration
available in the Raspberry Pi kernel fork.

Signed-off-by: Andrei Gherzan <andrei@balena.io>
[mb: BCM2838 -> BCM2711]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
5 years agommc: bcm283x: Add support for bcm2711 device in bcm2835_sdhci
Matthias Brugger [Wed, 24 Jul 2019 14:39:09 +0000 (15:39 +0100)]
mmc: bcm283x: Add support for bcm2711 device in bcm2835_sdhci

The bcm2711 has two emmc controllers. The difference is the clocks
they use. Add support for the second emmc controller.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Signed-off-by: Andrei Gherzan <andrei@balena.io>
5 years agoARM: bcm283x: Include definition for additional emmc clock
Andrei Gherzan [Wed, 24 Jul 2019 14:39:08 +0000 (15:39 +0100)]
ARM: bcm283x: Include definition for additional emmc clock

This clock has a different mbox ID so have this included in the relevant
header file.

Signed-off-by: Andrei Gherzan <andrei@balena.io>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
5 years agoRPI: Add entry for Raspberry Pi 4 model B
Andrei Gherzan [Wed, 24 Jul 2019 14:39:07 +0000 (15:39 +0100)]
RPI: Add entry for Raspberry Pi 4 model B

The Raspebrry Pi 4 uses the new revision code scheme as documented by
the foundation. This change adds an entry for this board as well.

Signed-off-by: Andrei Gherzan <andrei@balena.io>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
5 years agoARM: bcm283x: Define configs for RaspberryPi 4
Andrei Gherzan [Wed, 24 Jul 2019 14:39:06 +0000 (15:39 +0100)]
ARM: bcm283x: Define configs for RaspberryPi 4

Define two target configs for Raspberry Pi 4 (32 and 64bit) and the
corresponding BCM2838* configs.

Be aware of the current limitation in firmware which requires an
explicit configuration to force the arm in 64bit mode when the
respective target is used.

Signed-off-by: Andrei Gherzan <andrei@balena.io>
[mb: rename BCM2838 -> BCM2711]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
5 years agoARM: bcm283x: Add BCM283x_BASE define
Matthias Brugger [Wed, 24 Jul 2019 14:39:05 +0000 (15:39 +0100)]
ARM: bcm283x: Add BCM283x_BASE define

Devices of bcm283x have different base address, depending if they are on
bcm2835 or bcm2836/7. Use BCM283x_BASE depending on the SoC you want to
build and only add the offset in the header files.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Signed-off-by: Andrei Gherzan <andrei@balena.io>
5 years agoRPI: Add defconfigs for rpi4 (32/64)
Andrei Gherzan [Wed, 24 Jul 2019 14:39:04 +0000 (15:39 +0100)]
RPI: Add defconfigs for rpi4 (32/64)

This defines a minimum defconfig for each of the two Raspberry Pi 4
variants. One notable difference is that we don't have a embedded dt for
this board given that the fw supplies us with one which we can reuse.
Furthermore, the ram size is not queryable through mbox interface as the
maximum reported size is 1G. The fw patches the dt with the right
memory configuration and uboot uses it as it is. We avoid u-boot
touching this configuration by making sure CONFIG_ARCH_FIXUP_FDT_MEMORY
is deactivated.

Signed-off-by: Andrei Gherzan <andrei@balena.io>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
5 years agorpi: increase SYS_BOOTM_LEN to 64M on ARM64
Bonnans, Laurent [Wed, 31 Jul 2019 11:59:41 +0000 (11:59 +0000)]
rpi: increase SYS_BOOTM_LEN to 64M on ARM64

On AArch64, kernel images are not self-decompressing and easily exceed
the 8MB limit.

Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
5 years agommc: bcm2835-host: Fix wait_transfer_complete
Raul Benet [Thu, 13 Jun 2019 13:59:57 +0000 (14:59 +0100)]
mmc: bcm2835-host: Fix wait_transfer_complete

Function bcm_2835_wait_transfer_complete() is not waiting long enough.
The previous code was claiming to wait for ~1 seconds, but as it depends
on register reads it's time actually varies.
Some cards require wait times of up to ~56 ms to perform
the command 'saveenv' on an EXT4 partition.

Re-implement the loop exit condition to use get_timer() which allows
to specify the wait time in more reliable manner. Set the maximum wait
time to the originally intended 1 second.

Signed-off by: Raul Benet <raul.benet_at_kaptivo.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
5 years agoARM: bcm283x mbox: Fix send status register
Fabian Vogt [Tue, 16 Jul 2019 11:09:47 +0000 (13:09 +0200)]
ARM: bcm283x mbox: Fix send status register

Before we can send a message to the mailbox we have to check that there
is space to do so. Therefore we poll the status register. But up to now
the wrong status register, the one of mailbox 0, was checked. Fix this
by polling the status regiser of mailbox 1.

Signed-off-by: Fabian Vogt <fvogt@suse.com>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
[mb: rename registers and update commit message]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
5 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-samsung
Tom Rini [Fri, 6 Sep 2019 12:04:28 +0000 (08:04 -0400)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-samsung

- ARM: exynos5: Try to boot on mmc2 before mmc0/1

5 years agoMerge tag 'efi-2019-10-rc4-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Fri, 6 Sep 2019 12:04:08 +0000 (08:04 -0400)]
Merge tag 'efi-2019-10-rc4-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi

Pull request for UEFI sub-system for v2019.10-rc4 (3)

This includes the patches from
Pull request for UEFI sub-system for v2019.10-rc4 (2)

Fix UEFI specification compliance issues in the simple network protocol:

* Correctly set and reset the interrupt status.
* Support filling the header in the Transmit() service.
* Correct the checking and setting of the network state.
* Implement the MCastIPtoMAC() service.
* Adjust the simple network protocol unit test.

Fix UEFI specification compliance issues in the protocol.

Fix UEFI specification compliance issues in the simple text output protocol:
* Avoid out of bounds cursor position.
* Do not set illegal screen mode.

Fix UEFI specification compliance issues in the  block IO protocol:
* Check parameters.
* Return correct status code if buffer is unaligned.

Refactor initialization of EFI memory in preparation of support for
> 3GB memory on x86.

5 years agommc: sdhci: Add support for dt caps & caps mask
T Karthik Reddy [Mon, 2 Sep 2019 14:34:31 +0000 (16:34 +0200)]
mmc: sdhci: Add support for dt caps & caps mask

The sdhci capabilities registers can be incorrect. The
sdhci-caps-mask and sdhci-caps dt properties specify which bits of
the registers are incorrect and what their values should be. This
patch makes the sdhci driver use those properties to correct the caps.
Also use "dev_read_u64_default" instead of "dev_read_u32_array" for
caps mask.

Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
5 years agodm: core: Add functions to read 64-bit dt properties
T Karthik Reddy [Mon, 2 Sep 2019 14:34:30 +0000 (16:34 +0200)]
dm: core: Add functions to read 64-bit dt properties

This patch adds functions dev_read_u64_default & dev_read_u64
to read unsigned 64-bit values from devicetree.

Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agodoc: UEFI API documentation
Heinrich Schuchardt [Thu, 5 Sep 2019 18:37:13 +0000 (20:37 +0200)]
doc: UEFI API documentation

Add some more files to the UEFI API documentation.

Correct some Sphinx comments.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: EFI_BLOCK_IO_PROTOCOL.Reset()
Heinrich Schuchardt [Thu, 5 Sep 2019 18:13:46 +0000 (20:13 +0200)]
efi_loader: EFI_BLOCK_IO_PROTOCOL.Reset()

We cannot do anything in EFI_BLOCK_IO_PROTOCOL.Reset() but this does not
justify to return an error.

Let EFI_BLOCK_IO_PROTOCOL.Reset() return EFI_SUCCESS.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: use EFI_PRINT() instead of debug()
Heinrich Schuchardt [Thu, 5 Sep 2019 17:43:17 +0000 (19:43 +0200)]
efi_loader: use EFI_PRINT() instead of debug()

EFI_PRINT() offers indention of debug messages. Adjust the debug messages
of the BLOCK_IO_PROTOCOL.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: parameter checks BLOCK_IO_PROTOCOL
Heinrich Schuchardt [Thu, 5 Sep 2019 17:31:23 +0000 (19:31 +0200)]
efi_loader: parameter checks BLOCK_IO_PROTOCOL

Check parameters of ReadBlocks() and WriteBlocks().

If the buffer size is not a multiple of the block size, we have to return
EFI_BAD_BUFFER_SIZE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: do not set invalid screen mode
Heinrich Schuchardt [Wed, 4 Sep 2019 20:46:13 +0000 (22:46 +0200)]
efi_loader: do not set invalid screen mode

EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetMode() should return EFI_UNDEFINED if a
screen mode is not available.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Alexander Graf <agraf@csgraf.de>
5 years agoefi_loader: cursor positioning
Heinrich Schuchardt [Wed, 4 Sep 2019 19:13:45 +0000 (21:13 +0200)]
efi_loader: cursor positioning

When backspacing in column 0 do no set the column index to ULONG_MAX.
Ensure that the row number is not set to ULONG_MAX even if the row count is
advertised as 0.
Ignore control characters other the 0x08, 0x0a, 0x0d when updating the
column.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: correctly render UsbClass DP nodes as text
Heinrich Schuchardt [Wed, 4 Sep 2019 12:30:41 +0000 (14:30 +0200)]
efi_loader: correctly render UsbClass DP nodes as text

Correct the text representation of UsbClass device path nodes.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: correctly render CD-ROM device path nodes
Heinrich Schuchardt [Wed, 4 Sep 2019 11:56:01 +0000 (13:56 +0200)]
efi_loader: correctly render CD-ROM device path nodes

Correct the name of the partition size component in struct
efi_device_path_cdrom_path.

Render entry, start, and size when converting a CD-ROM device path node to
text.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: correctly render MAC address device path nodes
Heinrich Schuchardt [Wed, 4 Sep 2019 11:32:05 +0000 (13:32 +0200)]
efi_loader: correctly render MAC address device path nodes

If the interface type is greater 1 render all 32 bytes of the MAC address.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: correct text conversion for vendor DP
Heinrich Schuchardt [Wed, 4 Sep 2019 10:52:01 +0000 (12:52 +0200)]
efi_loader: correct text conversion for vendor DP

Vendor device paths may contain data. When converting vendor device paths
to text this binary data has to be rendered.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: Extract adding a conventional memory in separate routine
Park, Aiden [Tue, 3 Sep 2019 17:43:43 +0000 (17:43 +0000)]
efi_loader: Extract adding a conventional memory in separate routine

Adding a conventional memory region to the memory map may require ram_top
limitation and it can be also commonly used. Extract adding a conventional
memory to the memory map in a separate routine for generic use.

Signed-off-by: Aiden Park <aiden.park@intel.com>
Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: implement MCastIPtoMAC
Heinrich Schuchardt [Sun, 1 Sep 2019 15:17:53 +0000 (17:17 +0200)]
efi_loader: implement MCastIPtoMAC

Implement the MCastIPtoMAC service of the simple network protocol.
It converts an multicast IPv4 (or IPv6) address to a multicast Ethernet
address.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: fix status management in network stack
Heinrich Schuchardt [Sun, 1 Sep 2019 13:24:47 +0000 (15:24 +0200)]
efi_loader: fix status management in network stack

The network should start in status EfiSimpleNetworkStopped.

Add and correct status checks in the simple network protocol.

Correct the unit test:
* Shutdown() and Stop() during setup if needed
* invoke Shutdown() before Stop() when tearing down

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: EFI_SIMPLE_NETWORK.Transmit() fill header
Heinrich Schuchardt [Sat, 31 Aug 2019 08:55:29 +0000 (10:55 +0200)]
efi_loader: EFI_SIMPLE_NETWORK.Transmit() fill header

Fill the media header in EFI_SIMPLE_NETWORK.Transmit().
Check that the buffer size is large enough for the header.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_selftest: check EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT
Heinrich Schuchardt [Sat, 31 Aug 2019 08:00:58 +0000 (10:00 +0200)]
efi_selftest: check EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT

Check that when the WaitForPacket event occurs
EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT is set.

Check the return value of Receive().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoefi_loader: interrupts in simple network protocol
Heinrich Schuchardt [Sat, 31 Aug 2019 07:56:30 +0000 (09:56 +0200)]
efi_loader: interrupts in simple network protocol

GetStatus() must clear the interrupt status.
Transmit() should set the TX interrupt.
Receive() should clear the RX interrupt.
Initialize() and Start() should clear the interrupt status.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5 years agoriscv: qemu: enable CONFIG_CMD_BOOTEFI_SELFTEST
Heinrich Schuchardt [Wed, 17 Jul 2019 17:37:31 +0000 (19:37 +0200)]
riscv: qemu: enable CONFIG_CMD_BOOTEFI_SELFTEST

Enable CONFIG_CMD_BOOTEFI_SELFTEST for the QEMU RISC-V boards.

Travis CI QEMU testing has been enabled for qemu-riscv64_defconfig. With
this patch we will test the UEFI sub-system on the board.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoARM: exynos5: Try to boot on mmc2 before mmc0/1
Guillaume GARDET [Wed, 24 Jul 2019 07:10:13 +0000 (09:10 +0200)]
ARM: exynos5: Try to boot on mmc2 before mmc0/1

As stated in commit a61a4a1db009e3e600258551a01b54c4f50ec103 with DM_MMC,
exynos boards now enumarates external SD/MMC slot as mmc2, instead of mmc1
with legacy mode. Moving mmc2 before mmc1/0 restore the previous behavior
of trying external SD/MMC before internal slot.

Signed-off-by: Guillaume GARDET <guillaume.gardet@arm.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Anand Moon <linux.amoon@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Minkyu Kang <mk7.kang@samsung.com>
Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
5 years agodm: mmc_spi: Fix NULL pointer dereference in mmc_spi_bind()
Bin Meng [Sat, 31 Aug 2019 04:15:33 +0000 (21:15 -0700)]
dm: mmc_spi: Fix NULL pointer dereference in mmc_spi_bind()

The mmc_spi driver's priv is not available in its bind phase(). Use
platdata instead.

Fixes: 05e35d429745 ("mmc: mmc_spi: Re-write driver using DM framework")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
5 years agommc: dw_mmc: fix timeout calculate method
Kever Yang [Thu, 29 Aug 2019 07:42:41 +0000 (15:42 +0800)]
mmc: dw_mmc: fix timeout calculate method

There are two cases not been considered:
- use uint for timeout, it will overflow when size bigger than 512KB for
  it *8*1000 at the beginning, but we may use size up to 32MB; The
  'timeout' will overflow if size bigger than 51.2MB after this fix, which
  should be enough for U-Boot;
- The timeout is using clock speed for data rate, but the device may not
  have such high speed, eg. clock is 52MHz while the device write speed may
  be less than 10MB/s, and we may use up to 150MHz clock.

Fix them in this patch, the max timeout is about 6500 when size is 32MB
after fix.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
5 years agoARM: dts: ast2500: Add SDHCI nodes
Eddie James [Thu, 15 Aug 2019 19:29:40 +0000 (14:29 -0500)]
ARM: dts: ast2500: Add SDHCI nodes

Add nodes for the Aspeed SD controllers with their necessary properties.

Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Eddie James <eajames@linux.ibm.com>
5 years agoconfigs: AST2500 EVB: Enable SD controller
Eddie James [Thu, 15 Aug 2019 19:29:39 +0000 (14:29 -0500)]
configs: AST2500 EVB: Enable SD controller

Enable the MMC subsystem and the Aspeed SD controller. Also enable the
use of the device tree for probing the controller.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
5 years agommc: Add Aspeed SD controller driver
Eddie James [Tue, 27 Aug 2019 14:48:03 +0000 (09:48 -0500)]
mmc: Add Aspeed SD controller driver

Add support for the Aspeed SD host controller engine.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
5 years agoclk: aspeed: Add support for SD clock
Eddie James [Thu, 15 Aug 2019 19:29:37 +0000 (14:29 -0500)]
clk: aspeed: Add support for SD clock

Add code to enable the SD clock on the ast2500 SoC.

Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Eddie James <eajames@linux.ibm.com>
5 years agommc: Rename timeout parameters for clarification
Sam Protsenko [Wed, 14 Aug 2019 19:52:51 +0000 (22:52 +0300)]
mmc: Rename timeout parameters for clarification

It's quite hard to figure out time units for various function that have
timeout parameters. This leads to possible errors when one forgets to
convert ms to us, for example. Let's rename those parameters
correspondingly to 'timeout_us' and 'timeout_ms' to prevent such issues
further.

While at it, add time units info as comments to struct mmc fields.

This commit doesn't change the behavior, only renames parameters names.
Buildman should report no changes at all.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@gmail.com>
5 years agommc: Fix timeout values passed to mmc_wait_dat0()
Sam Protsenko [Wed, 14 Aug 2019 19:52:50 +0000 (22:52 +0300)]
mmc: Fix timeout values passed to mmc_wait_dat0()

mmc_wait_dat0() expects timeout argument to be in usec units. But some
overlying functions operate on timeout in msec units. Convert timeout
from msec to usec when passing it to mmc_wait_dat0().

This fixes 'avb' commands on BeagleBoard X15, because next chain was
failing:

    get_partition() -> mmc_switch_part() -> __mmc_switch() ->
    mmc_wait_dat0()

when passing incorrect timeout from __mmc_switch() to mmc_wait_dat0().

Fixes: bb98b8c5c06a ("mmc: During a switch, poll on dat0 if available and check the final status")
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Eugeniu Rosca <rosca.eugeniu@gmail.com>
Tested-by: Eugeniu Rosca <rosca.eugeniu@gmail.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Tested-by: Igor Opaniuk <igor.opaniuk@gmail.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@gmail.com>
5 years agodm: mmc: remove unused U_BOOT_DRIVER(mmc)
Andy Yan [Fri, 31 May 2019 07:44:39 +0000 (15:44 +0800)]
dm: mmc: remove unused U_BOOT_DRIVER(mmc)

When look through the code, I found this bare metal
drives is not used, so remove it.

Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
5 years agoMerge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-net
Tom Rini [Wed, 4 Sep 2019 20:02:03 +0000 (16:02 -0400)]
Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-net

- Assorted CVE fixes
- Other fixes

5 years agonet: nfs: remove superfluous packed attribute
Heinrich Schuchardt [Mon, 2 Sep 2019 22:05:05 +0000 (00:05 +0200)]
net: nfs: remove superfluous packed attribute

With GCC 9.2.1 net/nfs.c leads to multiple errors of type
address-of-packed-member.

net/nfs.c: In function ‘rpc_req’:
net/nfs.c:199:18: error: taking address of packed member of
‘struct rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
  199 |  p = (uint32_t *)&(rpc_pkt.u.call.data);
      |                  ^~~~~~~~~~~~~~~~~~~~~~
net/nfs.c: In function ‘nfs_readlink_reply’:
net/nfs.c:631:46: error: taking address of packed member of
‘struct rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
  631 |    nfs3_get_attributes_offset(rpc_pkt.u.reply.data);
      |                               ~~~~~~~~~~~~~~~^~~~~
  LD      drivers/block/built-in.o
net/nfs.c: In function ‘nfs_read_reply’:
net/nfs.c:692:46: error: taking address of packed member of
‘struct rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
  692 |    nfs3_get_attributes_offset(rpc_pkt.u.reply.data);
      |                               ~~~~~~~~~~~~~~~^~~~~

struct rpc_t is only used as local variable. It is naturally packed. So
there is no need for the attribute packed.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agonet: nfs: remove superfluous conversions
Heinrich Schuchardt [Mon, 2 Sep 2019 21:55:32 +0000 (23:55 +0200)]
net: nfs: remove superfluous conversions

rpc_pkt.u.call.data is an array of uint32_t. There is no need to convert
it to uint32_t *.

memcpy() expects void * as it 1st and 2nd argument. There is no point in
converting pointers to char * before passing them to memcpy().

In ntohl(data[1]) != 0 calling ntohl() is superfluous. If the value is
zero, does not depend on the byte order.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agoenv: net: U_BOOT_ENV_CALLBACKs should not depend on CMD_NET
Heinrich Schuchardt [Mon, 2 Sep 2019 08:10:34 +0000 (10:10 +0200)]
env: net: U_BOOT_ENV_CALLBACKs should not depend on CMD_NET

Some environment variables are relevant for networking. For these
U_BOOT_ENV_CALLBACKs have been defined. When the corresponding environment
variable is updated the callback updates the state of the network
sub-system.

In the UEFI subsystem we can use the network even if CONFIG_CMD_NET is not
defined.

Let the usage of the U_BOOT_ENV_CALLBACKs depend on CONFIG_NET and not on
CONFIG_CMD_NET.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agoCVE-2019-14196: nfs: fix unbounded memcpy with a failed length check at nfs_lookup_reply
liucheng (G) [Thu, 29 Aug 2019 13:48:02 +0000 (13:48 +0000)]
CVE-2019-14196: nfs: fix unbounded memcpy with a failed length check at nfs_lookup_reply

This patch adds a check to rpc_pkt.u.reply.data at nfs_lookup_reply.

Signed-off-by: Cheng Liu <liucheng32@huawei.com>
Reported-by: Fermín Serna <fermin@semmle.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agoCVE-2019-14195: nfs: fix unbounded memcpy with unvalidated length at nfs_readlink_reply
liucheng (G) [Thu, 29 Aug 2019 13:47:54 +0000 (13:47 +0000)]
CVE-2019-14195: nfs: fix unbounded memcpy with unvalidated length at nfs_readlink_reply

This patch adds a check to rpc_pkt.u.reply.data at nfs_readlink_reply.

Signed-off-by: Cheng Liu <liucheng32@huawei.com>
Reported-by: Fermín Serna <fermin@semmle.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agoCVE-2019-14194/CVE-2019-14198: nfs: fix unbounded memcpy with a failed length check...
liucheng (G) [Thu, 29 Aug 2019 13:47:48 +0000 (13:47 +0000)]
CVE-2019-14194/CVE-2019-14198: nfs: fix unbounded memcpy with a failed length check at nfs_read_reply

This patch adds a check to rpc_pkt.u.reply.data at nfs_read_reply.

Signed-off-by: Cheng Liu <liucheng32@huawei.com>
Reported-by: Fermín Serna <fermin@semmle.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agoCVE: nfs: fix stack-based buffer overflow in some nfs_handler reply helper functions
liucheng (G) [Thu, 29 Aug 2019 13:47:40 +0000 (13:47 +0000)]
CVE: nfs: fix stack-based buffer overflow in some nfs_handler reply helper functions

This patch adds a check to nfs_handler to fix buffer overflow for CVE-2019-14197,
CVE-2019-14200, CVE-2019-14201, CVE-2019-14202, CVE-2019-14203 and CVE-2019-14204.

Signed-off-by: Cheng Liu <liucheng32@huawei.com>
Reported-by: Fermín Serna <fermin@semmle.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agoCVE: net: fix unbounded memcpy of UDP packet
liucheng (G) [Thu, 29 Aug 2019 13:47:33 +0000 (13:47 +0000)]
CVE: net: fix unbounded memcpy of UDP packet

This patch adds a check to udp_len to fix unbounded memcpy for
CVE-2019-14192, CVE-2019-14193 and CVE-2019-14199.

Signed-off-by: Cheng Liu <liucheng32@huawei.com>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Reported-by: Fermín Serna <fermin@semmle.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agonet: make net_random_ethaddr() more random
Michael Walle [Tue, 27 Aug 2019 08:13:52 +0000 (10:13 +0200)]
net: make net_random_ethaddr() more random

The net_random_ethaddr() tries to get some entropy from different
startup times of a board. The seed is initialized with get_timer() which
has only a granularity of milliseconds. We can do better if we use
get_ticks() which returns the raw timer ticks. Using this we have a
higher chance of getting different values at startup.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agonet: macb: Fix rx buffer cache handling
Stefan Roese [Mon, 26 Aug 2019 07:18:11 +0000 (09:18 +0200)]
net: macb: Fix rx buffer cache handling

With commit c6d07bf440bc ("net/macb: increase RX buffer size for GEM")
ethernet support does not work any more with d-cache enabled on the
AT91SAM. The reason is, that MACB_RX_BUFFER_SIZE was changed from 4096
to 128 but this change was not refected in the rx_buffer flush and
invalidate functions, as these also use this macro.

This patch now fixes this by calculating the rx buffer size correctly
again in those functions. With this change, ethernet works again
reliably on my AT91SAM board.

Signed-off-by: Stefan Roese <sr@denx.de>
Fixes: c6d07bf440bc ("net/macb: increase RX buffer size for GEM")
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Eugen Hristev <eugen.hristev@microchip.com>
Cc: Anup Patel <anup.patel@wdc.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agonet: designware: drop compatible altr, socfpga-stmmac
Ralph Siemsen [Mon, 19 Aug 2019 18:43:13 +0000 (14:43 -0400)]
net: designware: drop compatible altr, socfpga-stmmac

The same compatible = "altr,socfpga-stmmac" appears in both
drivers/net/designware.c and drivers/net/dwmac_socfgpa.c,
creating ambiguity in which driver will be bound.

For Intel/Altera SoC devices, dwmac_socfpga.c is the correct driver.
So drop the compatible string from designware.c.

Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agoRevert "net: macb: Fixed reading MII_LPA register"
Bin Meng [Wed, 14 Aug 2019 10:29:42 +0000 (03:29 -0700)]
Revert "net: macb: Fixed reading MII_LPA register"

This reverts commit 1b0c9914cc75d1570359181ebd493cd5746cb0ed.

Commit 1b0c9914cc75 ("net: macb: Fixed reading MII_LPA register")
causes 100Mbps does not work any more with SiFive FU540 GEM on the
HiFive Unleashed board. Revert it.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>