]> git.dujemihanovic.xyz Git - u-boot.git/log
u-boot.git
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 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 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 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 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>
5 years agonetwork: set timeline for CONFIG_DM_ETH conversion
Heinrich Schuchardt [Fri, 9 Aug 2019 22:10:37 +0000 (00:10 +0200)]
network: set timeline for CONFIG_DM_ETH conversion

The driver model has been supported for network drivers since 2015. It is
time to convert the remaining boards. Set July 2020 as a timeline.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agodrivers: net: fsl_enet_mdio: fix missing terminator in PCI ID array
Alex Marginean [Wed, 7 Aug 2019 16:33:22 +0000 (19:33 +0300)]
drivers: net: fsl_enet_mdio: fix missing terminator in PCI ID array

It was missing in the original submission and not having it in place causes
issues with probing of PCI devices.

Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agonet: dwc_et_qos: update weak function board_interface_eth_init
Patrick Delaunay [Thu, 1 Aug 2019 09:29:03 +0000 (11:29 +0200)]
net: dwc_et_qos: update weak function board_interface_eth_init

Align the board and driver prototype for board_interface_eth_init
to avoid execution issue (the interface_type parameter is defined
as int or phy_interface_t).

To have a generic weak function (it should be reused by other driver)
I change the prototype to use directly udevice.

This prototype is added in netdev.h to allow compilation check
and avoid warning when compiling with W=1 on file
board/st/stm32mp1/stm32mp1.c

warning: no previous prototype for 'board_interface_eth_init'\
[-Wmissing-prototypes]
     int board_interface_eth_init(int interface_type, ....
         ^~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agonet: dwc_eth_qos: Change eqos_ops function to static
Patrick Delaunay [Thu, 1 Aug 2019 09:29:02 +0000 (11:29 +0200)]
net: dwc_eth_qos: Change eqos_ops function to static

This patch solves many warnings when compiling with W=1:
warning: no previous prototype for '....' [-Wmissing-prototypes]

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-By: Ramon Fried <rfried.dev@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agodrivers: net: pfe_eth: undefined return value
Heinrich Schuchardt [Tue, 30 Jul 2019 22:00:51 +0000 (00:00 +0200)]
drivers: net: pfe_eth: undefined return value

Do not use random value from stack as return value of pfe_phy_write().

Indicated by cppcheck.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agotest: dm_mdio: avoid out of bounds access
Heinrich Schuchardt [Tue, 30 Jul 2019 21:49:00 +0000 (23:49 +0200)]
test: dm_mdio: avoid out of bounds access

SANDBOX_PHY_REG_CNT is not an allowable index for the array
u16 reg[SANDBOX_PHY_REG_CNT].

Identified by cppcheck.

Fixes: b47edf8069cc ("test: dm_mdio: add a 2nd register to the emulated PHY")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agonet: mvpp2: support setting hardware addresses from ethernet core
Matt Pelland [Tue, 30 Jul 2019 13:40:24 +0000 (09:40 -0400)]
net: mvpp2: support setting hardware addresses from ethernet core

mvpp2 already has support for setting MAC addresses but this
functionality was not exposed to the ethernet core. This commit exposes
this functionality so that MAC address assignments stored in U-Boot's
environment are correctly applied before Linux boots.

Signed-off-by: Matt Pelland <mpelland@starry.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agoarm: dts: Set custom names for cp110 master/slave MDIO buses
Alex Marginean [Thu, 25 Jul 2019 09:33:20 +0000 (12:33 +0300)]
arm: dts: Set custom names for cp110 master/slave MDIO buses

Implicitly Marvell MDIO driver uses DT node names for devices, but in this
case that is not unique.  Set MDIO device names for master/slave to
cpm/cps.

Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agodrivers: net: add marvell MDIO driver
Alex Marginean [Thu, 25 Jul 2019 09:33:19 +0000 (12:33 +0300)]
drivers: net: add marvell MDIO driver

This patch adds a separate driver for the MDIO interface of the
Marvell Ethernet controllers based on driver model. There are two
reasons to have a separate driver rather than including it inside
the MAC driver itself:
  *) The MDIO interface is shared by all Ethernet ports, so a driver
     must guarantee non-concurrent accesses to this MDIO interface. The
     most logical way is to have a separate driver that handles this
     single MDIO interface, used by all Ethernet ports.
  *) The MDIO interface is the same between the existing mv643xx_eth
     driver and the new mvneta/mvpp2 driver. Even though it is for now
     only used by the mvneta/mvpp2 driver, it will in the future be
     used by the mv643xx_eth driver as well.

This driver supports SMI IEEE for 802.3 Clause 22 and XSMI for IEEE
802.3 Clause 45.

This patch also adds device tree binding for marvell MDIO driver.

Signed-off-by: Ken Ma <make@marvell.com>
Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agodoc: bindings: add mdio.txt describing generic MDIO properties
Alex Marginean [Thu, 25 Jul 2019 09:33:18 +0000 (12:33 +0300)]
doc: bindings: add mdio.txt describing generic MDIO properties

Adds a binding document for mdio.  A notable deviation from corresponding
Linux binding is the introduction of device-name optional property, which
can be used to name MDIO buses.  Two reset optional properties described
by Linux binding are also not present as they don't seem to be used in
U-Boot at this time.

Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agonet: mdio-uclass: name MDIO according to device-name property if preset
Alex Marginean [Thu, 25 Jul 2019 09:33:17 +0000 (12:33 +0300)]
net: mdio-uclass: name MDIO according to device-name property if preset

Use the optional property device-name to name the MDIO bus.  This works
around limitations with using the DT node name on devices such as
Armada-8040, which integrates two cp100 cores, both featuring MDIOs at the
same relative offsets and with the same DT node names.
The concept was originally proposed by Marvell as a custom property called
mdio-name specific to Marvell driver.  This patch uses the more generic
property device-name and moves this into MDIO class code so other can use
it as well.

Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoconfigs: sandbox: enable PCAP capture cmd
Ramon Fried [Thu, 18 Jul 2019 18:43:32 +0000 (21:43 +0300)]
configs: sandbox: enable PCAP capture cmd

Enable CONFIG_CMD_PCAP for testing PCAP capture.

Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agodoc: pcap: add pcap cmd documentation
Ramon Fried [Thu, 18 Jul 2019 18:43:31 +0000 (21:43 +0300)]
doc: pcap: add pcap cmd documentation

Add documentation for new "pcap" command.

Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agonet: introduce packet capture support
Ramon Fried [Thu, 18 Jul 2019 18:43:30 +0000 (21:43 +0300)]
net: introduce packet capture support

Add support for capturing ethernet packets and storing
them in memory in PCAP(2.4) format, later to be analyzed by
any PCAP viewer software (IE. Wireshark)

This feature greatly assist debugging network issues such
as detecting dropped packets, packet corruption etc.

Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Alex Marginean <alexm.osslist@gmail.com>
Tested-by: Alex Marginean <alexm.osslist@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agodrivers/fsl-mc: Create Kconfig file to manage driver specific configs better
Florinel Iordache [Wed, 15 May 2019 09:09:21 +0000 (09:09 +0000)]
drivers/fsl-mc: Create Kconfig file to manage driver specific configs better

Create drivers/net/fsl-mc/Kconfig and move fsl-mc specific configs
from arch/arm/cpu/armv8/fsl-layerscape/Kconfig to this new Kconfig

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agodrivers: net: driver for MDIO muxes controlled over I2C
Alex Marginean [Tue, 16 Jul 2019 08:21:17 +0000 (11:21 +0300)]
drivers: net: driver for MDIO muxes controlled over I2C

This driver is used for MDIO muxes driven over I2C.  This is currently
used on Freescale LS1028A QDS board, on which the physical MDIO MUX is
controlled by an on-board FPGA which in turn is configured through I2C.

Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoRevert "drivers: net: driver for MDIO muxes controlled over I2C"
Joe Hershberger [Tue, 3 Sep 2019 23:14:06 +0000 (18:14 -0500)]
Revert "drivers: net: driver for MDIO muxes controlled over I2C"

This reverts commit d9a9174fa5687521035b2ec82cce86cdcf4f36e6.

5 years agonet: mdio: Clarify code flow Covarity 244085 & 244090
Joe Hershberger [Tue, 30 Jul 2019 21:51:41 +0000 (16:51 -0500)]
net: mdio: Clarify code flow Covarity 244085 & 244090

Document that the lack of breaks is intentional.

Series-to: u-boot
Series-cc: ti

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agonet: Fix Covarity Defect 244093
Joe Hershberger [Tue, 30 Jul 2019 19:49:56 +0000 (14:49 -0500)]
net: Fix Covarity Defect 244093

Don't allow unterminated strings

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
5 years agoMerge tag 'arc-for-2019.10-rc4' of https://gitlab.denx.de/u-boot/custodians/u-boot-arc
Tom Rini [Tue, 3 Sep 2019 16:40:50 +0000 (12:40 -0400)]
Merge tag 'arc-for-2019.10-rc4' of https://gitlab.denx.de/u-boot/custodians/u-boot-arc

These are some very late changes mostly required to get 64-bit
division working on ARC boards.

For that we had to import missing parts of libgcc and add compiler
flags to EMSDP which otherwise used very simple profile for compliation.

And while at it another fix for EM SDP initialization is inluded as well.

5 years agoarc: emsdp: Add more platform-specific compiler options
Alexey Brodkin [Mon, 2 Sep 2019 12:02:14 +0000 (15:02 +0300)]
arc: emsdp: Add more platform-specific compiler options

Even though EM SDP is FPGA-based board and different FPGA
images (known as .bit-files) are awailable for the board still
there's a common subset of options we may rely on for all configs.

These are:
 * Normalizer
 * Swap instructions
 * Simple multiplier
 * Barrel-shifter
 * Floating-point unit
 * Shorter instructions (code density)

This among other improvements allows to compile code with
64-bit divisions, see [1].

[1] https://patchwork.ozlabs.org/patch/1156541/

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
5 years agoarc: libgcc: Import __udivdi3 & __udivmoddi4 to allow 64-bit division
Alexey Brodkin [Mon, 2 Sep 2019 09:19:15 +0000 (12:19 +0300)]
arc: libgcc: Import __udivdi3 & __udivmoddi4 to allow 64-bit division

As reported by Kever here [1] we were unable to compile 64-bit division
code due to missing definition of __udivdi3().

Import its implementation and __udivmoddi4() as its direct dependency
from today's libgcc [2].

[1] https://patchwork.ozlabs.org/patch/1146845/
[2] https://github.com/gcc-mirror/gcc/commit/5d8723600bc0eed41226b5a6785bc02a053b45d5

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
5 years agoarc: emsdp: Add initialization of PSRAM
Alexey Brodkin [Thu, 18 Jul 2019 12:51:25 +0000 (15:51 +0300)]
arc: emsdp: Add initialization of PSRAM

If the "Page Mode" is not enabled on the device,
read operations from PSRAM may result in incorrect data.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
5 years agoMerge tag 'for-v2019.10-v2' of https://gitlab.denx.de/u-boot/custodians/u-boot-i2c
Tom Rini [Tue, 3 Sep 2019 11:16:05 +0000 (07:16 -0400)]
Merge tag 'for-v2019.10-v2' of https://gitlab.denx.de/u-boot/custodians/u-boot-i2c

i2c bugfixes for 2019.10 take 2
- i2c: mxc: add CONFIG_CLK support
  If CONFIG_CLK is enabled use clk framework for clock settings.

5 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-riscv
Tom Rini [Tue, 3 Sep 2019 03:21:44 +0000 (23:21 -0400)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-riscv

- Skip unavailable hart in the get_count().
- fu540 set serial env from otp.
- fu540 add mmc0 as a boot target device.
- Update fix_rela_dyn and add absolute reloc addend.
- Andestech PLIC driver will skip unavailable hart.
- Support Andestech V5L2 cache driver.

5 years agoriscv: cache: use CCTL to flush d-cache
Rick Chen [Wed, 28 Aug 2019 10:46:11 +0000 (18:46 +0800)]
riscv: cache: use CCTL to flush d-cache

Use CCTL command to do d-cache write back
and invalidate instead of fence.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoriscv: dts: move out AE350 L2 node from cpus node
Rick Chen [Wed, 28 Aug 2019 10:46:10 +0000 (18:46 +0800)]
riscv: dts: move out AE350 L2 node from cpus node

When L2 node exists inside cpus node, uclass_get_device
can not parse L2 node successfully. So move it outside
from cpus node.

Also add tag-ram-ctl and data-ram-ctl attributes for
v5l2 cache controller driver. This can adjust timing
by requirement from dtb to improve performance.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoriscv: cache: Flush L2 cache before jump to linux
Rick Chen [Wed, 28 Aug 2019 10:46:09 +0000 (18:46 +0800)]
riscv: cache: Flush L2 cache before jump to linux

Flush and disable L2 cache in dcache_disable()
which will be called in cleanup_before_linux()
before jump to linux.

The sequence will be preferred as below:
L1 flush -> L1 disable -> L2 flush -> L2 disable

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoriscv: ax25: add imply v5l2 cache controller
Rick Chen [Thu, 29 Aug 2019 02:30:13 +0000 (10:30 +0800)]
riscv: ax25: add imply v5l2 cache controller

Select the v5l2 UCLASS_CACHE driver for ax25.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoriscv: ae350: use the v5l2 driver to configure the cache
Rick Chen [Wed, 28 Aug 2019 10:46:07 +0000 (18:46 +0800)]
riscv: ae350: use the v5l2 driver to configure the cache

Find the UCLASS_CACHE driver to configure the cache controller's
settings.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agodm: cache: add v5l2 cache controller driver
Rick Chen [Wed, 28 Aug 2019 10:46:06 +0000 (18:46 +0800)]
dm: cache: add v5l2 cache controller driver

Add a v5l2 cache controller driver that is usually found on
Andes RISC-V ae350 platform. It will parse the cache settings
from the dtb.

In this version tag and data ram control timing can be adjusted
by the requirement from the dtb.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agodm: cache: Add enable and disable ops for sandbox and test
Rick Chen [Wed, 28 Aug 2019 10:46:05 +0000 (18:46 +0800)]
dm: cache: Add enable and disable ops for sandbox and test

Add cache enable and disable ops for test coverage.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agodm: cache: Add enable and disable ops for cache uclass
Rick Chen [Wed, 28 Aug 2019 10:46:04 +0000 (18:46 +0800)]
dm: cache: Add enable and disable ops for cache uclass

Add cache enable/disable ops to the DM cache uclass driver

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoriscv: andes_plic: init plic by scanning each cpu node
Rick Chen [Wed, 21 Aug 2019 03:26:50 +0000 (11:26 +0800)]
riscv: andes_plic: init plic by scanning each cpu node

Initialize plic driver by ofnode_for_each_subnode() instead
of cpu_get_count().

This way can support to skip some harts which maybe marked as
unavailable, but the cpu node exists indeed.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoriscv: update fix_rela_dyn
Marcus Comstedt [Sun, 11 Aug 2019 12:45:29 +0000 (14:45 +0200)]
riscv: update fix_rela_dyn

The addend is now added for RELOC_TYPE relocs.  Also, changed the loop
structure so that all the R_RISCV_RELATIVE relocs are not required to
be at the beginning of the list.

Signed-off-by: Marcus Comstedt <marcus@mc.pp.se>
Cc: Rick Chen <rick@andestech.com>
5 years agoriscv: tools: Handle addend to absolute reloc in prelink-riscv
Marcus Comstedt [Sun, 11 Aug 2019 09:29:57 +0000 (11:29 +0200)]
riscv: tools: Handle addend to absolute reloc in prelink-riscv

Previously the handling of R_RISCV_32 and R_RISCV_64 would simply
insert the value of the symbol and ignore any addend.  However, there
exist relocs where the addend is non-zero:

0000000080250900 R_RISCV_64        efi_runtime_services+0x0000000000000068
0000000080250910 R_RISCV_64        efi_runtime_services+0x0000000000000038
0000000080250920 R_RISCV_64        efi_runtime_services+0x0000000000000018
0000000080250930 R_RISCV_64        efi_runtime_services+0x0000000000000020
0000000080250980 R_RISCV_64        efi_runtime_services+0x0000000000000048
0000000080250990 R_RISCV_64        efi_runtime_services+0x0000000000000050
00000000802509a0 R_RISCV_64        efi_runtime_services+0x0000000000000058
0000000080250940 R_RISCV_64        systab+0x0000000000000030
0000000080250950 R_RISCV_64        systab+0x0000000000000040
0000000080250960 R_RISCV_64        systab+0x0000000000000050
0000000080250970 R_RISCV_64        systab+0x0000000000000060

In these cases the addend needs to be added to the symbol value to get
the correct value for the reloc.

Signed-off-by: Marcus Comstedt <marcus@mc.pp.se>
Cc: Rick Chen <rick@andestech.com>
5 years agosifive-fu540: config: Add mmc0 as a boot target device
Alistair Francis [Fri, 16 Aug 2019 18:00:00 +0000 (11:00 -0700)]
sifive-fu540: config: Add mmc0 as a boot target device

Add the mmc0 device as a BOOT_TARGET_DEVICES.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoriscv: sifive: fu540: set serial environment variable from otp
Sagar Shrikant Kadam [Mon, 12 Aug 2019 14:57:40 +0000 (07:57 -0700)]
riscv: sifive: fu540: set serial environment variable from otp

This patch sets the serial# environment variable by reading the
board serial number from the OTP memory region.

Signed-off-by: Sagar Shrikant Kadam <sagar.kadam@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
5 years agoriscv: cpu: Skip unavailable hart in the get_count() op
Bin Meng [Thu, 8 Aug 2019 07:52:08 +0000 (00:52 -0700)]
riscv: cpu: Skip unavailable hart in the get_count() op

We should not count in hart that is marked as not available in the
device tree in riscv_cpu_get_count().

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Rick Chen <rick@andestech.com>
Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
5 years agosh: r2dplus: Switch to DM PCI driver
Marek Vasut [Sat, 31 Aug 2019 16:25:21 +0000 (18:25 +0200)]
sh: r2dplus: Switch to DM PCI driver

Add DT entry for the DM PCI driver, update board configs
and drop ad-hoc board init code for the PCI bus. Instead,
let the DM PCI driver initialize and operate the hardware.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 years agopci: sh7751: Convert to DM and DT probing
Marek Vasut [Sun, 1 Sep 2019 13:56:41 +0000 (15:56 +0200)]
pci: sh7751: Convert to DM and DT probing

Convert the SH7751 PCI driver to DM and add DT probing.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
5 years agosh: r2dplus: Enable OF control
Marek Vasut [Sat, 31 Aug 2019 16:27:58 +0000 (18:27 +0200)]
sh: r2dplus: Enable OF control

Enable OF control for SH4 R2Dplus board. This is necessary, because
the PCI uclass is designed in a way that makes it depend on DT and
disallows instanciating devices without DT (e.g. with platdata).

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 years agosh: r2dplus: Enable DM
Marek Vasut [Sat, 31 Aug 2019 16:03:40 +0000 (18:03 +0200)]
sh: r2dplus: Enable DM

Enable driver model support for SH4 R2Dplus board. Thus far, no
drivers are bound via the DM. The PCI drivers have yet to be
converted to DM_PCI.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 years agosh: Fix OF_SEPARATE support
Marek Vasut [Sun, 1 Sep 2019 16:05:03 +0000 (18:05 +0200)]
sh: Fix OF_SEPARATE support

If the OF_SEPARATE is enabled, the DT is appended past the _end symbol.
The current code however clears BSS very early, which overwrites the DT
blob with zeroes. Moreover, the early code relocates U-Boot into RAM to
the correct location, but does not relocate the DT.

This patch adds code to relocate the DT and avoids clearing BSS too
early, thus addressing both problems with OF_SEPARATE on SH.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 years agosh: tmu: Fix SH4 TCNT0 offset
Marek Vasut [Sat, 31 Aug 2019 15:33:06 +0000 (17:33 +0200)]
sh: tmu: Fix SH4 TCNT0 offset

Fix the offset of TCNT0 register, which is 0xc on SH4.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 years agodm: core: Decouple DM from DT
Marek Vasut [Sat, 31 Aug 2019 16:03:28 +0000 (18:03 +0200)]
dm: core: Decouple DM from DT

Some of the DM functions depend on OF_CONTROL, which is incorrect.
DM and DT are orthogonal. Add macro guards around such functions to
avoid compiling them in when DM is enabled, while OF_CONTROL is not.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Simon Glass <sjg@chromium.org>