Commit graph

86115 commits

Author SHA1 Message Date
Simon Glass
708404c9e9 ide: Move ide_init() entirely within ide_probe()
Now that ide_probe() is the only caller of ide_init(), move all the code
into the probe function, so it is easier to refactor it.

Move ide_dev_desc[] into ide_probe() to, since it is the only user.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
db89e72302 ide: Move setting of vendor strings into ide_probe()
The current implementation adds this information in the block device's
probe() function, which is called in the blk_probe_or_unbind() in
ide_probe().

It is simpler to do this in ide_probe() itself, since the effect is the
same. This helps to consolidate use of ide_dev_desc[] which we would like
to remove.

Use strlcpy() to keep checkpatch happy.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
209ee95611 ide: Make ide_bus_ok a local variable
This is only used in one place now, so make it a local variable.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
b6483ea223 ide: Move bus init into a function
Move this code into a separate function which returns whether the bus was
found, or not.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
8b1b943a7a ide: Avoid preprocessor for CONFIG_LBA48
Use IS_ENABLED() instead for all conditions. Add the 'lba48' flag into
struct blk_desc always, since it uses very little space. Use a bool so
the meaning is clearer.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2023-04-27 13:51:06 -04:00
Simon Glass
c94a331061 ide: Avoid preprocessor for CONFIG_ATAPI
Use IS_ENABLED() instead for all conditions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
9367e6174a ide: Simplify success condition
Change the if() to remove extra brackets and check for the positive case
first, i.e. when a device is found. Exit the loop in that case, with the
retry logic in the 'else' part.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
6579bb00cf ide: Refactor confusing loop code
This code is hard to follow as it uses #ifdef in a strange way. Adjust
it to avoid the preprocessor. Drop the special return for the non-ATAPI
case since we can rely on tries becoming 0 and exiting the loop.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
2a165956ac ide: Change the retries variable
Use a 'tries' variable which starts at the number of tries we want to do,
rather than a 'retries' one that stops at either 1 or 2. This will make it
easier to refactor the code to avoid the horrible #ifdefs

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
1b33fd8317 ide: Make function static
Only one function is called from outside this file. Make all the others
static.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
646deed40b ide: Correct use of ATAPI
The use of atapi_read() was incorrect dropped. Fix this so that it will
be used when needed. Use a udevice for the first argument of atapi_read()
so it is consistent with ide_read().

This requires much of the ATAPI code to be brought out from behind the
existing #ifdef. It will still be removed by the compiler if it is not
needed.

Add an atapi flag to struct blk_desc so the information can be retained.

Fixes: 145df842b4 ("dm: ide: Add support for driver-model block devices")
Fixes: d0075059e4 ("ide: Drop non-DM code for BLK")
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
1486c90623 ide: Create a prototype for ide_set_reset()
This is used by a board so should be in the header file. Add it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
f8e87e73e4 ide: Drop weak functions
These are not used from outside this file anymore. Make them static and
remove them from the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
bc65bff5dc ide: Move a few functions further up the file
Move these functions so they appear before they are used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
62d13fa634 ide: Drop ide_device_present()
This function is not used anymore. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
80778f505c ide: Move ide_init() into probing
At present the code does ide_init() as a separate operation, then calls
device_probe() to copy over the information. We can call ide_init() from
probe just as easily.

The only difference is that using 'ide init' twice will do nothing.
However it already fails to copy over the new data in that case, so the
effect is the same. For now, unbind the block devices and remove the IDE
device, which causes the bus to be probed again. Later patches will fix
this up fully, so that all blk_desc data is copied across.

Since ide_reset() is only called from ide_init(), there is no need to init
the ide_dev_desc[] array. This is already done at the end of ide_init() so
drop this code.

The call to uclass_first_device() is now within the probe() function of
the same device, so does nothing. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
00a79f21c1 ide: Drop init for not using BLK
ALl boards use CONFIG_BLK now so this code is not used. Drop it and the
header-file #ifdef

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
0917851100 ide: Drop CONFIG_START_IDE
This is not used by any board. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
4d89f4bf2d ide: Use mdelay() for long delays
Rather than using very large numbers with udelay(), use mdelay(), which
is easier to follow.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Simon Glass
14a4f52b0d ide: Move ATA_CURR_BASE to C file
This is not used outside one C file. Move it out of the header to
reduce its visbility.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-27 13:51:06 -04:00
Tom Rini
caf0a88d9f Merge branch '2023-04-26-enable-bootstd-for-all-rockchip'
- Merge Simon's series that enables bootstd and the distro bootmeth
  there for all of Rockchip.
2023-04-26 13:29:49 -04:00
Simon Glass
4204c50cbb rockchip: Use the same boot_targets for all boards
It doesn't really matter if we mention things which are not present. For
example, if 'nvme' is included but the board does not support it, it just
continues with the next item in the list.

It is simpler to use the same target list for all boards, so drop the
different one for rk3399.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26 08:43:05 -04:00
Simon Glass
7755dc58af rockchip: Move to standard boot
Drop the distro-boot scripts and use standard boot instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Jonas Karlman <jonas@kwiboo.se>
2023-04-26 08:43:05 -04:00
Mathew McBride
484e701d74 bootstd: Use blk uclass device numbers to set efi bootdev
When loading a file from a block device, efiload_read_file
was using the seq_num of the device (e.g "35" of virtio_blk#35)
instead of the block device id (e.g what you get from running
the corresponding device scan command, like "virtio 0")

This cause EFI booting from these devices to fail as an
invalid device number is passed to blk_get_device_part_str:

  Scanning bootdev 'virtio-blk#35.bootdev':
  distro_efi_read_bootflow_file start (efi,fname=<NULL>)
  distro_efi_read_bootflow_file start (efi,fname=<NULL>)
  setting bootdev virtio, 35, efi/boot/bootaa64.efi, 00000000beef9a40, 170800
  efi_dp_from_name calling blk_get_device_part_str
  dev=virtio devnr=35 path=efi/boot/bootaa64.efi
  blk_get_device_part_str (virtio,35)
  blk_get_device_by_str (virtio, 35)
  ** Bad device specification virtio 35 **
  Using default device tree: dtb/qemu-arm.dtb
  No device tree available
  0  efi          ready   virtio       1  virtio-blk#35.bootdev.par efi/boot/bootaa64.efi
  ** Booting bootflow 'virtio-blk#35.bootdev.part_1' with efi
  blk_get_device_part_str (virtio,0:1)
  blk_get_device_by_str (virtio, 0)
  No UEFI binary known at beef9a40 (image buf=00000000beef9a40,addr=0000000000000000)
  Boot failed (err=-22)

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26 08:43:05 -04:00
Simon Glass
1aabe4ef2b bootstd: Adjust code ordering to work around compiler quirk
At present when debugging is off, bootdev_find_in_blk() sometimes fails
to find a valid bootflow, e.g. with virtio. Accessing the 'blk' variable
later in the function seems to correct it.

Move the 'ret' check before the debug statement and set the block device
again aftewards, to work around this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26 08:43:05 -04:00
Simon Glass
f9fb57c691 bootstd: Show a message sometimes if no bootflows are found
Enable some messages that might provide hints, but only for
CMD_BOOTFLOW_FULL since otherwise the -l flag is not available.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
2023-04-26 08:43:04 -04:00
Simon Glass
1736b4af0e bootstd: Report missing labels only when asked
Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
the -l flag cannot otherwise be set.

Suggested-by: Tom Rini <trini@konsulko.com>

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26 08:43:04 -04:00
Simon Glass
d80bb4f958 bootstd: Support booting EFI where multiple options exist
The current EFI implementation has a strange quirk where it watches
loaded files and uses the last-loaded file to determine the device that
is being booted from.

This is confusing with bootstd, where multiple options may exist. Even
loading a device tree will cause it to go wrong. There is no API for
passing this information, since the only entry into booting an EFI image
is the 'bootefi' command.

To work around this, call efi_set_bootdev() for EFI images, if possible,
just before booting.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26 08:43:04 -04:00
Simon Glass
27ff7806c1 virtio: Ensure PCI is set up first
Sometimes virtio may rely on PCI, or at least that is what the
distro_bootcmd script suggests. Add this in.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26 08:43:04 -04:00
Simon Glass
9f8351659a bootstd: Tweak bootflow logic for device tree
We should only store the FDT filename if we were able to determine one.
Adjust the logic for this.

This corrects the case where no FDT is needed to boot, such as with EFI
using ACPI.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-26 08:43:04 -04:00
Tom Rini
2356053a94 Merge branch '2023-04-25-assorted-updates-and-fixes'
- A few TI, mpc8379erdb and vexpress64 updates, some arm64 core updates,
  test cleanups, Xen cleanups, assorted code and Kconfig cleanups (many
  in preparation for using clang on ARM), psci pre-reloc fixes, enable
  PCI bus mastering for ATA devices, and a gpio-uclass bugfix
2023-04-26 08:24:34 -04:00
Rasmus Villemoes
0fac5c47e4 gpio-uclass: fix off-by-one in gpio_request_list_by_name_nodev()
By the time we jump to the err label, count represents the number of
gpios we've successfully requested. So by subtracting one, we fail to
free the most recently requested.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-25 15:31:28 -04:00
Michal Simek
b411ba9210 xen: Limit execution to EL1 only
Xen core_init() is calling HVC which should be called from EL1 level that's
why do Xen initialization only when U-Boot runs in EL1.

Signed-off-by: Michal Simek <michal.simek@amd.com>
2023-04-25 15:31:28 -04:00
Michal Simek
539486787e xen: Add dependency on armv8
U-Boot currently implements hypervisor calls only for ARM64 that's why add
dependency on ARM64. The hardware functionality is also available on
ARMv7a, but currently not supported by U-Boot, hence it is not added to the
list of dependencies here.

Signed-off-by: Michal Simek <michal.simek@amd.com>
2023-04-25 15:31:28 -04:00
Pali Rohár
7add47959e arm: omap3: Directly use SMC #1 in lowlevel_init.S
Since commit de39dc7162 ("arm: armv7-a: Compile and tune for armv7-a
instead of armv5") is used -march=armv7-a option for Omap3 platforms.

With directive ".arch_extension sec" it is possible for -march=armv7-a to
directly use ARM SMC instruction.

So enable ".arch_extension sec" in Omap3 lowlevel_init.S and replace hand
assembled ".word 0xe1600071" by "SMC #1".

Since commit 51d0638650 ("arm: omap-common: add secure smc entry") same
pattern is already used in arch/arm/cpu/armv7/omap-common/lowlevel_init.S.

Signed-off-by: Pali Rohár <pali@kernel.org>
2023-04-25 15:31:28 -04:00
John Keeping
51e0cacca7 tools: env: update lock path in README
Commit aeb40f1166 ("tools: env: use /run to store lockfile") updated the
path to the lockfile but did not update the documentation to match.

Use the new path in the documentation.

Fixes: aeb40f1166 ("tools: env: use /run to store lockfile")
Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-25 15:31:28 -04:00
Christian Gmeiner
cc6259832a ata: pci: enable bus mastering
The non DM code path already would enable pci bus mastering. Do the
same for the DM code path.

Fixes AHCI problems I am seeing on an Intel Apollolake device.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[trini: Use ahci_dev not dev in the calls]
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-04-25 15:31:28 -04:00
Sinan Akman
23fd87c489 mpc8379erdb: Convert to using DM_SERIAL
Convert to DM_SERIAL for mpc8379erdb.

Signed-off-by: Sinan Akman <sinan@writeme.com>
2023-04-25 15:31:28 -04:00
Tom Rini
e97c89cc15 qemu: dfu: Correct memset call in set_dfu_alt_info
When building with clang, we see:
board/emulation/common/qemu_dfu.c:51:24: warning: 'memset' call operates on objects of type 'char' while the size is based on a different type 'char *' [-Wsizeof-pointer-memaccess]

As we're calling memset with the length set to the size of the pointer
and not the size of the buffer. Correct this with a call of the size of
the buffer itself.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2023-04-25 15:31:28 -04:00
Tom Rini
ac44c6cf95 api: Rework menu, and make it depend on CC_IS_GCC
We can only use the old U-Boot API for standalone applications when
building U-Boot with GCC as it relies upon the "gd is a register" trick
that only GCC supports. Further, rework the rest of the options so that
they are in the API menu and only visible if API support is enabled.

Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-25 15:31:28 -04:00
Peng Fan
6326519f57 sysreset: psci: add psci_sysreset_get_status
Add weak function psci_sysreset_get_status for platform to define
their own reset status with CONFIG_SYSRESET enabled.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-04-25 15:31:28 -04:00
Peng Fan
439b9383ee sysreset: psci: enable DM_FLAG_PRE_RELOC
It is possible that cpu core may reset before relocation with PSCI reset

Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-04-25 15:31:28 -04:00
Peng Fan
1bd790bc4b firmware: psci: enable DM_FLAG_PRE_RELOC
It is possible that cpu core may reset before relocation with PSCI reset

Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-04-25 15:31:28 -04:00
Michal Simek
44cd761ad6 xen: Fix Kconfig dependencies
XEN config can be enabled by other platforms (even it doesn't need to make
sense) that's why fix dependencies. XEN (xenbus.c) requires sscanf (also
pvblock needs it). And PVBLOCK is inside drivers/xen folder which requires
XEN to be enabled.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-04-25 15:31:28 -04:00
Tom Rini
af2fde49fe pytest: Use --lazy with umount
Sometimes when doing tests on real hardware we sometimes run in to the
case where some of these mounts haven't been fully flushed.  Using the
--lazy option with umount will allow us to continue while letting the OS
handle flushing the data out still.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-25 15:31:28 -04:00
Tom Rini
73b39a76e3 usb: gadget: f_mass_storage: Rework do_request_sense slightly
When building with clang, it notes that sdinfo may be unused
uninitialized in some cases. This appears to be true from reading the
code, and we can simply set the variable to zero to start with and be as
correct as before.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Marek Vasut <marex@denx.de>
2023-04-25 15:31:27 -04:00
Tom Rini
51a765b376 boot/image-board.c: Silence warning in select_ramdisk
When building with clang we get a warning that rdaddr could be
uninitialized in one case. While this cannot functionally happen, we can
easily silence the warning.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-25 15:31:27 -04:00
Tom Rini
b5fc9f99d0 armv7: Use isb/dsb directly in start.S
Toolchains which do not directly support using "isb" and "dsb" directly
are no longer functionally supported in U-Boot. Furthermore, clang has
for a long time warned about using the alternate form that we were.
Update the code.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-25 15:31:27 -04:00
Tom Rini
a27c8ea7f7 arm: Centralize fixed register logic
When building for ARM64, we need to pass -ffixed-x18 and otherwise pass
-ffixed-r9. Rather than having this logic in two places, we can do this
once in arch/arm/config.mk. Further, while gcc will ignore being passed
both -ffixed-r9 and -ffixed-x18 and simply use -ffixed-x18, clang will
note that -ffixed-r9 is not used. Remove this duplication to also remove
the warning.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-25 15:31:27 -04:00
Tom Rini
4ad6850d2b clang: Don't look for libgcc
In the case of using clang to build, and having not already enabled the
private libgcc, do not look for it, as it will not be found nor
required.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-25 15:31:27 -04:00