oweals/u-boot.git
4 years agorpi: fix dram bank initialization
Matthias Brugger [Thu, 5 Dec 2019 17:53:13 +0000 (18:53 +0100)]
rpi: fix dram bank initialization

To update the dram bank information from device-tree we use
fdtdec_decode_ram_size() which expectes the the size-cells and
address-cells to be defined in the memory node. For normal system RAM
these values are defined in the root node. When the values differ from
the default values defined in the spec, we can end up with wrong RAM
bank information.

Switch to the "standard" way to update the RAM bank information to
avoid this.

Fixes: 9de5b89e4c ("rpi4: enable dram bank initialization")

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
4 years agoMerge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-riscv
Tom Rini [Tue, 10 Dec 2019 02:53:23 +0000 (21:53 -0500)]
Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-riscv

- Increase stack size to avoid a stack overflow during distro boot.
- Add hifive-unleashed-a00.dts for SIFIVE FU540.
- Add OF_SEPARATE support for SIFIVE FU540.
- Add SPL support for Andes AX25 AE350.
- Improve U-Boot SPL / OpenSBI smp boot flow for RISC-V.

4 years agospl: opensbi: wait for ack from secondary harts before entering OpenSBI
Lukas Auer [Sun, 8 Dec 2019 22:28:52 +0000 (23:28 +0100)]
spl: opensbi: wait for ack from secondary harts before entering OpenSBI

At the start, OpenSBI relocates itself to its link address. If the link
address ranges of U-Boot SPL and OpenSBI overlap, the relocation can
lead to code corruption if a hart is still running U-Boot SPL during
relocation. To avoid this problem, the main hart is specified as the
preferred boot hart to perform the relocation. This fixes the code
corruption problems based on the assumption that since the main hart
schedules the secondary harts to enter OpenSBI, it will be the last to
enter OpenSBI. However it was reported that this assumption is not
always correct.

To make sure the assumption always holds true, wait for all secondary
harts to acknowledge the call-function request before entering OpenSBI
on the main hart.

Reported-by: Rick Chen <rick@andestech.com>
Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Rick Chen <rick@andestech.com>
Tested-by: Rick Chen <rick@andestech.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoriscv: add option to wait for ack from secondary harts in smp functions
Lukas Auer [Sun, 8 Dec 2019 22:28:51 +0000 (23:28 +0100)]
riscv: add option to wait for ack from secondary harts in smp functions

Add a wait option to smp_call_function() to wait for the secondary harts
to acknowledge the call-function request. The request is considered to
be acknowledged once each secondary hart has cleared the corresponding
IPI.

As part of the call-function request, the secondary harts invalidate the
instruction cache after clearing the IPI. This adds a delay between
acknowledgment (clear IPI) and fulfillment (call function) of the
request. We want to use the acknowledgment to be able to judge when the
request has been completed. Remove the delay by clearing the IPI after
cache invalidation and just before calling the function from the
request.

Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Rick Chen <rick@andestech.com>
Tested-by: Rick Chen <rick@andestech.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoriscv: add functions for reading the IPI status
Lukas Auer [Sun, 8 Dec 2019 22:28:50 +0000 (23:28 +0100)]
riscv: add functions for reading the IPI status

Add the function riscv_get_ipi() for reading the pending status of IPIs.
The supported controllers are Andes' Platform Level Interrupt Controller
(PLIC), the Supervisor Binary Interface (SBI), and SiFive's Core Local
Interruptor (CLINT).

Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Rick Chen <rick@andestech.com>
4 years agospl: opensbi: specify main hart as preferred boot hart
Lukas Auer [Sun, 8 Dec 2019 22:28:49 +0000 (23:28 +0100)]
spl: opensbi: specify main hart as preferred boot hart

OpenSBI uses a relocation lottery to determine the hart to relocate
OpenSBI to its link address. In the U-Boot SPL boot flow, the main hart
schedules the secondary harts to enter OpenSBI before doing so itself.
One of the secondary harts will therefore always be the winner of the
relocation lottery. This is problematic if the link address ranges of
OpenSBI and U-Boot SPL overlap. OpenSBI will be relocated and therefore
overwrite U-Boot SPL while some harts may still run it, leading to code
corruption.

Avoid this problem by specifying the main hart as the preferred boot
hart to perform the OpenSBI relocation. The main hart will be the last
hart to enter OpenSBI, relocation can therefore occur safely.

The boot hart field was added to version 2 of the OpenSBI FW_DYNAMIC
info structure. The header file include/opensbi.h is synchronized with
include/sbi/fw_dynamic.h from the OpenSBI project to update the info
structure. The header file is recent as of commit
7a13beb21326 ("firmware: Add preferred boot HART field in struct
fw_dynamic_info").

Reported-by: Rick Chen <rick@andestech.com>
Suggested-by: Anup Patel <Anup.Patel@wdc.com>
Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Rick Chen <rick@andestech.com>
Tested-by: Rick Chen <rick@andestech.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agodoc: update AX25-AE350 RISC-V documentation
Rick Chen [Thu, 14 Nov 2019 05:52:30 +0000 (13:52 +0800)]
doc: update AX25-AE350 RISC-V documentation

Add descriptions about U-Boot SPL feature and how to build and run.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
4 years agoriscv: dts: Add #address-cells and #size-cells in nor node
Rick Chen [Thu, 14 Nov 2019 05:52:29 +0000 (13:52 +0800)]
riscv: dts: Add #address-cells and #size-cells in nor node

Those are required for cfi-flash driver to get correct address information.
Also modify size description correctly.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
4 years agoriscv: dts: Support four cores SMP
Rick Chen [Thu, 14 Nov 2019 05:52:28 +0000 (13:52 +0800)]
riscv: dts: Support four cores SMP

Add CPU2 and CPU3 information in cpus node
to support four cores SMP booting.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
4 years agoriscv: Fix clear bss loop in the start-up code
Rick Chen [Thu, 14 Nov 2019 05:52:27 +0000 (13:52 +0800)]
riscv: Fix clear bss loop in the start-up code

For RV64, it will use sd instruction to clear t0
register, and the increament will be 8 bytes. So
if the difference between__bss_strat and __bss_end
was not 8 bytes aligned, the clear bss loop will
overflow and acks like system hang.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
4 years agospl: cache: Allow cache drivers in SPL
Rick Chen [Thu, 14 Nov 2019 05:52:26 +0000 (13:52 +0800)]
spl: cache: Allow cache drivers in SPL

When ax25-ae350 try to enable v5l2 cache
driver in SPL configuration, it need this
option for cache support in SPL.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
4 years agoriscv: ax25: cache: Add SPL_RISCV_MMODE for SPL
Rick Chen [Thu, 14 Nov 2019 05:52:25 +0000 (13:52 +0800)]
riscv: ax25: cache: Add SPL_RISCV_MMODE for SPL

The mcache_ctl csr only can be manipulated in M mode.
Add SPL_RISCV_MMODE for U-Boot SPL to control cache
operation.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
4 years agoriscv: andes_plic: Fix some wrong configurations
Rick Chen [Thu, 14 Nov 2019 05:52:24 +0000 (13:52 +0800)]
riscv: andes_plic: Fix some wrong configurations

Fix two wrong settings of andes plic driver as below:

1. Fix wrong pending register base definition.
2. Declaring the en variable in enable_ipi() as unsigned int instead of
   int can help to fix wrong plic enabling setting in RV64.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
4 years agoriscv: ax25-ae350: Use generic memory size setup
Rick Chen [Thu, 14 Nov 2019 05:52:23 +0000 (13:52 +0800)]
riscv: ax25-ae350: Use generic memory size setup

To get memory size from device tree instead of
get_ram_size(). This can avoid memory access fault
in U-Boot proper after PMP configurations in OpenSBI.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
4 years agoriscv: ax25-ae350: add SPL configuration
Rick Chen [Thu, 14 Nov 2019 05:52:22 +0000 (13:52 +0800)]
riscv: ax25-ae350: add SPL configuration

This patch provides four configurations which can support U-Boot SPL
to boot from RAM or FLASH and then boot FIT image including OpenSBI
FW_DYNAMIC firmware and U-Boot proper images from RAM or MMC boot devices.

With ae350_rv[32|64]_spl_defconfigs:

U-Boot SPL will be loaded by gdb or FSBL and runs in RAM in machine mode
and then load FIT image from RAM device on AE350.

With ae350_rv[32|64]_spl_xip_defconfigs:

U-Boot SPL can be burned into SPI flash and run in flash in machine mode
and then load FIT image from SPI flash or MMC device on AE350.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
4 years agoriscv: ax25: add SPL support
Rick Chen [Thu, 14 Nov 2019 05:52:21 +0000 (13:52 +0800)]
riscv: ax25: add SPL support

The U-Boot SPL will boot in M mode and load the FIT image which
include OpenSBI and U-Boot proper images. After loading progress,
it will jump to OpenSBI first and then U-Boot proper which will
run in S mode.

Also remove V5L2_CACHE due to U-Boot SPL code size consideration.
Without this concern, it can be enable manually for performance.

Signed-off-by: Rick Chen <rick@andestech.com>
Cc: KC Lin <kclin@andestech.com>
Cc: Alan Kao <alankao@andestech.com>
4 years agoUse dts support from U-Boot via OF_SEPARATE instead of depending from opensbi.
Rick Chen [Wed, 4 Dec 2019 06:52:46 +0000 (14:52 +0800)]
Use dts support from U-Boot via OF_SEPARATE instead of depending from opensbi.

This would help to make the necessary changes in drivers and device trees
in U-Boot tree itself. This feature would also be helpful to not pass
dtb during opensbi builds.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Rick Chen <rick@andestech.com>
4 years agoriscv: dts: Add hifive-unleashed-a00 dts from Linux
Jagan Teki [Mon, 18 Nov 2019 11:29:40 +0000 (16:59 +0530)]
riscv: dts: Add hifive-unleashed-a00 dts from Linux

Sync the hifive-unleashed-a00 dts from Linux with
below commit details:

commit <2993c9b04e616df0848b655d7202a707a70fc876> ("riscv: dts: HiFive
Unleashed: add default chosen/stdout-path")

Idea is to periodically sync the dts from Linux instead of
tweaking internal changes one after another, so better not
add any intermediate changes in between. This would help to
maintain the dts files easy and meaningful since we are
reusing device tree files from Linux.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
4 years agoriscv: increase stack size to avoid a stack overflow during distro boot
Lukas Auer [Sun, 20 Oct 2019 18:53:47 +0000 (20:53 +0200)]
riscv: increase stack size to avoid a stack overflow during distro boot

This fixes a problem, where booting Linux using distro boot will
sometimes lead to an invalid instruction exception on the main hart. The
secondary harts are not affected and boot Linux successfully. The root
cause of this problem is a stack overflow on the main hart.

With distro boot, the current default stack size of 8KiB on RISC-V is
not sufficient and will cause a stack overflow. The stacks are allocated
sequentially. In the case of a stack overflow the stack of the main hart
can reach into that of another hart and be corrupted.

The stack overflow previously did not cause any problems, because only
stack frames, which are not used anymore since the hart enters Linux,
were corrupted. Starting with GCC 9, the stack usage has decreased. Now,
only the most recent stack frame overflows into the stack of a secondary
hart and is corrupted. The illegal instruction exception is caused by
the secondary hart overwriting the return address in the stack frame of
the main hart with an address that does not include valid code.

Increase the default stack size of each hart to 16KiB to avoid this
problem.

Reported-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Tested-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Rick Chen <rick@andestech.com>
4 years agoARM: DRA7: Fixup DSP OPP_HIGH clock rate on DRA76P/DRA77P SoCs
Suman Anna [Mon, 2 Dec 2019 22:34:21 +0000 (16:34 -0600)]
ARM: DRA7: Fixup DSP OPP_HIGH clock rate on DRA76P/DRA77P SoCs

The commit 1b42ab3eda8a ("ARM: DRA7: Fixup DSPEVE, IVA and GPU clock
frequencies based on OPP") added the core logic to update the kernel
device-tree blob to adjust the DSP, IVA and GPU DPLL clocks based on
a one-time OPP choice selected in U-Boot for most of the DRA7xx/AM57xx
family of SoCs.

The DSPs on DRA76xP/DRA77xP SoCs (DRA76x ACD package SoCs) though
provide a higher performance and can run at a higher clock frequency
of 850 MHz at OPP_HIGH instead of 750 MHz. Fix up the logic to use the
correct clock rates on these SoCs. Note that this higher clock rate is
not applicable to other Jacinto 6 Plus SoCs (DRA75xP/DRA74xP SoCs or
AM574x SoCs) that follow the ABZ package.

Signed-off-by: Suman Anna <s-anna@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
4 years agoMerge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-net
Tom Rini [Mon, 9 Dec 2019 18:48:22 +0000 (13:48 -0500)]
Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-net

4 years agocmd: pxe: Increase maximum path length
Ben Wolsieffer [Thu, 28 Nov 2019 05:07:08 +0000 (00:07 -0500)]
cmd: pxe: Increase maximum path length

On NixOS, cross compiled kernels have long suffixes that cause them to
exceed the current maximum path length. The PXE/TFTP max path length is
used for extlinux.conf support as well, which is where this problem
usually manifest's itself.

Signed-off-by: Ben Wolsieffer <benwolsieffer@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agoconfigs: j721e_evm_a72_defconfig: Enable DMA and Ethernet
Vignesh Raghavendra [Wed, 4 Dec 2019 16:47:25 +0000 (22:17 +0530)]
configs: j721e_evm_a72_defconfig: Enable DMA and Ethernet

Enable configs related to DMA and Ethernet so as to support networking at
U-Boot prompt

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
4 years agoarm: dts: k3-j721e-common-proc-board: Add DMA and CPSW related DT nodes
Vignesh Raghavendra [Wed, 4 Dec 2019 16:47:24 +0000 (22:17 +0530)]
arm: dts: k3-j721e-common-proc-board: Add DMA and CPSW related DT nodes

Add DT nodes related to DMA and CPSW to -u-boot.dtsi to get networking
up on J721e EVM.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
4 years agonet: ti: am65-cpsw-nuss: Add new compatible for J721e
Vignesh Raghavendra [Wed, 4 Dec 2019 16:47:23 +0000 (22:17 +0530)]
net: ti: am65-cpsw-nuss: Add new compatible for J721e

Add new compatible to handle J721e SoC

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
4 years agonet: ti: am65-cpsw-nuss: Rework RX flow ID handling
Vignesh Raghavendra [Wed, 4 Dec 2019 16:47:22 +0000 (22:17 +0530)]
net: ti: am65-cpsw-nuss: Rework RX flow ID handling

Get flow ID information for RX DMA channel using dma_get_cfg() interface
instead of reading from DT. This is required in order to avoid DT update
whenever there is change in the range of flow ID allocated to the host.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
4 years agodma: ti: k3-udma: Implement dma_get_cfg() interface
Vignesh Raghavendra [Wed, 4 Dec 2019 16:47:21 +0000 (22:17 +0530)]
dma: ti: k3-udma: Implement dma_get_cfg() interface

Implement dma_get_cfg() interface to pass flow id information for DMA
clients to use. This is needed because on K3 SoCs, CPSW (ethernet) and
UDMA (DMA provider) support "flows" within a given RX DMA channel. This
allows different network packets to be segregated while using same RX
DMA channel. In order for basic ethernet to work, CPSW slave must be
aware of the flow ID allocated for the RX channel by the DMA driver.
This interface allows CPSW to query flow ID from DMA provider and
configure it in CPSW HW.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
4 years agodma: Introduce dma_get_cfg() interface
Vignesh Raghavendra [Wed, 4 Dec 2019 16:47:20 +0000 (22:17 +0530)]
dma: Introduce dma_get_cfg() interface

Sometimes, there would be a need to exchange data between DMA provider
and DMA client which are very specific to DMA driver of the SoC/platform
and are not generic enough to be put into struct dma. Therefore, introduce
dma_get_cfg() interface to get DMA provider specific data from client
device. Clients can use unique configuration ID flags to get different
configuration data from DMA driver.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
4 years agonet: ftgmac100: align RX/TX descriptors on ARCH_DMA_MINALIGN
Cédric Le Goater [Thu, 28 Nov 2019 12:37:04 +0000 (13:37 +0100)]
net: ftgmac100: align RX/TX descriptors on ARCH_DMA_MINALIGN

Fixes: e766849713ff ("net: ftgmac100: convert the RX/TX descriptor arrays")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: fsl_enetc: register internal MDIO bus
Alex Marginean [Mon, 25 Nov 2019 15:57:27 +0000 (17:57 +0200)]
drivers: net: fsl_enetc: register internal MDIO bus

This bus is used to access internal SoC PHYs.  These PHYs are configured
by the ENETC driver directly, but it's useful to have command line access
to this MDIO to debug the system especially when using new external PHYs.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: fsl_enetc_mdio: return with time-out if HW is stuck
Alex Marginean [Thu, 14 Nov 2019 16:58:47 +0000 (18:58 +0200)]
drivers: net: fsl_enetc_mdio: return with time-out if HW is stuck

On some boards MDIO may get stuck if it detects echo on the line.  This is
a know hardware issue, there is a board fix for it.  In case we're running
on a board that doesn't have the fix, we don't want to loop here forever
and freeze U-Boot.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: fsl_enetc: move PCS and PHY config to probe
Alex Marginean [Thu, 14 Nov 2019 16:58:46 +0000 (18:58 +0200)]
drivers: net: fsl_enetc: move PCS and PHY config to probe

This reduces the time needed to establish a link as we don't reset the link
each time the interface is used.  Our Link capabilities do not change at
run-time so there is no need to re-apply PHY configuration each time.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: fsl_enetc: Add 2.5Gbps to supported link speeds
Alex Marginean [Thu, 14 Nov 2019 16:58:45 +0000 (18:58 +0200)]
drivers: net: fsl_enetc: Add 2.5Gbps to supported link speeds

The original code enabled link speeds up to 1Gbps, but the interface can
go up to 2.5G, enable that speed to in PHY AN mask.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: fsl_enetc: use the new MDIO DM helper functions
Alex Marginean [Mon, 25 Nov 2019 15:15:13 +0000 (17:15 +0200)]
drivers: net: fsl_enetc: use the new MDIO DM helper functions

Uses the new dm_eth_phy_connect helper to connect to the PHY to simplify
the code.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: mdio-uclass: add dm_eth_phy_connect helper function
Alex Marginean [Mon, 25 Nov 2019 15:15:12 +0000 (17:15 +0200)]
net: mdio-uclass: add dm_eth_phy_connect helper function

The function connects an ethernet device to a PHY using DT information.
This API is only available for eth devices with an associated device tree
node.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: mdio-uclass: rename arguments of dm_mdio_phy_connect for clarity
Alex Marginean [Mon, 25 Nov 2019 15:15:11 +0000 (17:15 +0200)]
net: mdio-uclass: rename arguments of dm_mdio_phy_connect for clarity

Renamed dm_mdio_phy_connect arguments dev to mdiodev and addr to phyaddr
for a bit more clarity and consistency with the following patches.
Also use NULL instead of 0 on error return path.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: tftp: Fix too small block size
Andre Przywara [Sat, 23 Nov 2019 17:58:59 +0000 (17:58 +0000)]
net: tftp: Fix too small block size

Commit b618b3707633 ("net: Convert CONFIG_TFTP_BLOCKSIZE to Kconfig")
accidentally set the default *option* TFTP block size to 512 bytes, even
though the comment in the code says that this is a terrible choice. Most
boards didn't define the symbol before, so they got the default block size
of 1468 bytes before, but now use 512 bytes, which is also the fallback.
This leads to both abysmal performance and a lot of hashes printed
on the screen (one character for every 5K), which is both annoying and
slow over serial links.

Set the default block size in Kconfig back to the value it had before.

This improves TFTP performance from 2.8 MB/s to 6.9 MB/s on a Pine64.

Fixes: b618b3707633 ("net: Convert CONFIG_TFTP_BLOCKSIZE to Kconfig")
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: fsl_enetc: use XFI, USXGMII interface type macros
Alex Marginean [Thu, 14 Nov 2019 16:28:38 +0000 (18:28 +0200)]
drivers: net: fsl_enetc: use XFI, USXGMII interface type macros

Apply 10G PCS init for USXGMII, XFI interface types.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodoc: bindings: Aquantia PHY node binding
Alex Marginean [Thu, 14 Nov 2019 16:28:37 +0000 (18:28 +0200)]
doc: bindings: Aquantia PHY node binding

A couple of optional properties have been introduced for Aquantia PHY
allowing the driver to set up wiring related configuration points that
are otherwise driven by firmware.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodoc: bindings: add bindings document for PHY nodes
Alex Marginean [Thu, 14 Nov 2019 16:28:36 +0000 (18:28 +0200)]
doc: bindings: add bindings document for PHY nodes

It defines that PHY nodes must be children on MDIO bus nodes and defines
the only required property in U-Boot, reg.  This property along with the
example provided are copied over from Linux.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: aquantia: check system interface too when checking for link up
Alex Marginean [Thu, 14 Nov 2019 16:28:35 +0000 (18:28 +0200)]
drivers: net: aquantia: check system interface too when checking for link up

In some cases the link on the system interface of the aquantia PHY comes up
after the link on line interface.  The link state loop only checks the line
side, which may result in first packet sent being lost.
Use aquantia_link_is_up instead, which checks both system and line side on
gen 2/3 PHYs to avoid losing the 1st packet.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: aquantia: set SMBus addr based on DT property
Alex Marginean [Thu, 14 Nov 2019 16:28:34 +0000 (18:28 +0200)]
drivers: net: aquantia: set SMBus addr based on DT property

Aquantia PHYs have a SMBus interface mostly used for debug.  The addresses
on this interface are normally set up by PHY firmware, but depending on the
board they may end up not being unique.  Add an optional DT property used
to change SMBus address if needed.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: aquantia: set MDI reversal based on DT property
Alex Marginean [Thu, 14 Nov 2019 16:28:33 +0000 (18:28 +0200)]
drivers: net: aquantia: set MDI reversal based on DT property

MDI pins up to the RJ45 connector may be reversed on the board and the
default PHY configuration applied by firmware may or may not match that.
Add an optional DT property to configure MDI reversal for this case.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: aquantia: set up SI protocol based on interface type
Alex Marginean [Thu, 14 Nov 2019 16:28:32 +0000 (18:28 +0200)]
drivers: net: aquantia: set up SI protocol based on interface type

If PHY is not ready for data by the time _config is called, reconfigure the
PHY system interface to use the proper protocol based on phydev->interface,
just in case the defaults set by PHY firmware don't match current
configuration.

Signed-off-by: Florin Laurentiu Chiculita <florinlaurentiu.chiculita@nxp.com>
Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: aquantia: add PHY generation information
Alex Marginean [Thu, 14 Nov 2019 16:28:31 +0000 (18:28 +0200)]
drivers: net: aquantia: add PHY generation information

Uses the data field in phy_driver structure to identify the PHY generation.
This is useful for custom configuration as non-generic PHY registers are
not 100% compatible between generations.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodrivers: net: aquantia: use XFI, USXGMII interface types
Alex Marginean [Thu, 14 Nov 2019 16:28:30 +0000 (18:28 +0200)]
drivers: net: aquantia: use XFI, USXGMII interface types

The PHY supports XFI and USXGMII, the notable difference being that USX AN
is enabled for USXGMII.  Legacy code uses XGMII for any 10G proto and
detects whether USX AN should be enabled or not using a PHY status
register.  Keep that functionality too, so we don't break existing drivers.

Signed-off-by: Razvan Ionut Cirjan <razvanionut.cirjan@nxp.com>
Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agoinclude: phy: add data field for private driver data
Alex Marginean [Thu, 14 Nov 2019 16:28:29 +0000 (18:28 +0200)]
include: phy: add data field for private driver data

This is useful to carry custom information between the driver structure
associated with a specific HW and the driver code.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agoinclude: phy: define XFI and USXGMII interface types
Alex Marginean [Thu, 14 Nov 2019 16:28:28 +0000 (18:28 +0200)]
include: phy: define XFI and USXGMII interface types

Drivers currently use XGMII for XFI and USXGMII and, where needed, use
other information to identify the actual protocol on the board.  With these
two defined drivers can now rely on DT phy-mode property.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: fix switch vendor name
Anatolij Gustschin [Sat, 26 Oct 2019 23:14:41 +0000 (01:14 +0200)]
net: phy: fix switch vendor name

Fix vendor name in MV88E61xx option description.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: mv88e61xx: register phy_driver struct for 88E6071
Anatolij Gustschin [Sat, 26 Oct 2019 23:14:40 +0000 (01:14 +0200)]
net: phy: mv88e61xx: register phy_driver struct for 88E6071

Support probing and init for 88E6071 switch.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: mv88E61xx: fix ENERGY_DET init for mv88E6071
Anatolij Gustschin [Sat, 26 Oct 2019 23:14:39 +0000 (01:14 +0200)]
net: phy: mv88E61xx: fix ENERGY_DET init for mv88E6071

On mv88E6071 the 'EDet' field offset, width and sense control
bits are different, adjust the driver to init the PHY control
register as needed. This fixes not working link detection and
tftp transfers.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: mv88e61xx: add CPU port parameter init for 88E6071
Anatolij Gustschin [Sat, 26 Oct 2019 23:14:38 +0000 (01:14 +0200)]
net: phy: mv88e61xx: add CPU port parameter init for 88E6071

On 88E6071 chip the port status register bit field offsets
for duplex and link bits differ. Extend the driver to use
88E6071 specific offset values. The width of bit fields for
speed status differ, too. Adapt for proper port speed
detection on 88E6071.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: mv88e61xx: rework to enable detection of 88E6071 devices
Anatolij Gustschin [Sat, 26 Oct 2019 23:14:37 +0000 (01:14 +0200)]
net: phy: mv88e61xx: rework to enable detection of 88E6071 devices

Extend the driver to init switch register offsets from variables
instead of compile time macros and enable detection of 88E6071 and
compatible devices. Ethernet transfer (e.g. tftp) does not work yet,
so enable the registration of the 'indirect mii' bus for easier PHY
register access by 'mii' command.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: micrel: make sure the factory test bit is cleared
Nicolas Ferre [Wed, 23 Oct 2019 10:46:44 +0000 (10:46 +0000)]
net: phy: micrel: make sure the factory test bit is cleared

The KSZ8081 PHY has a factory test mode which is set at the de-assertion
of the reset line based on the RXER (KSZ8081RNA/RND) or TXC
(KSZ8081MNX/RNB) pin. If a pull-down is missing, or if the pin has a
pull-up, the factory test mode should be cleared by manually writing a 0
(according to the datasheet).
Create another ksz8081_config function to handle this case.

Suggested-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: eth-uclass: ignore unavailable devices
Michael Walle [Mon, 21 Oct 2019 23:03:10 +0000 (01:03 +0200)]
net: eth-uclass: ignore unavailable devices

device_probe() may fail in which case the seq_id will be -1. Don't
display these devices during startup. While this is only a cosmetic
change, the return value of eth_initialize() will also change to the
actual number of available devices. The return value is only used in
spl_net to decide whether there are any devices to boot from. So
returning only available devices is also more correct in that case.

Signed-off-by: Michael Walle <michael@walle.cc>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: aquantia: wait for phy init sequence to finish
Florin Chiculita [Mon, 14 Oct 2019 14:27:07 +0000 (17:27 +0300)]
net: phy: aquantia: wait for phy init sequence to finish

Aquantia quad-phys may take longer to initialize. This commit adds
a polling mechanism for a global alarm bit that tells if phy init
sequence is completed.

Signed-off-by: Florin Chiculita <florinlaurentiu.chiculita@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: macb: let miiphy_read/_write pass arbitrary addresses
Josef Holzmayr [Wed, 2 Oct 2019 19:22:52 +0000 (21:22 +0200)]
net: macb: let miiphy_read/_write pass arbitrary addresses

This allows passing arbitrary addresses through macb_miiphy_read and
macb_miiphy_write, therefore enabling the mii command to access
all mdio bus devices instead of only the defined phy.

Signed-off-by: Josef Holzmayr <holzmayr@rsi-elektrotechnik.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: macb: explicitly pass phy_adr to mdio read and write
Josef Holzmayr [Wed, 2 Oct 2019 19:22:51 +0000 (21:22 +0200)]
net: macb: explicitly pass phy_adr to mdio read and write

To support accessing arbitrary addresses the mii/mdio bus it is
necessary that the macb_mdio_read and macb_mdio_write functions
do not implicitly use the address of the connected phy.

The function signature is extended according to the Linux kernel
equivalent.

Signed-off-by: Josef Holzmayr <holzmayr@rsi-elektrotechnik.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: Increase link up delay in genphy_update_link()
Stefan Roese [Mon, 30 Sep 2019 08:26:42 +0000 (10:26 +0200)]
net: phy: Increase link up delay in genphy_update_link()

I've noticed that in most cases when genphy_update_link() is called, the
ethernet driver (mt7628-eth in this case) fails with the first ethernet
packets. Resulting in a timeout of the first tftp command. Increasing
the delay in the link check look from 1 to 50 ms and moving it below the
BMSR register read fixes this issue, resulting in a stable ethernet
traffic, even after initial link autonogotiation.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Weijie Gao <weijie.gao@mediatek.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agocmd: mdio/mii: add Kconfig help and allow break dependency
Ramon Fried [Fri, 13 Sep 2019 15:25:03 +0000 (18:25 +0300)]
cmd: mdio/mii: add Kconfig help and allow break dependency

* Add Kconfig help describing the purpose of each command.
* Add CONFIG_CMD_MDIO so it could be selected individually, as
  it doesn't depend on the mii command.
* Add Kconfig imply to mii to automatically select the mdio
  command.

Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: rtl8169: Support RTL-8168c/8111c
Thierry Reding [Wed, 11 Sep 2019 17:19:06 +0000 (19:19 +0200)]
net: rtl8169: Support RTL-8168c/8111c

This version of the RTL-8168 chip can be found on some add-in cards sold
by CSL-Computer GmbH & Co. KG. The chip isn't special in any way, but it
needs to have the ChipCmd register programmed after the DMA descriptors
have been set up, so make sure that happens by adding an entry to the
chip information table.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: mvpp2: MVPP2 now needs MVMDIO
Nevo Hed [Thu, 15 Aug 2019 22:08:45 +0000 (18:08 -0400)]
net: mvpp2: MVPP2 now needs MVMDIO

Changes to mvpp2.c require the MVMDIO module which in turn uses
DM_MDIO.

Signed-off-by: Nevo Hed <nhed+github@starry.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: mvpp2: use new MVMDIO driver
Nevo Hed [Thu, 15 Aug 2019 22:08:44 +0000 (18:08 -0400)]
net: mvpp2: use new MVMDIO driver

This commit ports mvpp2 to use the recently introduced Marvell MDIO
(MVMDIO) driver.  It removes direct interaction with the SMI & XSMI
busses.  This commit is based in part on earlier work by
Ken Ma <make@marvell.com> in Marvell's own downstream repo:
https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/c81dc39.

The above refrenced work was based on an MVMDIO implementation that
never made it into U-Boot.  With this patch the mvpp2 driver switches
to use the new MVMDIO driver that is based on a more universal
mdio-uclass implementation.

Signed-off-by: Nevo Hed <nhed+github@starry.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agoarm: dts: armada-cp110-*dtsi: add xmdio nodes
Nevo Hed [Thu, 15 Aug 2019 22:08:43 +0000 (18:08 -0400)]
arm: dts: armada-cp110-*dtsi: add xmdio nodes

Based on upstream-linux
See https://github.com/torvalds/linux/commit/f66b2aff.

However made the XSMI register window 0x16 (22) bytes per my reading
of the functional spec.  Similar commits in Marvels own repo bump it
to 0x200 (512) bytes but I did not see the reasoning for that.

https://github.com/MarvellEmbeddedProcessors/u-boot-marvell/commit/4d932b4.

Also added device-name attributes to prevent ambiguity in the `mdio`
command.

Signed-off-by: Nevo Hed <nhed+github@starry.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: mvpp2: mark phy as invalid in case of missing appropriate driver
Grzegorz Jaszczyk [Thu, 15 Aug 2019 22:08:42 +0000 (18:08 -0400)]
net: mvpp2: mark phy as invalid in case of missing appropriate driver

If the phy doesn't match with any existing u-boot drivers, the phy
framework will connect it to the generic one which uid ==
0xffffffff. In this case, act as if the phy wouldn't be declared in
dts. Otherwise, in case of 3310 (for which the driver doesn't exist)
the link is marked as always down. Removing phy entry from dts in case
of 3310 is not a good option because it is required for the
phy_fw_down procedure.

This patch fixes the issue with the link always down on MCBIN board.

nhed: added NULL deref test.

Signed-off-by: Grzegorz Jaszczyk <jaz@semihalf.com>
Reviewed-by: Igal Liberman <igall@marvell.com>
Tested-by: Igal Liberman <igall@marvell.com>
Signed-off-by: Nevo Hed <nhed+github@starry.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: mvpp2x: fix traffic stuck after PHY start error
Stefan Chulski [Thu, 15 Aug 2019 22:08:41 +0000 (18:08 -0400)]
net: mvpp2x: fix traffic stuck after PHY start error

Issue:
- Network stuck if autonegotion fails.

Issue root cause:

- When autonegotiation fails during port open procedure, the packet
  processor configuration does not finish and open procedure exits
  with error.
- However, this doesn't prevent u-boot network framework from
  calling send and receive procedures.
- Using transmit and receive functions of misconfigured packet
  processor will cause traffic to get stuck.

Fix:

- Continue packet processor configuration even if autonegotiation
  fails.  Only error message is triggered in this case.
- Exit transmit and receive functions if there is no PHY link
  indication.
- U-boot network framework now calls open procedure again during next
  transmit initiation.

Signed-off-by: Stefan Chulski <stefanc@marvell.com>
Reviewed-by: Igal Liberman <igall@marvell.com>
Tested-by: Igal Liberman <igall@marvell.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agoarm: dts: k3-am654-base-board-u-boot: change cpsw2g interface mode to rgmii-rxid
Grygorii Strashko [Mon, 18 Nov 2019 21:04:47 +0000 (23:04 +0200)]
arm: dts: k3-am654-base-board-u-boot: change cpsw2g interface mode to rgmii-rxid

The AM654 SoC doesn't allow to disabling RGMII TX internal delay in CPSW2G
MAC. Hence, change CPSW2G interface mode to "rgmii-rxid" - RGMII with
internal RX delay provided by the PHY, the MAC will add an TX delay in this
case.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: dp83867: refactor rgmii configuration
Grygorii Strashko [Mon, 18 Nov 2019 21:04:46 +0000 (23:04 +0200)]
net: phy: dp83867: refactor rgmii configuration

Refactor SGMII configuration to group all settings together and reduce
number of MDIO transactions.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: dp83867: io impedance is not dependent on RGMII delay
Grygorii Strashko [Mon, 18 Nov 2019 21:04:45 +0000 (23:04 +0200)]
net: phy: dp83867: io impedance is not dependent on RGMII delay

Based on commit 27708eb5481b ("net: phy: dp83867: IO impedance is not
dependent on RGMII delay") of mainline linux kernel.

The driver would only set the IO impedance value when RGMII internal delays
were enabled.  There is no reason for this.  Move the IO impedance block
out of the RGMII delay block.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: dp83867: rework delay rgmii delay handling
Grygorii Strashko [Mon, 18 Nov 2019 21:04:44 +0000 (23:04 +0200)]
net: phy: dp83867: rework delay rgmii delay handling

Based on commit c11669a2757e ("net: phy: dp83867: Rework delay rgmii delay
handling") of mainline linux kernel.

The current code is assuming the reset default of the delay control
register was to have delay disabled.  This is what the datasheet shows as
the register's initial value.  However, that's not actually true: the
default is controlled by the PHY's pin strapping.

This patch:
- insures the other direction's delay is disabled If the interface mode is
selected as RX or TX delay only
- validates the delay values and fail if they are not in range
- checks if the board is strapped to have a delay and is configured to use
"rgmii" mode and warning is generated that "rgmii-id" should have been
used.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: dp83867: Add ability to disable output clock
Grygorii Strashko [Mon, 18 Nov 2019 21:04:43 +0000 (23:04 +0200)]
net: phy: dp83867: Add ability to disable output clock

Based on commit 13c83cf8af0d ("net: phy: dp83867: Add ability to disable
output clock") of mainline linux kernel.

Generally, the output clock pin is only used for testing and only serves as
a source of RF noise after this.  It could be used to daisy-chain PHYs, but
this is uncommon.  Since the PHY can disable the output, make doing so an
option.  I do this by adding another enumeration to the allowed values of
ti,clk-output-sel.

The code was not using the value DP83867_CLK_O_SEL_REF_CLK as one might
expect: to select the REF_CLK as the output.  Rather it meant "keep clock
output setting as is", which, depending on PHY strapping, might not be
outputting REF_CLK.

Change this so DP83867_CLK_O_SEL_REF_CLK means enable REF_CLK output.
Omitting the property will leave the setting as is (which was the previous
behavior in this case).

Out of range values were silently converted into DP83867_CLK_O_SEL_REF_CLK.
Change this so they generate an error.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agodt-bindings: phy: dp83867: Add documentation for disabling clock output
Grygorii Strashko [Mon, 18 Nov 2019 21:04:42 +0000 (23:04 +0200)]
dt-bindings: phy: dp83867: Add documentation for disabling clock output

Based on commit 980066e6d964 ("dt-bindings: phy: dp83867: Add documentation
for disabling clock output") of mainline linux kernel.

The clock output is generally only used for testing and development and not
used to daisy-chain PHYs.  It's just a source of RF noise afterward.

Add a mux value for "off".  I've added it as another enumeration to the
output property.  In the actual PHY, the mux and the output enable are
independently controllable.  However, it doesn't seem useful to be able
to describe the mux setting when the output is disabled.

Document that PHY's default setting will be left as is if the property
is omitted.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: dp83867: move static initialization to .probe()
Grygorii Strashko [Mon, 18 Nov 2019 21:04:41 +0000 (23:04 +0200)]
net: phy: dp83867: move static initialization to .probe()

Move static, one-time initialization to .probe() callback.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: phy: ti: rename ti.c to dp83867.c
Grygorii Strashko [Mon, 18 Nov 2019 21:04:40 +0000 (23:04 +0200)]
net: phy: ti: rename ti.c to dp83867.c

The driver ti.c is actually driver for TI DP83867x PHYs, so rename it
accordingly.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: tftp: Fix tftp store address check in store_block()
Bin Meng [Sat, 16 Nov 2019 06:20:13 +0000 (22:20 -0800)]
net: tftp: Fix tftp store address check in store_block()

During testing of qemu-riscv32 with a 2GiB memory configuration,
tftp always fails with a error message:

  Load address: 0x84000000
  Loading: #
  TFTP error: trying to overwrite reserved memory...

It turns out the result of 'tftp_load_addr + tftp_load_size' just
overflows (0x100000000) and the test logic in store_block() fails.
Fix this by adjusting the end address to ULONG_MAX when overflow
is detected.

Fixes: a156c47e39ad ("tftp: prevent overwriting reserved memory")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: avoid address-of-packed-member error
Heinrich Schuchardt [Tue, 5 Nov 2019 11:48:19 +0000 (12:48 +0100)]
net: avoid address-of-packed-member error

sandbox_defconfig does not compile using GCC 9.2.1:

net/net.c: In function ‘net_process_received_packet’:
net/net.c:1288:23: error: taking address of packed member of ‘struct
ip_udp_hdr’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
 1288 |    sumptr = (ushort *)&(ip->udp_src);
      |                       ^~~~~~~~~~~~~~

Avoid the error by using a u8 pointer instead of an u16 pointer and
in-lining ntohs().

Simplify the checksumming of the last message byte.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet/phy: Fix phy_connect() for phy addr 0
Priyanka Jain [Tue, 5 Nov 2019 04:05:11 +0000 (04:05 +0000)]
net/phy: Fix phy_connect() for phy addr 0

Fix 'mask' calculation in phy_connect() for phy addr '0'.
'mask' is getting set to '0xffffffff' for phy addr '0'
in phy_connect() whereas expected value is '0'.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
Reported-by: tetsu-aoki via github
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: nfs: Only link in NFS code outside of SPL builds
Tom Rini [Fri, 6 Dec 2019 00:35:07 +0000 (19:35 -0500)]
net: nfs: Only link in NFS code outside of SPL builds

While we have networking use cases within SPL we do not support loading
files via NFS at this point in time.  Disable calling nfs_start() so
that the NFS related code can be garbage collected at link time.

Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agolib: Always build support for formatting MAC and IP address
Joe Hershberger [Tue, 24 Sep 2019 16:41:23 +0000 (11:41 -0500)]
lib: Always build support for formatting MAC and IP address

Even if not communicating over the network in U-Boot, code may be manipulating
and storing IP or MAC addresses to pass to Linux, etc.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: Improve documentation for string_to_ip()
Joe Hershberger [Sat, 14 Sep 2019 00:29:41 +0000 (19:29 -0500)]
net: Improve documentation for string_to_ip()

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
4 years agonet: Always build the string_to_enetaddr() helper
Joe Hershberger [Sat, 14 Sep 2019 00:21:16 +0000 (19:21 -0500)]
net: Always build the string_to_enetaddr() helper

Part of the env cleanup moved this out of the environment code and into
the net code. However, this helper is sometimes needed even when the net
stack isn't included.

Move the helper to lib/net_utils.c like it's similarly-purposed
string_to_ip(). Also rename the moved function to similar naming.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reported-by: Ondrej Jirman <megous@megous.com>
4 years agoarm: -march=armv5t for ARM11
Heinrich Schuchardt [Sat, 7 Dec 2019 08:14:50 +0000 (09:14 +0100)]
arm: -march=armv5t for ARM11

In GCC 9 support for the Armv5 and Armv5E architectures (which have no
known implementations) has been removed, cf.
https://gcc.gnu.org/gcc-9/changes.html

Commit 16540d07fd62 ("arm: fix -march for ARM11") changed the value of the
compiler flag from -march=armv5 and -march=armv5t into -march=armv6 for
ARM11.

The values prior to this patch were:

    arch-$(CONFIG_CPU_ARM1136)     =-march=armv5
    arch-$(CONFIG_CPU_ARM1176)     =-march=armv5t

The change lead to a regression with the Raspberry Pi Zero W not booting
anymore.

Use -march=armv5t both for ARM1136 and ARM1176.

Fixes: 16540d07fd62 ("arm: fix -march for ARM11")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Joris Offouga <offougajoris@gmail.com>
4 years agolinux/types.h: fix typo unchar
Heinrich Schuchardt [Sat, 7 Dec 2019 23:22:01 +0000 (00:22 +0100)]
linux/types.h: fix typo unchar

unsigned char should be called uchar and not unchar.

This fixes a build error in lib/crypto/x509_cert_parser.c.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
4 years agoMerge tag 'u-boot-imx-20191209' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
Tom Rini [Mon, 9 Dec 2019 15:32:08 +0000 (10:32 -0500)]
Merge tag 'u-boot-imx-20191209' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx

Fixes for 2020.01
-----------------

- imx8qxp_mek: increase buffer sizes and args number
- Fixes for imx7ulp
- imx8mm: Fix the first root clock in imx8mm_ahb_sels[]
- colibri_imx7: reserve DDR memory for Cortex-M4
- vining2000: fixes and convert to ethernet DM
- imx8m: fix rom version check to unbreak some B0 chips
- tbs2910: Disable VxWorks image booting support

4 years agoimx8m: fix rom version check to unbreak some B0 chips
Patrick Wildt [Tue, 19 Nov 2019 08:42:06 +0000 (09:42 +0100)]
imx8m: fix rom version check to unbreak some B0 chips

Recently the version check was improved to be able to determine that
we're running on SoC revision 2.1.  A check for B0 was tightened so
that it now must equal 0x20 instead of being bigger than 0x20.  On
some B0 chips the value returned is 0x1020 instead of 0x20.  This
means even though it's B0, the check will fail and code relying on
the correct chip revision will make wrong decisions.  There is no
documentation of those bits, but it seems that NXP always uses a
byte to encode the revision.  Thus remove the upper bits to fix the
regression.

Signed-off-by: Patrick Wildt <patrick@blueri.se>
4 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-x86
Tom Rini [Sun, 8 Dec 2019 15:51:00 +0000 (10:51 -0500)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-x86

- 16-bit start up codes clean up

4 years agox86: simplify ljmp to 32-bit code
Masahiro Yamada [Tue, 3 Dec 2019 05:28:58 +0000 (14:28 +0900)]
x86: simplify ljmp to 32-bit code

You can directly specify the label as the operand for ljmp.

This commit saves 4-byte code.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: fixed the gas warning]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
4 years agox86: use data32 directive instead of macro for operand-size prefix
Masahiro Yamada [Tue, 3 Dec 2019 05:20:49 +0000 (14:20 +0900)]
x86: use data32 directive instead of macro for operand-size prefix

This file defines 'a32' and 'o32' macros to avoid magic numbers
of operand/address-size prefixing.

GAS supports 'data32' and 'addr32' for that purpose.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
4 years agoMerge branch '2019-12-06-master-imports'
Tom Rini [Fri, 6 Dec 2019 21:45:46 +0000 (16:45 -0500)]
Merge branch '2019-12-06-master-imports'

- Allow for the sysboot command, which is used to parse extlinux.conf
  files to be used without PXE support.  There is no functional change
  here aside from fixing distro boot in a few cases where we actually
  lacked the ability to parse the extlinux.conf file
- Add the x509/pkcs7 parsers from Linux, a pre-requisite to EFI Secure
  Boot support.

4 years agoMakefile: Ensure tools directory exists in output prior to use
Tom Rini [Wed, 4 Dec 2019 23:54:30 +0000 (18:54 -0500)]
Makefile: Ensure tools directory exists in output prior to use

With the change to make tools/version.h a file we need to make sure that
the output directory exists first otherwise we will get a build failure.

Reported-by: Peter Robinson <pbrobinson@gmail.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Fixes: 4d90f6cd9813 ("tools: Avoid creating symbolic links for tools/version.h")
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agotest: add asn1 unit test
AKASHI Takahiro [Wed, 13 Nov 2019 00:45:02 +0000 (09:45 +0900)]
test: add asn1 unit test

This test will exercise asn1 compiler as well as asn1 decoder functions
via various parsers.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
4 years agolib: crypto: add pkcs7 message parser
AKASHI Takahiro [Wed, 13 Nov 2019 00:45:01 +0000 (09:45 +0900)]
lib: crypto: add pkcs7 message parser

Imported from linux kernel v5.3:
 pkcs7.asn1 without changes
 pkcs7.h with changes marked as __UBOOT__
 pkcs7_parser.h without changes
 pkcs7_parser.c with changes marked as __UBOOT__

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
4 years agolib: crypto: add x509 parser
AKASHI Takahiro [Wed, 13 Nov 2019 00:45:00 +0000 (09:45 +0900)]
lib: crypto: add x509 parser

Imported from linux kernel v5.3:
 x509.asn1 without changes
 x509_akid.asn1 without changes
 x509_parser.h without changes
 x509_cert_parser.c with changes marked as __UBOOT__
 x509_public_key.c with changes marked as __UBOOT__

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
4 years agolib: crypto: add rsa public key parser
AKASHI Takahiro [Wed, 13 Nov 2019 00:44:59 +0000 (09:44 +0900)]
lib: crypto: add rsa public key parser

Imported from linux kernel v5.3:
rsapubkey.asn1 without changes
rsa.h without changes
rsa_helper.c with changes marked as __UBOOT__

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
4 years agolib: crypto: add public key utility
AKASHI Takahiro [Wed, 13 Nov 2019 00:44:58 +0000 (09:44 +0900)]
lib: crypto: add public key utility

Imported from linux kernel v5.3:
 asymmetric-type.h with changes marked as __UBOOT__
 asymmetric_type.c with changes marked as __UBOOT__
 public_key.h with changes marked as __UBOOT__
 public_key.c with changes marked as __UBOOT__

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
4 years agolib: add oid registry utility
AKASHI Takahiro [Wed, 13 Nov 2019 00:44:57 +0000 (09:44 +0900)]
lib: add oid registry utility

Imported from linux kernel v5.3:
 build_OID_registry without changes
 oid_registry.h without changes
 oid_registry.c with changes marked as __UBOOT__

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
4 years agodoc: add README for asn1 compiler and decoder
AKASHI Takahiro [Wed, 13 Nov 2019 00:44:56 +0000 (09:44 +0900)]
doc: add README for asn1 compiler and decoder

This document gives a brief description about ASN1 compiler as well as
ASN1 decoder.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
4 years agolib: add asn1 decoder
AKASHI Takahiro [Wed, 13 Nov 2019 00:44:55 +0000 (09:44 +0900)]
lib: add asn1 decoder

Imported from linux kernel v5.3:
 lib/asn1_decoder.c with changes marked as __UBOOT__

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
4 years agoMakefile: add build script for asn1 parsers
AKASHI Takahiro [Wed, 13 Nov 2019 00:44:54 +0000 (09:44 +0900)]
Makefile: add build script for asn1 parsers

This rule will be used to build x509 and pkcs7 parsers.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
4 years agocmd: add asn1_compiler
AKASHI Takahiro [Wed, 13 Nov 2019 00:44:53 +0000 (09:44 +0900)]
cmd: add asn1_compiler

Imported from linux kernel v5.3:
 asn1.h without changes
 asn1_ber_bytecode.h without changes
 asn1_decoder.h without changes
 asn1_compiler.c without changes

This host command will be used to create a ASN1 parser, for example,
for pkcs7 messages or x509 certificates. More specifically, it will
generate *byte code* which will be interpreted by asn1 decoder library.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>