platform/kernel/u-boot.git
3 years agoconfigs: socfpga: soc64: Move CONFIG_BOOTCOMMAND to defconfig
Siew Chin Lim [Mon, 1 Mar 2021 12:04:14 +0000 (20:04 +0800)]
configs: socfpga: soc64: Move CONFIG_BOOTCOMMAND to defconfig

CONFIG_BOOTCOMMAND have been moved to Kconfig.boot. This patch
move the CONFIG_BOOTCOMMAND macro from socfpga_soc64_common.h to
*_defconfig file for both Stratix 10 and Agilex.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
3 years agoarm: socfpga: dts: soc64: Update filename in binman node of FIT image with VAB support
Siew Chin Lim [Mon, 1 Mar 2021 12:04:13 +0000 (20:04 +0800)]
arm: socfpga: dts: soc64: Update filename in binman node of FIT image with VAB support

FIT image of Vendor Authentication Coot (VAB) contains signed images.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
3 years agoarm: socfpga: cmd: Support 'vab' command
Siew Chin Lim [Mon, 1 Mar 2021 12:04:12 +0000 (20:04 +0800)]
arm: socfpga: cmd: Support 'vab' command

Support 'vab' command to perform vendor authentication.

Command format: vab addr len
Authorize 'len' bytes starting at 'addr' via vendor public key

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
3 years agoarm: socfpga: soc64: Support Vendor Authorized Boot (VAB)
Siew Chin Lim [Mon, 1 Mar 2021 12:04:11 +0000 (20:04 +0800)]
arm: socfpga: soc64: Support Vendor Authorized Boot (VAB)

Vendor Authorized Boot is a security feature for authenticating
the images such as U-Boot, ARM trusted Firmware, Linux kernel,
device tree blob and etc loaded from FIT. After those images are
loaded from FIT, the VAB certificate and signature block appended
at the end of each image are sent to Secure Device Manager (SDM)
for authentication. U-Boot will validate the SHA384 of the image
against the SHA384 hash stored in the VAB certificate before
sending the image to SDM for authentication.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
Reviewed-by: Ley Foon Tan <ley.foon.tan@intel.com>
3 years agoarm: socfpga: Move Stratix10 and Agilex to use TARGET_SOCFPGA_SOC64
Siew Chin Lim [Mon, 1 Mar 2021 12:04:10 +0000 (20:04 +0800)]
arm: socfpga: Move Stratix10 and Agilex to use TARGET_SOCFPGA_SOC64

Create common macro TARGET_SOCFPGA_SOC64 for Stratix10 and Agilex.

Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
3 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq
Tom Rini [Sat, 6 Mar 2021 12:25:04 +0000 (07:25 -0500)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq

- Convert qemu-ppce500 to driver model and enable additional driver
  support
- bug fixes/updates in net-dsa driver, vid driver, move configs to kconfig
- Update Maintainers of some powerpc, layerscape platforms

3 years agodoc: Add a reST document for qemu-ppce500
Bin Meng [Thu, 25 Feb 2021 09:22:59 +0000 (17:22 +0800)]
doc: Add a reST document for qemu-ppce500

Add a reST document to describe how to build and run U-Boot for
the QEMU ppce500 machine.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Move board directory from board/freescale to board/emulation
Bin Meng [Thu, 25 Feb 2021 09:22:58 +0000 (17:22 +0800)]
ppc: qemu: Move board directory from board/freescale to board/emulation

board/emulation is the place for other QEMU targets like x86, arm,
riscv. Let's move the qemu-ppce500 board codes there.

List me as a co-maintainer for this board.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Drop fixed_sdram()
Bin Meng [Thu, 25 Feb 2021 09:22:57 +0000 (17:22 +0800)]
ppc: qemu: Drop fixed_sdram()

This function is not called anywhere. Only fsl_ddr_sdram_size() is
necessary [1] for QEMU. Drop it.

[1] arch/powerpc/cpu/mpc85xx/cpu.c::dram_init()

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Drop a custom env variable 'fdt_addr_r'
Bin Meng [Thu, 25 Feb 2021 09:22:56 +0000 (17:22 +0800)]
ppc: qemu: Drop a custom env variable 'fdt_addr_r'

Now that we have switched to CONFIG_OF_CONTROL, and we can use the
env variable 'fdtcontroladdr' directly instead of creating one that
is duplicated.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Delete the temporary FDT virtual-physical mapping after U-Boot is relocated
Bin Meng [Thu, 25 Feb 2021 09:22:55 +0000 (17:22 +0800)]
ppc: qemu: Delete the temporary FDT virtual-physical mapping after U-Boot is relocated

After U-Boot is relocated to RAM already, the previous temporary FDT
virtual-physical mapping that was used in the pre-relocation phase
is no longer needed. Let's delete the mapping.

get_fdt_virt() might be used before and after relocation, update it
to return different virtual address of FDT.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Enable RTC support via I2C
Bin Meng [Thu, 25 Feb 2021 09:22:54 +0000 (17:22 +0800)]
ppc: qemu: Enable RTC support via I2C

The QEMU ppce500 target integrates a Freescale I2C controller and
has a Pericom pt7c4338 RTC connected to it. Enable corresponding
DM drivers so that 'date' command is actually useful.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Enable support for power off via GPIO
Bin Meng [Thu, 25 Feb 2021 09:22:53 +0000 (17:22 +0800)]
ppc: qemu: Enable support for power off via GPIO

The QEMU ppce500 target provides the power off functionality via
the GPIO pin#0, and we can support this using the sysreset gpio
poweroff driver. Let's enable it.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agodm: sysreset: Add a Kconfig option for the 'reset' command
Bin Meng [Thu, 25 Feb 2021 09:22:52 +0000 (17:22 +0800)]
dm: sysreset: Add a Kconfig option for the 'reset' command

sysreset uclass driver provides an implementation of 'reset'
command using the sysreset_ APIs unconditionally. It also
supports the 'poweroff' command using the sysreset_ APIs,
but under a Kconfig option CONFIG_SYSRESET_CMD_POWEROFF.

Let's do the same for the 'reset' command, by introducing a
new Kconfig option CONFIG_SYSRESET_CMD_RESET, and set it to
on by default, to allow a board that don't have a sysreset
reset driver yet, but have a sysreset poweroff driver to
compile without any issue.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Enable GPIO support
Bin Meng [Thu, 25 Feb 2021 09:22:51 +0000 (17:22 +0800)]
ppc: qemu: Enable GPIO support

QEMU ppce500 target integrates a GPIO controller that is compatible
with the QorIQ GPIO controller. Enable the DM GPIO driver for it
and the 'gpio' command.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agogpio: mpc8xxx: Support controller register physical address beyond 32-bit
Bin Meng [Thu, 25 Feb 2021 09:22:50 +0000 (17:22 +0800)]
gpio: mpc8xxx: Support controller register physical address beyond 32-bit

dev_read_addr_size_index() returns fdt_addr_t which might be a
64-bit physical address. This might be true for some 85xx SoCs
whose CCSBAR is mapped beyond 4 GiB.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: mpc85xx: Add 'gpibe' register to 'struct ccsr_gpio'
Bin Meng [Thu, 25 Feb 2021 09:22:49 +0000 (17:22 +0800)]
ppc: mpc85xx: Add 'gpibe' register to 'struct ccsr_gpio'

Without this, the DM GPIO driver for MPC8xxx does not compile for
MPC85xx SoCs.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Enable VirtIO BLK support
Bin Meng [Thu, 25 Feb 2021 09:22:48 +0000 (17:22 +0800)]
ppc: qemu: Enable VirtIO BLK support

Enable VirtIO BLK driver so that we can store a kernel image to
a disk image and boot from there.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agovirtio: Fix VirtIO BLK driver dependency
Bin Meng [Thu, 25 Feb 2021 09:22:47 +0000 (17:22 +0800)]
virtio: Fix VirtIO BLK driver dependency

The VirtIO BLK driver depends on the blk uclass driver.
Add the dependency in the Kconfig.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Enable VirtIO NET support
Bin Meng [Thu, 25 Feb 2021 09:22:46 +0000 (17:22 +0800)]
ppc: qemu: Enable VirtIO NET support

By default the QEMU ppce500 machine connects a VirtIO NET to the
PCI controller, although it can be replaced to an e1000 NIC via
additional command line options.

Now that we have switched over to DM PCI, VirtIO support becomes
possible. This commit enables the support.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agocmd: Fix virtio command dependency
Bin Meng [Thu, 25 Feb 2021 09:22:45 +0000 (17:22 +0800)]
cmd: Fix virtio command dependency

The 'virtio' command calls blk_common_cmd() which is only available
when CONFIG_HAVE_BLOCK_DEVICE is on. Fix the Kconfig dependency.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Drop CONFIG_OF_BOARD_SETUP
Bin Meng [Thu, 25 Feb 2021 09:22:44 +0000 (17:22 +0800)]
ppc: qemu: Drop CONFIG_OF_BOARD_SETUP

ft_board_setup() is now empty. Drop it.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Switch over to use DM ETH and PCI
Bin Meng [Thu, 25 Feb 2021 09:22:43 +0000 (17:22 +0800)]
ppc: qemu: Switch over to use DM ETH and PCI

At present the board supports non-DM version PCI and E1000 drivers.
Switch over to use DM ETH and PCI by:

- Rewrite the PCI address map functions using DM APIs
- Enable CONFIG_MISC_INIT_R to do the PCI initialization and
  address map
- Drop unnecessary ad-hoc config macros
- Remove board_eth_init() in the board codes

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agopci: mpc85xx: Support 64-bit bus and cpu address
Bin Meng [Thu, 25 Feb 2021 09:22:42 +0000 (17:22 +0800)]
pci: mpc85xx: Support 64-bit bus and cpu address

At present the driver only supports 32-bit bus and cpu address.
The controller's outbound registers/fields for extended address
are not programmed. Let's program them to support 64-bit bus and
cpu address.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agopci: mpc85xx: Support controller register physical address beyond 32-bit
Bin Meng [Thu, 25 Feb 2021 09:22:41 +0000 (17:22 +0800)]
pci: mpc85xx: Support controller register physical address beyond 32-bit

devfdt_get_addr_index() returns fdt_addr_t which might be a 64-bit
physical address. Use map_physmem() to return the virtual address
that can be used by a 32-bit machine.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agopci: mpc85xx: Wrap LAW programming with CONFIG_FSL_LAW
Bin Meng [Thu, 25 Feb 2021 09:22:40 +0000 (17:22 +0800)]
pci: mpc85xx: Wrap LAW programming with CONFIG_FSL_LAW

For the QEMU ppce500 machine, LAW registers are not implemented
hence CONFIG_FSL_LAW is not turned on and all LAW APIs are not
available. We should wrap all LAW registers programming in the
mpc85xx PCI driver with CONFIG_FSL_LAW.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Switch over to use DM serial
Bin Meng [Thu, 25 Feb 2021 09:22:39 +0000 (17:22 +0800)]
ppc: qemu: Switch over to use DM serial

The QEMU ppce500 target integrates 2 NS16550 serial ports. Switch
over to use the DM version of the driver by:

- drop unnecessary ad-hoc config macros
- add get_serial_clock() in the board codes

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agocommon: Move initr_addr_map() to a bit earlier
Bin Meng [Thu, 25 Feb 2021 09:22:38 +0000 (17:22 +0800)]
common: Move initr_addr_map() to a bit earlier

At present initr_addr_map() is put at a late stage in the
init_sequence_r[] calls. This won't work because lot of
device driver initialization (e.g.: serial port) happens
before it but is lack of the address translation support.

This moves the call to a bit earlier, right after the DM
initialization.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: io.h: Use addrmap_ translation APIs only in post-relocation phase
Bin Meng [Thu, 25 Feb 2021 09:22:37 +0000 (17:22 +0800)]
ppc: io.h: Use addrmap_ translation APIs only in post-relocation phase

In phys_to_virt() and virt_to_phys(), if CONFIG_ADDR_MAP is defined,
they use addrmap_ translation APIs to do the address translation.
However these APIs only work in post-relocation phase.

Update the code logic to fall back to use the default one when in
pre-relocation phase.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agolib: kconfig: Mention CONFIG_ADDR_MAP limitation in the help
Bin Meng [Thu, 25 Feb 2021 09:22:36 +0000 (17:22 +0800)]
lib: kconfig: Mention CONFIG_ADDR_MAP limitation in the help

Mention that CONFIG_ADDR_MAP only works in the post-relocation phase.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agotest: cmd: Add a basic test for 'addrmap' command
Bin Meng [Thu, 25 Feb 2021 09:22:35 +0000 (17:22 +0800)]
test: cmd: Add a basic test for 'addrmap' command

This adds a basic test for the newly introduced 'addrmap' command.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
[Rebase]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agocmd: Add a command to display the address map
Bin Meng [Thu, 25 Feb 2021 09:22:34 +0000 (17:22 +0800)]
cmd: Add a command to display the address map

This adds a new command 'addrmap' to display the address map for
non-identity virtual-physical memory mappings.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agolib: addr_map: Move address_map[] type to the header file
Bin Meng [Thu, 25 Feb 2021 09:22:33 +0000 (17:22 +0800)]
lib: addr_map: Move address_map[] type to the header file

At present address_map[] is static and its type is unknown to external
modules. In preparation to create a command to list its contents, this
patch moves its type definition and declaration to the header file.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoinclude: Remove extern from addr_map.h
Bin Meng [Thu, 25 Feb 2021 09:22:32 +0000 (17:22 +0800)]
include: Remove extern from addr_map.h

Remove the extern of the header because they are useless.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Enable driver model
Bin Meng [Thu, 25 Feb 2021 09:22:31 +0000 (17:22 +0800)]
ppc: qemu: Enable driver model

At present QEMU ppce500 target has not been migrated to driver model
yet. As a start, let's enable driver model and the 'dm' command.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Enable OF_CONTROL
Bin Meng [Thu, 25 Feb 2021 09:22:30 +0000 (17:22 +0800)]
ppc: qemu: Enable OF_CONTROL

The QEMU ppce500 machine generates a device tree blob and passes
it to U-Boot during boot. Let's enable OF_CONTROL with OF_BOARD
and provide board_fdt_blob_setup() in the board codes.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Drop board_early_init_f()
Bin Meng [Thu, 25 Feb 2021 09:22:29 +0000 (17:22 +0800)]
ppc: qemu: Drop board_early_init_f()

This function does nothing. Drop it.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Drop init_laws() and print_laws()
Bin Meng [Thu, 25 Feb 2021 09:22:28 +0000 (17:22 +0800)]
ppc: qemu: Drop init_laws() and print_laws()

These are no longer needed. Drop them.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: mpc85xx: Wrap LAW related codes with CONFIG_FSL_LAW
Bin Meng [Thu, 25 Feb 2021 09:22:27 +0000 (17:22 +0800)]
ppc: mpc85xx: Wrap LAW related codes with CONFIG_FSL_LAW

LAW related codes should be wrapped with CONFIG_FSL_LAW.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Fix CONFIG_SYS_PCI_MAP_END
Bin Meng [Thu, 25 Feb 2021 09:22:26 +0000 (17:22 +0800)]
ppc: qemu: Fix CONFIG_SYS_PCI_MAP_END

CONFIG_SYS_PCI_MAP_END currently points to 0xe8000000, which means
the upper end of the virtual address mapped to PCI bus address ends
at 0xe8000000. But this is wrong as the CCSBAR was already mapped
at 0xe0000000 with a 1 MiB size.

Fixes: fa08d3951777 ("PPC 85xx: Add qemu-ppce500 machine")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Support non-identity PCI bus address
Bin Meng [Thu, 25 Feb 2021 09:22:25 +0000 (17:22 +0800)]
ppc: qemu: Support non-identity PCI bus address

When QEMU originally supported the ppce500 machine back in Jan 2014,
it was created with a 1:1 mapping of PCI bus address. Things seemed
to change rapidly that in Nov 2014 with the following QEMU commits:

commit e6b4e5f4795b ("PPC: e500: Move CCSR and MMIO space to upper end of address space")

and

commit cb3778a0455a ("PPC: e500 pci host: Add support for ATMUs")

the PCI memory and IO physical address were moved to beyond 4 GiB,
but PCI bus address remained below 4 GiB, hence a non-identity
mapping was created. Unfortunately corresponding U-Boot updates
were missed along with the QEMU changes and the U-Boot QEMU ppce500
PCI support has been broken since then.

This commit makes the PCI (non-DM version) work again.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agocommon: fdt_support: Support special case of PCI address in fdt_read_prop()
Bin Meng [Thu, 25 Feb 2021 09:22:24 +0000 (17:22 +0800)]
common: fdt_support: Support special case of PCI address in fdt_read_prop()

At present fdt_read_prop() can only handle 1 or 2 cells. It is
called by fdt_read_range() which may be used to read PCI address
from <ranges> for a PCI bus node where the number of PCI address
cell is 3. The <ranges> property is an array of:

  { <child address> <parent address> <size in child address space> }

When trying to read <child address> from a PCI bus node using
fdt_read_prop(), as the codes below:

    /* Read <child address> */
    if (child_addr) {
        r = fdt_read_prop(ranges, ranges_len, cell, child_addr,
                          acells);
        if (r)
            return r;
    }

it will fail, because the PCI child address is made up of 3 cells
but fdt_read_prop() cannot handle it. We advance the cell offset
by 1 so that the <child address> can be correctly read.

This adds the special handling of such case.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: qemu: Update MAINTAINERS for correct email address
Bin Meng [Thu, 25 Feb 2021 09:22:23 +0000 (17:22 +0800)]
ppc: qemu: Update MAINTAINERS for correct email address

Alex's previous email address is no longer reachable.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agopci: fsl_pci_init: Dynamically allocate the PCI regions
Bin Meng [Thu, 25 Feb 2021 09:22:22 +0000 (17:22 +0800)]
pci: fsl_pci_init: Dynamically allocate the PCI regions

Commit e002474158d1 ("pci: pci-uclass: Dynamically allocate the PCI regions")
changes 'struct pci_controller'.regions from pre-allocated array of
regions to dynamically allocated, which unfortunately broken lots of
boards that still use the non-DM PCI driver.

This patch changes the non-DM fsl_pci_init driver to dynamically
allocate the regions, just like what's done in the pci uclass driver.

Fixes: e002474158d1 ("pci: pci-uclass: Dynamically allocate the PCI regions")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agonet: dsa: remove master santiy check
Michael Walle [Wed, 24 Feb 2021 16:40:42 +0000 (17:40 +0100)]
net: dsa: remove master santiy check

Because we probe the master ourselves (and fail if there is no master),
it is not possible that we don't have a master device.

There is one catch though: device removal. We don't support that. It
wasn't supported neither before this patch. Because the master device
was only set in .pre_probe(), if a device was removed master_dev was a
dangling pointer and transmitting a frame cause a panic. I don't see a
good solution without having some sort of notify machanism when a
udevice is removed.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Michael Walle <michael@walle.cc> [DSA unit tests]
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agonet: dsa: remove NULL check for priv and platform data
Michael Walle [Wed, 24 Feb 2021 16:40:41 +0000 (17:40 +0100)]
net: dsa: remove NULL check for priv and platform data

Because the uclass has the "*_auto" properties set, the driver model
will take care of allocating the private structures for us and they
can't be NULL. Drop the checks.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agonet: dsa: probe master device
Michael Walle [Wed, 24 Feb 2021 16:40:40 +0000 (17:40 +0100)]
net: dsa: probe master device

DSA needs to have the master device probed first for MAC inheritance.
Until now, it only works by chance because the only user (LS1028A SoC)
will probe the master device first. The probe order is given by the PCI
device ordering, thus it works because the master device has a "smaller"
BDF then the switch device.

Explicitly probe the master device in dsa_port_probe().

Fixes: fc054d563bfb ("net: Introduce DSA class for Ethernet switches")
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agonet: dsa: return early if there is no master
Michael Walle [Wed, 24 Feb 2021 16:40:39 +0000 (17:40 +0100)]
net: dsa: return early if there is no master

It doesn't make sense to have DSA without a master port. Error out early
if there is no master port.

Fixes: fc054d563bfb ("net: Introduce DSA class for Ethernet switches")
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls1012aqds: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:23 +0000 (17:50 +0530)]
board: ls1012aqds: Update MAINTAINERS

Update LS1012AQDS Board MAINTAINERS entries to
current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: lx2160a: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:22 +0000 (17:50 +0530)]
board: lx2160a: Update MAINTAINERS

Update LX2160AQDS BOARD MAINTAINER entry to
current MAINTAINER.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls1046ardb: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:21 +0000 (17:50 +0530)]
board: ls1046ardb: Update MAINTAINERS

Update LS1046ARDB BOARD MAINTAINERS entries to
current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls1046aqds: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:20 +0000 (17:50 +0530)]
board: ls1046aqds: Update MAINTAINERS

Update LS1046AQDS BOARD MAINTAINERS entries to
current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls2080ardb: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:19 +0000 (17:50 +0530)]
board: ls2080ardb: Update MAINTAINERS

Update LS2080ARDB BOARD MAINTAINERS entries to
current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls2080aqds: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:18 +0000 (17:50 +0530)]
board: ls2080aqds: Update MAINTAINERS

Update LS2080AQDS BOARD MAINTAINERS entries to
current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls1088a: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:17 +0000 (17:50 +0530)]
board: ls1088a: Update MAINTAINERS

Update LS1088ARDB, LS1088AQDS BOARD MAINTAINERS
entries to current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls1043ardb: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:16 +0000 (17:50 +0530)]
board: ls1043ardb: Update MAINTAINERS

Update LS1043ARDB BOARD MAINTAINERS entries
to current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls1028a: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:15 +0000 (17:50 +0530)]
board: ls1028a: Update MAINTAINERS

Update LS1028AQDS, LS10128ARDB board MAINTAINERS
entries to current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls1021atwr: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:14 +0000 (17:50 +0530)]
board: ls1021atwr: Update MAINTAINERS

Update LS1021ATWR BOARD MAINTAINERS entries to
current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls1021aiot: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:13 +0000 (17:50 +0530)]
board: ls1021aiot: Update MAINTAINERS

Update LS1021AIOT BOARD MAINTAINERS entries to
current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls1012ardb: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:12 +0000 (17:50 +0530)]
board: ls1012ardb: Update MAINTAINERS

Update LS1012ARDB BOARD MAINTAINERS entries
to current MAINTAINERS.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: ls1012afrdm: Update MAINTAINERS
Priyanka Jain [Fri, 19 Feb 2021 12:20:11 +0000 (17:50 +0530)]
board: ls1012afrdm: Update MAINTAINERS

Update LS1012AFRWY BOARD MAINTAINER entry
to current MAINTAINER.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoboard: corenet_ds: MAINTAINERS: Remove redundant entries
Priyanka Jain [Fri, 19 Feb 2021 12:20:10 +0000 (17:50 +0530)]
board: corenet_ds: MAINTAINERS: Remove redundant entries

Remove MAINTAINERS entries for
P3041DS_NAND_SECURE_BOOT_defconfig
and P5040DS_NAND_SECURE_BOOT_defconfig
as these configs support have been removed.

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoconfigs: fsl: move via specific defines to Kconfig
Rajesh Bhagat [Mon, 15 Feb 2021 08:46:14 +0000 (09:46 +0100)]
configs: fsl: move via specific defines to Kconfig

Moves below via specific defines to Kconfig:

CONFIG_FSL_VIA

Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoconfigs: fsl: move bootrom specific defines to Kconfig
Rajesh Bhagat [Thu, 11 Feb 2021 12:28:49 +0000 (13:28 +0100)]
configs: fsl: move bootrom specific defines to Kconfig

Moves below bootrom specific defines to Kconfig:

    CONFIG_SYS_FSL_BOOTROM_BASE
    CONFIG_SYS_FSL_BOOTROM_SIZE

Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoarm: fsl: common: Improve NXP VID driver PMBus support
Stephen Carlson [Mon, 8 Feb 2021 10:11:29 +0000 (11:11 +0100)]
arm: fsl: common: Improve NXP VID driver PMBus support

This patch adds support for more PMBus compatible devices to the NXP
drivers for its QorIQ family devices. At runtime, the voltage regulator is
queried over I2C, and the required voltage multiplier determined. This
change supports the DIRECT and LINEAR PMBus voltage reporting modes.

Previously, the driver only supported a few specific devices such as the
IR36021 and LTC3882, so this change allows the QorIQ series to be used
with a much larger variety of core voltage regulator devices.

checkpatch warning "Use if (IS_DEFINED (...))" was ignored to maintain
consistency with the existing code.

Signed-off-by: Stephen Carlson <stcarlso@linux.microsoft.com>
Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
Tested-by: Wasim Khan <wasim.khan@nxp.com>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoAzure/GitLab: Use buildman -T0 for binman, etc, test
Tom Rini [Thu, 4 Mar 2021 21:59:00 +0000 (16:59 -0500)]
Azure/GitLab: Use buildman -T0 for binman, etc, test

There are times where buildman seems to get stuck in this job when in
CI.  Forcing single-threaded here allows us to complete and move on.

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agobuildman: Support single-threaded operation
Simon Glass [Sun, 31 Jan 2021 05:17:46 +0000 (22:17 -0700)]
buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoNokia RX-51: Enable CONFIG_CMD_BOOTD
Pali Rohár [Wed, 24 Feb 2021 00:27:29 +0000 (01:27 +0100)]
Nokia RX-51: Enable CONFIG_CMD_BOOTD

CONFIG_CMD_BOOTD provides 'boot' command which is required in more scripts.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agofs/squashfs: Fix compilation error
Pali Rohár [Wed, 3 Mar 2021 09:52:36 +0000 (10:52 +0100)]
fs/squashfs: Fix compilation error

Commit 401d1c4f5d2d29c4bc4beaec95402ca23eb63295 ("common: Drop
asm/global_data.h from common header") broke compilation of squashfs
filesystem when CONFIG_CMD_SQUASHFS=y is enabled.

Compilation is failing on error:

    aarch64-linux-gnu-ld.bfd: u-boot/fs/squashfs/sqfs_inode.c:121: undefined reference to `le32_to_cpu'

Fixes: 401d1c4f5d2d29c4bc4beaec95402ca23eb63295 ("common: Drop asm/global_data.h from common header")
Suggested-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
3 years agoMerge tag 'dm-pull-3mar21' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
Tom Rini [Thu, 4 Mar 2021 03:53:53 +0000 (22:53 -0500)]
Merge tag 'dm-pull-3mar21' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm

dm: Fix an obscure bug with empty of-platdata
Fixes for ns16550 base address and frequency-reading
Other minor fixes

3 years agoserial: ns16550: Handle zero <clock-frequency> value
Bin Meng [Wed, 3 Feb 2021 14:42:25 +0000 (22:42 +0800)]
serial: ns16550: Handle zero <clock-frequency> value

A working device tree node of ns16550 should never be populated
with value zero for the <clock-frequency> property. Unfortunately
this is the case for the QEMU ppce500 target.

Let's try to assign plat->clock to CONFIG_SYS_NS16550_CLK as the
last resort to handle such case.

This commit should be reverted when:

- The following QEMU patch [1] is merged, and
- U-Boot CI has upgraded its QEMU version that contains the fix

[1] http://patchwork.ozlabs.org/project/qemu-devel/patch/1612362288-22216-2-git-send-email-bmeng.cn@gmail.com/

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoserial: ns16550: Correct the base address type
Bin Meng [Wed, 3 Feb 2021 13:22:40 +0000 (21:22 +0800)]
serial: ns16550: Correct the base address type

Currently ns16550_serial_assign_base() treats the argument 'base'
with type `ulong`. This is incorrect because the base address was
obtained from device tree with type `fdt_addr_t` that can represent
a physical address larger than 32-bit in a 32-bit system.

Fixes: 9e6ce62190b7 ("serial: ns16550: Fix ordering of getting base address")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agodts: Fix OF_LIVE dependency
Bin Meng [Wed, 3 Feb 2021 13:20:03 +0000 (21:20 +0800)]
dts: Fix OF_LIVE dependency

lib/of_live.c references the following 2 ofnode APIs:
of_alias_scan() and of_get_property().

These APIs get built only when DM is on. Fix the dependency then.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agolib: Fix BINMAN_FDT dependency
Bin Meng [Wed, 3 Feb 2021 13:20:02 +0000 (21:20 +0800)]
lib: Fix BINMAN_FDT dependency

lib/binman.c references the following 3 ofnode APIs:
ofnode_first_subnode(), ofnode_path() and ofnode_read_bool().

These APIs get built only when DM is on. Fix the dependency then.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agosandbox: host bind must close file descriptor
Heinrich Schuchardt [Tue, 2 Feb 2021 23:21:56 +0000 (00:21 +0100)]
sandbox: host bind must close file descriptor

Each invocation of the 'host bind' command with a file name argument opens
a file descriptor. The next invocation of the 'host bind' command destroys
the block device but the file descriptor remains open. The same holds true
for the 'unbind blk' command.

Close the file descriptor when unbinding the host block device.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agofix patman --limit-cc option
Bernhard Kirchen [Fri, 29 Jan 2021 14:10:08 +0000 (15:10 +0100)]
fix patman --limit-cc option

patman's --limit-cc option parses its argument to an integer and uses
that to trim the list of CC recipients to a particular maximum. but that
only works if the cc variable is a list, which it is not.

Signed-off-by: Bernhard Kirchen <bernhard.kirchen@mbconnectline.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agobootstage: Fix dependency for BOOTSTAGE_RECORD_COUNT
Simon Glass [Wed, 3 Feb 2021 13:00:49 +0000 (06:00 -0700)]
bootstage: Fix dependency for BOOTSTAGE_RECORD_COUNT

At present these three Kconfigs exist even when bootstage is not enabled.
This is not necessary since bootstage.c is only built if BOOTSTAGE is
enabled.

Make them conditional. Also fix up the overflow message to mention TPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Add DM_DEVICE_REMOVE condition to all exit paths
Simon Glass [Thu, 4 Feb 2021 04:29:44 +0000 (21:29 -0700)]
dm: core: Add DM_DEVICE_REMOVE condition to all exit paths

At present device_bind() does some unnecessary work if a device fails to
bind in SPL. Add the missing conditions.

Also fix a style nit in the same function while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Fix allocation of empty of-platdata
Simon Glass [Thu, 4 Feb 2021 04:29:43 +0000 (21:29 -0700)]
dm: core: Fix allocation of empty of-platdata

With of-platdata we always have a dtv struct that holds the platform data
provided by the driver_info record. However, this struct can be empty if
there are no actual devicetree properties provided.

The upshot of empty platform data is that it will end up as a zero-size
member in the BSS section, which is fine. But if the driver specifies
plat_auto then it expects the correct amount of space to be allocated.

At present this does not happen, since device_bind() assumes that the
platform-data size will always be >0. As a result we end up not
allocating the space and just use the BSS region, overwriting whatever
other contents are present.

Fix this by removing the condition that platform data be non-empty, always
allocating space if requested.

This fixes a strange bug that has been lurking since of-platdata was
implemented. It has likely never been noticed since devices normally have
at least some devicetree properties, BSS is seldom used on SPL, the dtv
structs are normally at the end of bss and the overwriting only happens
if a driver changes its platform data.

It was discovered using sandbox_spl, which exercises more features than
a normal board might, and the critical global_data variable 'gd' happened
to be at the end of BSS.

Fixes: 9fa28190091 ("dm: core: Expand platdata for of-platdata devices")
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMerge tag 'u-boot-imx-20210303' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
Tom Rini [Wed, 3 Mar 2021 15:10:34 +0000 (10:10 -0500)]
Merge tag 'u-boot-imx-20210303' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx

i.MX for 2021.04
----------------

- new boards:
- i.MX8MN Beacon EmbeddedWorks (2GB)
- Gateworks Venice imx8mm
- convert to DM:
- imx53-qsb, mx53loco, mx51evk, mx23-evk
- Fixes :
- Network : FEC ethernet quirks
- DH dh-imx6

CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/6597

3 years agoboard: gateworks: imx8mm: Add Gateworks Venice board support
Tim Harvey [Tue, 2 Mar 2021 22:00:21 +0000 (14:00 -0800)]
board: gateworks: imx8mm: Add Gateworks Venice board support

Add initial support for Gateworks Venice product family based on the
i.MX 8M Mini SoC

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
3 years agoarm: dts: imx8mm: add Gateworks i.MX8 Mini Dev kits
Tim Harvey [Tue, 2 Mar 2021 22:00:20 +0000 (14:00 -0800)]
arm: dts: imx8mm: add Gateworks i.MX8 Mini Dev kits

Add Gateworks i.MX 8M Mini Development kits from Linux-5.12-rc1

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
3 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-usb
Tom Rini [Wed, 3 Mar 2021 12:54:55 +0000 (07:54 -0500)]
Merge https://source.denx.de/u-boot/custodians/u-boot-usb

- Kconfig dependency fix for USB_KEYBOARD
- musb gadget fixes / enhancements

3 years agousb: USB keyboard requires DM_KEYBOARD
Heinrich Schuchardt [Sun, 28 Feb 2021 11:50:49 +0000 (12:50 +0100)]
usb: USB keyboard requires DM_KEYBOARD

If CONFIG_DM_USB=y, the USB keyboard only works if CONFIG_DM_KEYBOARD=y.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoNokia RX-51: Enable usbtty serial console by default
Pali Rohár [Sat, 20 Feb 2021 10:50:15 +0000 (11:50 +0100)]
Nokia RX-51: Enable usbtty serial console by default

Now when usbtty serial console is fixed in U-Boot enable CONFIG_USB_TTY for
Nokia RX-51 board by default.

Fix also USB product id as U-Boot ignores CONFIG_USBD_PRODUCTID macro and
include U-Boot string into USB product name to indicate usage of U-Boot.

CONFIG_CONSOLE_MUX is already used and U-Boot console is available for
all in/out devices. Therefore there is no need to have separate commands
'run sercon', 'run usbcon' and 'run vgacon', so remove them.

As space for U-Boot is limited to 256kB, enable CONFIG_OPTIMIZE_INLINING
and disable some other unused options so CONFIG_USB_TTY can be enabled.

Nokia RX-51 does not have easily accessible UART serial console so the only
option for easy debugging is to use device's keyboard+screen or this usbtty
serial console over USB.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agoNokia RX-51: Move content of rx51.h to rx51.c
Pali Rohár [Sun, 7 Feb 2021 13:50:15 +0000 (14:50 +0100)]
Nokia RX-51: Move content of rx51.h to rx51.c

After removal of MUX configuration there is no need to have extra rx51.h.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agoNokia RX-51: Remove function set_muxconf_regs()
Pali Rohár [Sun, 7 Feb 2021 13:50:14 +0000 (14:50 +0100)]
Nokia RX-51: Remove function set_muxconf_regs()

This function is not used and was never called.

This board contains '#define CONFIG_SKIP_LOWLEVEL_INIT' because X-Loader
set everything up, including MUX configuration.

Also this MUX configuration is incorrect and does not match hardware.

So remove this dead, unused and broken code.

This change will decrease size of U-Boot binary.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agoarm: omap3: Compile s_init() function only when it is used
Pali Rohár [Sun, 7 Feb 2021 13:50:13 +0000 (14:50 +0100)]
arm: omap3: Compile s_init() function only when it is used

Function s_init() is called only from lowlevel_init(). So compile it only
when function lowlevel_init() is compiled.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agoarm: omap3: Compile lowlevel_init() function only when it is used
Pali Rohár [Sun, 7 Feb 2021 13:50:12 +0000 (14:50 +0100)]
arm: omap3: Compile lowlevel_init() function only when it is used

Function lowlevel_init() is called only from cpu_init_crit() and this
function is wrapped into #if .. #endif section. So compile also
lowlevel_init() function under same #if condition.

Function cpy_clk_code() uses lowlevel_init symbol to get address where
go_to_speed code ends. As this symbol is not available anymore when
compiling with CONFIG_SKIP_LOWLEVEL_INIT, defines a new label
go_to_speed_end at the place where go_to_speed code ends.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agousb: gadget: Use dbg_ep0() macro instead of serial_printf()
Pali Rohár [Sun, 7 Feb 2021 13:50:11 +0000 (14:50 +0100)]
usb: gadget: Use dbg_ep0() macro instead of serial_printf()

All debug messages from ep0.c except a few are printed by dbg_ep0() macro.
So for remaining few exceptions use also dbg_ep0() instead of serial_printf().

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agousb: musb: Ensure that we set musb dynamic FIFO buffer for every endpoint
Pali Rohár [Sun, 7 Feb 2021 13:50:10 +0000 (14:50 +0100)]
usb: musb: Ensure that we set musb dynamic FIFO buffer for every endpoint

If we do not set FIFO buffer address and size for some endpoint which is in
use then default programmed address 0x0 would be used which is in conflict
with address of FIFO buffer for endpoint 0. Moreover address of FIFO buffer
for endpoint 0 cannot be programmed, it is fixed to 0x0. Sharing address
space between more endpoints cause data loss and unexpected errors.

This patch is fixing transmission of characters over usbtty serial console
and allows using of usbtty for debugging purposes on Nokia N900.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agousb: musb: Fix handling interrupts for EP0 and SET ADDRESS commmand
Pali Rohár [Sun, 7 Feb 2021 13:50:09 +0000 (14:50 +0100)]
usb: musb: Fix handling interrupts for EP0 and SET ADDRESS commmand

Interrupt for EP0 is indicated in intrtx register via first bit. This bit
is set for both RX and TX despite register has only TX in its name. First
bit in intrrx register is reserved, not used and never set.

So remove calling musb_peri_ep0() function at every iteration of udc_irq()
and musb_peri_rx() and call it only from musb_peri_tx() when correct
interrupt bit in initrtx it set.

Address from SET ADDRESS command must be set to faddr register only after
acknowledging SERV_RXPKTRDY followed by received EP0 interrupt. So prior
calling musb_peri_ep0_set_address() check for EP0 interrupt instead of
(incorrect) MUSB_INTR_SOF interrupt.

This patch fixes issue that host (computer) cannot register U-Boot USB
device and is failing with errors:

    usb 1-1: new full-speed USB device number 86 using xhci_hcd
    usb 1-1: Device not responding to setup address.
    usb 1-1: Device not responding to setup address.
    usb 1-1: device not accepting address 86, error -71

U-Boot was writing address to faddr register too early and did not wait for
correct interrupt after which should update address.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agousb: musb: Fix receiving of bigger buffers
Pali Rohár [Sun, 7 Feb 2021 13:50:08 +0000 (14:50 +0100)]
usb: musb: Fix receiving of bigger buffers

If musb_peri_rx_ep() was called to process received HW buffer but U-Boot
cannot read it yet (e.g. because U-Boot SW buffer is full) then interrupt
was marked as processed also when HW buffer stayed unprocessed.

U-Boot tried to process this buffer again when it received interrupt again,
but it can receive it only when sender (host) sends a new data. As sender
(host) is not going to send a new data until U-Boot process current data
this issue caused a deadlock in case sender (host) is emitting data faster
than U-Boot can process it.

Reading musb intrrx register automatically clears this register and marks
interrupt as processed. So to prevent marking interrupt in U-Boot as
processed, adds a new variable pending_intrrx which would contain
unprocessed bits of intrrx register.

For a second step, every time when musb_peri_rx_ep() is called and there
are waiting data to be processed (signaled by MUSB_RXCSR_RXPKTRDY) either
acknowledge sender (via musb_peri_rx_ack()) that whole HW buffer was
processed or set corresponding bit in pending_intrrx that HW buffer was not
fully processed yet and next iteration is required after U-Boot allocates
space for reading HW buffer.

This patch fixes receiving large usb buffers, e.g. file transfer via Kermit
protocol implemented by 'loadb' U-Boot command over usbtty serial console.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agousb: musb: Fix transmission of bigger buffers
Pali Rohár [Sun, 7 Feb 2021 13:50:07 +0000 (14:50 +0100)]
usb: musb: Fix transmission of bigger buffers

If udc_endpoint_write() was called with bigger payload which does not fit
into one USB packet it is needed to transmit payload in more USB packets.
First packet is transmitted by udc_endpoint_write() call itself and other
packets are put into waiting queue.

Implement function musb_peri_tx() which checks if endpoints are ready for
transmit and continue transmission of waiting queue.

This patch fixes sending big output from printenv command over usbtty
serial console.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>>
3 years agousb: musb: Read value of PERI_RXCSR to 16bit variable
Pali Rohár [Sun, 7 Feb 2021 13:50:06 +0000 (14:50 +0100)]
usb: musb: Read value of PERI_RXCSR to 16bit variable

PERI_RXCSR is 16bit register so store its value into 16bit local variable.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agousb: musb: Fix configuring FIFO for endpoints
Pali Rohár [Sun, 7 Feb 2021 13:50:05 +0000 (14:50 +0100)]
usb: musb: Fix configuring FIFO for endpoints

This patch fixes configuring FIFOs for one-directional endpoints which have
only one queue (either RX or TX, but noth both).

Size of FIFO buffer is 2^(idx+3) bytes and starting address is 2^(addr+3).
Moreover first 64 bytes are reserved for EP0.

Without this patch if FIFO size specified by caller was zero then idx was
incorrectly calculated (expr. ffs(0)-1) and size overflowed in fifosz
register. This register uses has only 4 bits for FIFO size. Moreover
specifying zero buffer size is not possible (with idx=0 is minimal buffer
size 8 bytes).

So even for one-directional endpoints we need to correctly specify both
(RX and TX) FIFO buffer sizes and its addresses.

This patch is fixing calculation of start address and buffer size to
minimal value and ensures that it would not overlap with buffer reserved
for EP0.

This issue caused loose of packets on USB bus in both directions and
basically usbtty was unusable.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agousb: musb: Always clear the data toggle bit when configuring ep
Pali Rohár [Sun, 7 Feb 2021 13:50:04 +0000 (14:50 +0100)]
usb: musb: Always clear the data toggle bit when configuring ep

Without this patch clearing was done only when U-Boot was compiled with
MUSB Host Controller. But clearing of data toggle bit is needed also for
MUSB Device Controller otherwise Device Controller does not work correctly.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agousb: musb: Fix compilation of gadget code
Pali Rohár [Sun, 7 Feb 2021 13:50:03 +0000 (14:50 +0100)]
usb: musb: Fix compilation of gadget code

musb udc code depends on usb gadget code provided by CONFIG_USB_DEVICE as
defined in drivers/usb/gadget/Makefile. But this Makefile is not included
into U-Boot build when CONFIG_USB_GADGET is not set. As CONFIG_USB_DEVICE
cannot be enabled together with CONFIG_USB_GADGET it means that dependency
for musb udc code is not compiled during build. Fix it by including
drivers/usb/gadget dependency also when CONFIG_USB_DEVICE is set.

This patch fixes compile errors:

arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o: in function `musb_peri_ep0_rx':
u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `ep0_recv_setup'
arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o: in function `musb_peri_ep0_idle':
u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `ep0_recv_setup'
arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o: in function `musb_peri_ep0_zero_data_request':
u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_device_event_irq'
arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o: in function `musb_peri_ep0_idle':
u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `ep0_recv_setup'
arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o: in function `musb_peri_ep0_rx':
u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_rcv_complete'
arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o: in function `musb_peri_rx_ep':
u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_rcv_complete'
arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o: in function `udc_endpoint_write':
u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_tx_complete'
arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o: in function `udc_irq':
u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_device_event_irq'
arm-linux-gnueabi-ld.bfd: u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_device_event_irq'
arm-linux-gnueabi-ld.bfd: u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_device_event_irq'
arm-linux-gnueabi-ld.bfd: u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_device_event_irq'
arm-linux-gnueabi-ld.bfd: u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_device_event_irq'
arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o:u-boot/drivers/usb/musb/musb_udc.c: more undefined references to `usbd_device_event_irq' follow
arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o: in function `udc_setup_ep':
u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_alloc_urb'
arm-linux-gnueabi-ld.bfd: drivers/usb/musb/built-in.o: in function `udc_startup_events':
u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_device_event_irq'
arm-linux-gnueabi-ld.bfd: u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_device_event_irq'
arm-linux-gnueabi-ld.bfd: u-boot/drivers/usb/musb/musb_udc.c: undefined reference to `usbd_device_event_irq'
make: *** [Makefile:1762: u-boot] Error 1

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agoserial: usbtty: Send urb data in correct order
Pali Rohár [Sun, 7 Feb 2021 13:50:02 +0000 (14:50 +0100)]
serial: usbtty: Send urb data in correct order

Function next_urb() selects the last urb data buffer from linked list to
which next data from usbtty's puts function should be appended.

But to check if TX data still exists it is needed to look at the first urb
data buffer from linked list. So check for endpoint->tx_urb (first from the
linked list) instead of current_urb (the last from the linked list).

Successful call to udc_endpoint_write() may invalidate active urb and
allocate new urb in queue which invalidates pointer returned by next_urb()
function.

So call next_urb() prior putting data into urb buffer and call it every
time after using udc_endpoint_write() function to prevent sending data from
usbtty's puts function in incorrect order.

This patch fixes issue that usbtty code does not transmit data when they
are waiting in the tx queue.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
3 years agoserial: usbtty: Fix puts function
Pali Rohár [Sun, 7 Feb 2021 13:50:01 +0000 (14:50 +0100)]
serial: usbtty: Fix puts function

This function has incorrect implementation of prepending CR prior LF.
Without this patch it prepended CR prior whole string which is going to be
written and let LF without leading CR. Fix this issue by inserting CR at
correct place to make output on usbtty serial console more readable.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>