]> git.dujemihanovic.xyz Git - u-boot.git/log
u-boot.git
20 months agosmegw01: Enable EMMC boot from multiple partitions
Eduard Strehlau [Wed, 26 Apr 2023 16:04:54 +0000 (13:04 -0300)]
smegw01: Enable EMMC boot from multiple partitions

GPT Partition labels are used for determining the right
root filesystem to boot from.

The U-Boot environment is configured to reside in the eMMC hardware
boot partition we are currently booted from.

This should enable a dual copy approach for upgrading the bootloader.
One can overwrite the inactive hardware partition with new bootloader
and environment and afterwards switch the eMMC boot partition for an
atomic bootloader switch.

Signed-off-by: Eduard Strehlau <eduard@lionizers.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
20 months agosmegw01: Only commit to new partition if update was successful
Eduard Strehlau [Wed, 26 Apr 2023 16:04:53 +0000 (13:04 -0300)]
smegw01: Only commit to new partition if update was successful

When performing rootfs update via swupdate, it is convenient to check the
'ustate' variable to decide whether the update succeeded or not.

Signed-off-by: Eduard Strehlau <eduard@lionizers.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
20 months agosmegw01: Run altbootcmd in the case of failure
Eduard Strehlau [Wed, 26 Apr 2023 16:04:52 +0000 (13:04 -0300)]
smegw01: Run altbootcmd in the case of failure

Run the altbootcmd script if any step of bootcmd fails.

This ensures that always a valid image can be run.

Signed-off-by: Eduard Strehlau <eduard@lionizers.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
20 months agosmegw01: Add altbootcmd
Eduard Strehlau [Wed, 26 Apr 2023 16:04:51 +0000 (13:04 -0300)]
smegw01: Add altbootcmd

Add an altbootcmd script, which is convenient way to integrate with
swupdate and perform a roll back of the previous working version in the
case of update failure.

Signed-off-by: Eduard Strehlau <eduard@lionizers.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
20 months agosmegw01: Select bootcount support
Eduard Strehlau [Wed, 26 Apr 2023 16:04:50 +0000 (13:04 -0300)]
smegw01: Select bootcount support

Add automatic boot counter that increases after every
reset. After a power-on reset, it will be initialized with 1,
and each reboot will increment the value by 1. By default it is
disabled if bootlimit isn't set.

Signed-off-by: Eduard Strehlau <eduard@lionizers.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
20 months agosmegw01: Select CONFIG_CMD_SQUASHFS
Eduard Strehlau [Wed, 26 Apr 2023 16:04:49 +0000 (13:04 -0300)]
smegw01: Select CONFIG_CMD_SQUASHFS

Select CONFIG_CMD_SQUASHFS so that the SquashFS U-Boot commands
are available.

Signed-off-by: Eduard Strehlau <eduard@lionizers.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
20 months agosmegw01: Enable setting additional boot params
Eduard Strehlau [Wed, 26 Apr 2023 16:04:48 +0000 (13:04 -0300)]
smegw01: Enable setting additional boot params

Introduce EXTRA_BOOTPARAMS to allow passing additional parameters
to kernel command line. This is useful for debugging purposes.

Signed-off-by: Eduard Strehlau <eduard@lionizers.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
20 months agoarm: imx8m: remove unused and obsolete board_fix_fdt() in SOC context
Hugo Villeneuve [Tue, 25 Apr 2023 14:19:35 +0000 (10:19 -0400)]
arm: imx8m: remove unused and obsolete board_fix_fdt() in SOC context

It doesn't seem appropriate for arch/SOC to use a board-level
functionality (CONFIG_OF_BOARD_FIXUP), because this prevents boards
that need to do FDT fixup from using that feature.

Also, this code is completely dead and useless (from comments by
Rasmus Villemoes on the mailing list):

  - No in-tree imx8m-based board seems to set CONFIG_OF_BOARD_FIXUP
  - The nodes which that function wants to disable don't even exist in
    the U-Boot copy of imx8mp.dtsi.

This code was introduced in commit 35bb60787b88. It seems to be some
random import of code from downstream NXP U-Boot, with a commit
message that makes no sense in upstream context.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Fabio Estevam <festevam@denx.de>
20 months agoimx: fix get_boot_device() for imx8
Tim Harvey [Mon, 24 Apr 2023 16:33:44 +0000 (09:33 -0700)]
imx: fix get_boot_device() for imx8

commit 787f04bb6a0a ("imx: add USB2_BOOT type") broke get_boot_device()
for IMX8 which affects booting from SDP due to boot_instance being
non-zero.

Fix this by only using boot_instance for imx8ulp and imx9.

Fixes: 787f04bb6a0a ("imx: add USB2_BOOT type")
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Fabio Estevam <festevam@denx.de>
20 months agoimx6: clock: print real pixel clock rate
Dario Binacchi [Sat, 22 Apr 2023 14:11:19 +0000 (16:11 +0200)]
imx6: clock: print real pixel clock rate

Add debug messages to print the real pixel clock rate, which may not be
the requested one.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
20 months agoimx6: clock: add support to get LCD pixel clock rate
Dario Binacchi [Sat, 22 Apr 2023 14:11:18 +0000 (16:11 +0200)]
imx6: clock: add support to get LCD pixel clock rate

Add the get_lcd_clk() function to get the LCD pixel clock rate.

The patch has been tested on imx6ul platform.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
20 months agoimx6: clock: improve calculations to get the PLL video rate
Dario Binacchi [Sat, 22 Apr 2023 14:11:17 +0000 (16:11 +0200)]
imx6: clock: improve calculations to get the PLL video rate

During some tests to check the pixel clock rate in the transition from
U-Boot to the Linux kernel, I noticed that with the same configuration
of the registers the debug messages reported different rates.

The same Linux kernel calculations are now used to get the PLL video
rate.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
20 months agoimx: support i.MX8QM DMSSE20 a1 board
Oliver Graute [Fri, 21 Apr 2023 10:11:50 +0000 (12:11 +0200)]
imx: support i.MX8QM DMSSE20 a1 board

Add i.MX8QM DMSSE20 a1 board support

U-Boot 2023.04-00030-g7be2f547b2 (Apr 21 2023 - 11:11:43 +0200)

Model: Advantech iMX8QM DMSSE20
Board: DMS-SE20A1 8GB
Build: SCFW 549b1e18, SECO-FW c9de51c0, ATF 5782363
Boot:  USB
DRAM:  8 GiB
Core:  100 devices, 19 uclasses, devicetree: separate
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial@5a060000
Out:   serial@5a060000
Err:   serial@5a060000
Net:   eth0: ethernet@5b040000
Warning: ethernet@5b050000 (eth1) using random MAC address - 32:05:0c:f9:5e:10
, eth1: ethernet@5b050000
Hit any key to stop autoboot:  0

Signed-off-by: Oliver Graute <oliver.graute@kococonnector.com>
20 months agoimx8mn: buffer overflow in low_drive_gpu_freq()
Heinrich Schuchardt [Mon, 17 Apr 2023 23:37:21 +0000 (01:37 +0200)]
imx8mn: buffer overflow in low_drive_gpu_freq()

Avoid a buffer overflow if assigned-clock-rates has less than two elements.

Fixes: 98bcdf16356c ("imx8mn: Add low drive mode support for DDR4/LPDDR4 EVK")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
20 months agopico-imx6ul: Convert to CONFIG_DM_SERIAL
Fabio Estevam [Sun, 16 Apr 2023 17:55:04 +0000 (14:55 -0300)]
pico-imx6ul: Convert to CONFIG_DM_SERIAL

The conversion to CONFIG_DM_SERIAL is mandatory, so select
this option.

Signed-off-by: Fabio Estevam <festevam@denx.de>
20 months agoboard: mntre: imx8mq: Add MNT Reform 2 board support
Patrick Wildt [Sun, 5 Feb 2023 23:48:26 +0000 (00:48 +0100)]
board: mntre: imx8mq: Add MNT Reform 2 board support

The MNT Reform 2 is a modular DIY laptop.  In its initial version it
is based on the BoundaryDevices i.MX8MQ SoM.  Some parts have been
lifted from BoundaryDevices official U-Boot downstream project.

Signed-off-by: Patrick Wildt <patrick@blueri.se>
Tested-by: Vagrant Cascadian <vagrant@debian.org>
Tested-by: Vagrant Cascadian <vagrant@debian.org>
Signed-off-by: Stefano Babic <sbabic@denx.de>
20 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-spi
Tom Rini [Mon, 1 May 2023 17:29:52 +0000 (13:29 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-spi

- cadence-quadspi fixes (Apurva Nandan, Dhruva Gole)
- CHIP_ERASE optimization (Marek Vasut)
- fixups for s25fs512s (Takahiro Kuwano)

20 months agoPrepare v2023.07-rc1
Tom Rini [Mon, 1 May 2023 16:02:02 +0000 (12:02 -0400)]
Prepare v2023.07-rc1

Signed-off-by: Tom Rini <trini@konsulko.com>
20 months agoconfigs: Resync with savedefconfig
Tom Rini [Mon, 1 May 2023 15:50:26 +0000 (11:50 -0400)]
configs: Resync with savedefconfig

Rsync all defconfig files using moveconfig.py

Signed-off-by: Tom Rini <trini@konsulko.com>
20 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi
Tom Rini [Mon, 1 May 2023 01:29:50 +0000 (21:29 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi

Please pull the second part of the sunxi pull request for this cycle.
Another bunch of patches that replace old-school U-Boot hacks with
proper DM based code, this time for the raw NAND flash driver, and the
USB PHY VBUS detection code. Plus two smaller patches that were sitting
in my inbox for a while.

Gitlab CI passed. In lack of some supported board with NAND flash I
couldn't really test this part, but apparently this was tested by the
reviewer. I briefly ran the branch on some boards with USB-OTG, and
this still worked.

20 months agoMerge branch 'for-2023.07' of https://source.denx.de/u-boot/custodians/u-boot-mpc8xx
Tom Rini [Sat, 29 Apr 2023 13:29:41 +0000 (09:29 -0400)]
Merge branch 'for-2023.07' of https://source.denx.de/u-boot/custodians/u-boot-mpc8xx

This pull request adds support for the last CPU board from
CS GROUP France (previously CSSI).

That CPU board called CMPCPRO has a mpc8321E CPU (Family PQII PRO hence
its name) and can be plugged in place of the CMPC885 board.

In order to support that new board, the following changes are included
in this series:
- Make the mpc8xx watchdog driver more generic for reusing it
with mpc83xx
- Fix various small problems on mpc83xx platform
- Add a GPIO Driver for QE GPIOs
- Add support for mpc832x into mpc83xx SPI driver
- Refactor existing board code that will be shared with new board
- Add the new board

20 months agoMerge tag 'dm-pull-28apr23' of https://source.denx.de/u-boot/custodians/u-boot-dm
Tom Rini [Fri, 28 Apr 2023 23:00:01 +0000 (19:00 -0400)]
Merge tag 'dm-pull-28apr23' of https://source.denx.de/u-boot/custodians/u-boot-dm

sandbox and fdt bug fixes / tweaks
various other minor fixes

20 months agofdt: Indicate that people should use the ofnode API
Simon Glass [Tue, 25 Apr 2023 16:27:21 +0000 (10:27 -0600)]
fdt: Indicate that people should use the ofnode API

Add a note to the comment at the top of this file.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agofdt_support: fix comments syntax error
Hugo Villeneuve [Mon, 24 Apr 2023 20:51:50 +0000 (16:51 -0400)]
fdt_support: fix comments syntax error

Fix comments syntax error in fdt_node_offset_by_compat_reg()
description:
    compatiable -> compatible

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agocore: fdtaddr: use map_sysmem() as cast for the return
Johan Jonker [Sun, 23 Apr 2023 09:19:41 +0000 (11:19 +0200)]
core: fdtaddr: use map_sysmem() as cast for the return

For the devfdt_get_addr_index_ptr() and devfdt_get_addr_size_index_ptr()
function use map_sysmem() function as cast for the return for use in
sandbox. Also fix sandbox test.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Drop second hunk:
Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agotools: Fall back to importlib_resources on Python 3.6
Jan Kiszka [Sat, 22 Apr 2023 14:42:48 +0000 (16:42 +0200)]
tools: Fall back to importlib_resources on Python 3.6

importlib.resources became part of 3.7 only. Allow using distros with
3.6 and the importlib_resources backport.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agotest: fdt: Fix copyright message
Marek Vasut [Sat, 22 Apr 2023 12:59:58 +0000 (14:59 +0200)]
test: fdt: Fix copyright message

Drop the map_to_sysmem() copy paste error. No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agopatman: fix class TestFunctional
Heinrich Schuchardt [Thu, 20 Apr 2023 18:07:29 +0000 (20:07 +0200)]
patman: fix class TestFunctional

Variable orig_dir cannot be used in the finally block if it has not be
assigned outside of the try block.

tools/patman/func_test.py:523:21:
E0601: Using variable 'orig_dir' before assignment
(used-before-assignment)

tools/patman/func_test.py:691:21:
E0601: Using variable 'orig_dir' before assignment
(used-before-assignment)

Fixes: fd70986a62af ("patman: Add a test that uses gitpython")
Fixes: be051c0c7741 ("patman: Detect missing upstream in CountCommitsToBranch")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agobinman: Use expanduser instead of HOME
Simon Glass [Wed, 19 Apr 2023 21:21:14 +0000 (15:21 -0600)]
binman: Use expanduser instead of HOME

There may not be a HOME environment variable, so use the os.expanduser()
function instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agodm: core: introduce uclass_get_device_by_of_path()
Rasmus Villemoes [Thu, 13 Apr 2023 15:17:03 +0000 (17:17 +0200)]
dm: core: introduce uclass_get_device_by_of_path()

There's quite a few instances of board-specific code doing

  off = fdt_path_offset(gd->fdt_blob, ...);
  ...
  ret = uclass_get_device_by_of_offset(..., off, &dev);

looking for an eeprom or a pmic via some alias. Such code can be
simplified a little if we have a helper for directly getting a device
via device tree path (including being given as an alias).

Implement it in terms of ofnode rather than raw offsets so that this
will work whether live tree is enabled or not.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
20 months agouclass: add uclass_find_device_by_phandle_id() helper
Rasmus Villemoes [Thu, 13 Apr 2023 15:16:11 +0000 (17:16 +0200)]
uclass: add uclass_find_device_by_phandle_id() helper

The functions uclass_find_device_by_phandle() and
uclass_get_device_by_phandle_id() both loop over a given uclass
looking for a device with a given phandle. Factor that out to a common
helper.

For now, there are no (known potential) users of the new helper
outside uclass.c, so make it static.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Simon Glass <sjg@chromium.org>
Fix warning on sandbox_spl; fix code style:
Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agosandbox: disable tracing before unmapping RAM
Pavel Skripkin [Wed, 12 Apr 2023 18:55:44 +0000 (21:55 +0300)]
sandbox: disable tracing before unmapping RAM

Currently doing 'reset' command in sandbox with tracing enabled causes
SIGSEV

```
Hit any key to stop autoboot:  0
=>
=>
=> reset
resetting ...
Segmentation fault (core dumped)

```

Tracing callback uses RAM buffer for storing tracing reports, but
state_uninit() function unmaps whole RAM, which causes SIGSEV on umapped
memory inside tracing subsystem.

Fix it by disabling tracing before unmapping memory

Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Add missing check for CONFIG_TRACE:
Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agosandbox: correct posix_types.h define
Heinrich Schuchardt [Mon, 17 Apr 2023 07:08:56 +0000 (09:08 +0200)]
sandbox: correct posix_types.h define

arch/arm/include/asm/posix_types.h and
arch/sandbox/include/asm/posix_types.h should use different defines.

Add SPDX header.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agobootflow: Rework do_bootflow_menu() slightly
Tom Rini [Thu, 6 Apr 2023 14:03:33 +0000 (10:03 -0400)]
bootflow: Rework do_bootflow_menu() slightly

When building this with clang, we get a warning such as:
cmd/bootflow.c:412:27: warning: variable 'bflow' is uninitialized when used here [-Wuninitialized]
        printf("Selected: %s\n", bflow->os_name ? bflow->os_name : bflow->name);
                                 ^~~~~

And a suggestion to just initialize bflow to NULL. This would however
would be ensuring a bad dereference. Instead, looking at the function we
rework things so that when CONFIG_EXPO is not enabled (and so, no UI) we
error early and would never reach this point in the code.  Simplify the
rest slightly as well while at this.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agodm: core: Make aliases_lookup static
Bin Meng [Wed, 5 Apr 2023 14:37:55 +0000 (22:37 +0800)]
dm: core: Make aliases_lookup static

aliases_lookup is only referenced in of_access.c

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agodrivers: tee: sandbox: Fix SCP03 control emulator
Jorge Ramirez-Ortiz [Sat, 8 Apr 2023 15:35:31 +0000 (17:35 +0200)]
drivers: tee: sandbox: Fix SCP03 control emulator

Fix and document the Secure Channel Protocol03 emulator.

Fixes: 5a8783c80c39 ("drivers: tee: sandbox: SCP03 control emulator")
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agosandbox: fix return type of os_filesize()
Heinrich Schuchardt [Wed, 5 Apr 2023 09:34:15 +0000 (11:34 +0200)]
sandbox: fix return type of os_filesize()

Given a file ../img of size 4294967296 with GPT partition table and
partitions:

=> host bind 0 ../img
=> part list host 0
Disk host-0.blk not ready

The cause is os_filesize() returning int. File sizes must use off_t.

Correct all uses of os_filesize() too.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoMAINTAINERS: assign include/os.h
Heinrich Schuchardt [Wed, 5 Apr 2023 09:26:38 +0000 (11:26 +0200)]
MAINTAINERS: assign include/os.h

os.h is only used by the sandbox.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agobinman: Use unsigned long over typedef ulong
Andrew Davis [Tue, 4 Apr 2023 18:45:41 +0000 (13:45 -0500)]
binman: Use unsigned long over typedef ulong

The header binman_sym.h depends on ulong typedef but does not include
types.h. This means the header must be included after including types.h
or a header that includes it.

We could include types.h but instead let's just switch from ulong
to directly using unsigned long. This removes the need for typedef'ing
it in some of the tests, so also remove those.

Signed-off-by: Andrew Davis <afd@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agocommon: static fdt_simplefb_enable_existing_node()
Heinrich Schuchardt [Mon, 3 Apr 2023 18:46:50 +0000 (20:46 +0200)]
common: static fdt_simplefb_enable_existing_node()

Function fdt_simplefb_enable_existing_node() should be static as it is not
used outside common/fdt_simplefb.c.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoboot: vbe_simple: Fix vbe_simple_read_bootflow() dependency
Bin Meng [Mon, 3 Apr 2023 03:40:26 +0000 (11:40 +0800)]
boot: vbe_simple: Fix vbe_simple_read_bootflow() dependency

vbe_simple_read_bootflow() calls vbe_simple_read_bootflow_fw()
which is only available when BOOTMETH_VBE_SIMPLE_FW is on.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosandbox: mark sandbox_exit() as no return.
Heinrich Schuchardt [Sat, 1 Apr 2023 07:54:25 +0000 (09:54 +0200)]
sandbox: mark sandbox_exit() as no return.

Fix a -Wimplicit-fallthrough warning in sandbox_sysreset_request().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosandbox: spi: sandbox_sf_process_cmd() missing fallthrough
Heinrich Schuchardt [Sat, 1 Apr 2023 07:38:05 +0000 (09:38 +0200)]
sandbox: spi: sandbox_sf_process_cmd() missing fallthrough

Add a missing fallthrough macro to avoid a -Wimplicit-fallthrough warning.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosandbox: fix sandbox_hub_submit_control_msg()
Heinrich Schuchardt [Sat, 1 Apr 2023 06:57:33 +0000 (08:57 +0200)]
sandbox: fix sandbox_hub_submit_control_msg()

Avoid incorrect fall through:
A USB_RT_HUB request should not be treated as USB_RT_PORT.

Simplify the coding:
Avoid duplicate debug() statements.

This fixes all -Wimplicit-fallthrough warnings.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosandbox: fix fall through in sandbox_flash_bulk()
Heinrich Schuchardt [Sat, 1 Apr 2023 06:24:52 +0000 (08:24 +0200)]
sandbox: fix fall through in sandbox_flash_bulk()

Handling of SANDBOX_FLASH_EP_OUT should never fall through to
SANDBOX_FLASH_EP_IN.

This addresses a warning shown when compiling with
-Wimplicit-fallthrough.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoboard: cssi: Add CPU board CMPCPRO
Christophe Leroy [Tue, 4 Apr 2023 11:09:36 +0000 (13:09 +0200)]
board: cssi: Add CPU board CMPCPRO

CSSI has another CPU board, similar to the CMPC885 board
that get plugged on the two base boards MCR3000_2G and MIAE.

That CPU board is called CMPCPRO because it has a MPC8321E CPU,
also known as Power QUICC II PRO.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
20 months agoboard: cssi: Move all mother board code into common.c
Christophe Leroy [Wed, 5 Apr 2023 16:50:23 +0000 (18:50 +0200)]
board: cssi: Move all mother board code into common.c

All the code used to manage the mother boards will be
common to soon to come CPU board.

Move all that code into common.c

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
20 months agoboard: cssi: Refactor EEPROM read
Christophe Leroy [Wed, 5 Apr 2023 14:05:36 +0000 (16:05 +0200)]
board: cssi: Refactor EEPROM read

On cmpc885 board, the ethernet addresses are stored in an
EEPROM that is accessed through SPI.

A 3 bytes command is sent to the chip then the content
gets read. At the time being a single block access is
performed, ignoring the first 3 bytes read.

Reword the SPI transfer to first send 3 bytes then
receive the content of the EEPROM so that there don't be
3 dummy bytes at the beginning of the buffer.

And move the function into common.c so that it can be
reused by the board that will be added in a future patch.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
20 months agoboard: cssi: Create dedicated file for common sources
Christophe Leroy [Tue, 4 Apr 2023 10:42:15 +0000 (12:42 +0200)]
board: cssi: Create dedicated file for common sources

In preparation of the new cssi board called cmpcpro which
we be introduce in a future patch, move common
functions into a dedicated file in a common directory.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
20 months agoboard: cssi: Migrate to hashed password
Christophe Leroy [Fri, 28 Apr 2023 15:42:33 +0000 (17:42 +0200)]
board: cssi: Migrate to hashed password

Use a hashed password instead of clear text in order to
improve board security.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
20 months agoKconfig: Remove an impossible condition
Samuel Holland [Sun, 22 Jan 2023 17:23:51 +0000 (11:23 -0600)]
Kconfig: Remove an impossible condition

ARCH_SUNXI selects BINMAN, so the condition "!BINMAN && ARCH_SUNXI"
is impossible to satisfy.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agophy: sun4i-usb: Do not drive VBUS with external VBUS present
Samuel Holland [Fri, 15 Jul 2022 03:34:53 +0000 (22:34 -0500)]
phy: sun4i-usb: Do not drive VBUS with external VBUS present

It is possible to use host-side USB with externally-provided VBUS. For
example, some USB OTG cables have an extra power input which powers
both the board and the USB peripheral.

To support this setup, skip enabling the VBUS switch/regulator if VBUS
voltage is already present. This behavior matches the Linux PHY driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agogpio: axp/sunxi: Remove virtual VBUS detection GPIO
Samuel Holland [Sun, 22 Jan 2023 23:46:22 +0000 (17:46 -0600)]
gpio: axp/sunxi: Remove virtual VBUS detection GPIO

Now that this functionality is modeled using the device tree and
regulator uclass, the named GPIO is not referenced anywhere. Remove it.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agosunxi: Switch to PMIC USB power supply VBUS detection
Samuel Holland [Sun, 22 Jan 2023 23:46:21 +0000 (17:46 -0600)]
sunxi: Switch to PMIC USB power supply VBUS detection

Update boards to use the USB power supply driver, as referenced in the
device tree, instead of a virtual GPIO. This removes the need for some
DM-incompatible special cases in the GPIO driver.

The following five boards used AXP0-VBUS-DETECT in their config, but are
missing the "usb0_vbus_power-supply" property in their device tree:
 - Ainol_AW1_defconfig / sun7i-a20-ainol-aw1
 - Cubieboard4_defconfig / sun9i-a80-cubieboard4
 - Merrii_A80_Optimus_defconfig / sun9i-a80-optimus
 - Yones_Toptech_BD1078_defconfig / sun7i-a20-yones-toptech-bd1078
 - Yones_Toptech_BS1078_V2_defconfig /
   sun6i-a31s-yones-toptech-bs1078-v2

None of those five boards have the MUSB controller (USB OTG) enabled in
their device trees, so this change should not break anything for them.

Additionally, the following board intentionally omits the property
because VBUS is always enabled:
 - Nintendo_NES_Classic_Edition_defconfig /
   sun8i-r16-nintendo-nes-classic

The PHY driver already assumes VBUS is enabled when no detection method
is available, so again this will not cause any problems.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agopower: regulator: Add a driver for the AXP USB power supply
Samuel Holland [Sun, 22 Jan 2023 23:46:20 +0000 (17:46 -0600)]
power: regulator: Add a driver for the AXP USB power supply

This driver reports the presence/absence of voltage on the PMIC's USB
VBUS pin. This information is used by the USB PHY driver. The
corresponding Linux driver uses the power supply class, which does not
exist in U-Boot. UCLASS_REGULATOR seems to be the closest match.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agomtd: nand: sunxi: Pass the device to the init function
Samuel Holland [Sun, 22 Jan 2023 22:06:36 +0000 (16:06 -0600)]
mtd: nand: sunxi: Pass the device to the init function

This more closely matches the U-Boot driver to the Linux version.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Michael Trimarchi <micahel@amarulasolutions.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agomtd: nand: sunxi: Convert to the driver model
Samuel Holland [Sun, 22 Jan 2023 22:06:35 +0000 (16:06 -0600)]
mtd: nand: sunxi: Convert to the driver model

Clocks, resets, and pinmuxes are now handled by the driver model, so the
only thing the "board" code needs to do is load the driver. This matches
the pattern used by other DM raw NAND drivers (there is no NAND uclass).

The actual board code is now only needed in SPL.

Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agomtd: nand: sunxi: Convert from fdtdec to ofnode
Samuel Holland [Sun, 22 Jan 2023 22:06:34 +0000 (16:06 -0600)]
mtd: nand: sunxi: Convert from fdtdec to ofnode

As a first step toward converting this driver to the driver model, use
the ofnode abstraction to replace direct references to the FDT blob.

Using ofnode_read_u32_index removes an extra pair of loops and makes the
allwinner,rb property optional, matching the devicetree binding.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agomtd: nand: sunxi: Remove an unnecessary check
Samuel Holland [Sun, 22 Jan 2023 22:06:33 +0000 (16:06 -0600)]
mtd: nand: sunxi: Remove an unnecessary check

Each chip is required to have a unique CS number ("reg" property) in the
range 0-7, so there is no need to separately count the number of chips.

Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agopinctrl: sunxi: Add NAND pinmuxes
Samuel Holland [Sun, 22 Jan 2023 22:06:32 +0000 (16:06 -0600)]
pinctrl: sunxi: Add NAND pinmuxes

NAND is always at function 2 on port C.

Pin lists and mux values were taken from the Linux drivers.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agoclk: sunxi: Add NAND clocks and resets
Samuel Holland [Sun, 22 Jan 2023 22:06:31 +0000 (16:06 -0600)]
clk: sunxi: Add NAND clocks and resets

Currently NAND clock setup is done in board code, both in SPL and in
U-Boot proper. Add the NAND clocks/resets here so they can be used by
the "full" NAND driver once it is converted to the driver model.

The bit locations are copied from the Linux CCU drivers.

Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agosunxi: binman: Fix U-Boot offset when SPL is not 32 KiB
Samuel Holland [Sat, 21 Jan 2023 23:25:17 +0000 (17:25 -0600)]
sunxi: binman: Fix U-Boot offset when SPL is not 32 KiB

On sunxi boards, SPL looks for U-Boot at a 32 KiB offset, unless SPL is
larger than 32 KiB, in which case U-Boot immediately follows SPL. See
the logic in spl_mmc_get_uboot_raw_sector() and spl_spi_load_image().

In two cases, the existing binman description mismatches the SPL code.
For 64-bit boards, binman would place U-Boot immediately following SPL,
even if SPL is smaller than 32 KiB. This can happen when SPL MMC support
is disabled (i.e. when booting from SPI flash).

In contrast, for 32-bit boards, binman would place U-Boot at 32 KiB,
even if SPL is larger than that. This happens because the 'offset'
property does not consider the size of previous entries.

Fix both issues by setting a minimum size for the SPL entry, which
exactly matches the logic in the SPL code. Unfortunately, this size must
be provided as a magic number, since none of the relevant config symbols
(SPL_PAD_TO, SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, and SYS_SPI_U_BOOT_OFFS)
are guaranteed to be defined in all cases.

Fixes: cfa3db602caf ("sunxi: Convert 64-bit boards to use binman")
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
20 months agoMerge branch '2023-04-27-introduce-nvm-xip-block-storage-emulation'
Tom Rini [Thu, 27 Apr 2023 23:22:38 +0000 (19:22 -0400)]
Merge branch '2023-04-27-introduce-nvm-xip-block-storage-emulation'

To quote the author:
Adding block storage emulation for NVM XIP flash devices.

Some paltforms such as Corstone-1000 need to see NVM XIP raw flash
as a block storage device with read only capability.

Here NVM flash devices are devices with addressable
memory (e.g: QSPI NOR flash).

The NVM XIP block storage emulation provides the following features:

- Emulate NVM XIP raw flash as a block storage device with read only capability
- Being generic by design and can be used by any platform
- Device tree node
- Platforms can use multiple NVM XIP devices at the same time by defining a
  DT node for each one of them
- A generic NVMXIP block driver allowing to read from the XIP flash
- A generic NVMXIP Uclass driver for binding the block device
- A generic NVMXIP QSPI driver
- Implemented on top of memory-mapped IO (using readq macro)
- Enabling NVMXIP in sandbox64
- A sandbox test case
- Enabling NVMXIP in Corstone1000 platform as a use case

For more details please refer to doc/develop/driver-model/nvmxip.rst

20 months agosandbox64: add a test case for UCLASS_NVMXIP
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:58 +0000 (10:11 +0100)]
sandbox64: add a test case for UCLASS_NVMXIP

provide a test for NVM XIP devices

The test case allows to make sure of the following:

- The NVM XIP QSPI devices are probed
- The DT entries are read correctly
- the data read from the flash by the NVMXIP block driver is correct

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
20 months agocorstone1000: enable NVM XIP QSPI flash
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:57 +0000 (10:11 +0100)]
corstone1000: enable NVM XIP QSPI flash

add the QSPI flash device with block storage capability

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
20 months agocorstone1000: add NVM XIP QSPI device tree node
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:56 +0000 (10:11 +0100)]
corstone1000: add NVM XIP QSPI device tree node

add QSPI flash device node for block storage access

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
20 months agosandbox64: add support for NVMXIP QSPI
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:55 +0000 (10:11 +0100)]
sandbox64: add support for NVMXIP QSPI

enable NVMXIP QSPI for sandbox 64-bit

Adding two NVM XIP QSPI storage devices.

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agosandbox64: fix: return unsigned long in readq()
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:54 +0000 (10:11 +0100)]
sandbox64: fix: return unsigned long in readq()

make readq return unsigned long

readq should return 64-bit data

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agodrivers/mtd/nvmxip: introduce QSPI XIP driver
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:53 +0000 (10:11 +0100)]
drivers/mtd/nvmxip: introduce QSPI XIP driver

add nvmxip_qspi driver under UCLASS_NVMXIP

The device associated with this driver is the parent of the blk#<id> device
nvmxip_qspi can be reused by other platforms. If the platform
has custom settings to apply before using the flash, then the platform
can provide its own parent driver belonging to UCLASS_NVMXIP and reuse
nvmxip-blk driver. The custom driver can be implemented like nvmxip_qspi in
addition to the platform custom settings.

Platforms can use multiple NVM XIP devices at the same time by defining a
DT node for each one of them.

For more details please refer to doc/develop/driver-model/nvmxip_qspi.rst

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
20 months agodrivers/mtd/nvmxip: introduce NVM XIP block storage emulation
Abdellatif El Khlifi [Mon, 17 Apr 2023 09:11:52 +0000 (10:11 +0100)]
drivers/mtd/nvmxip: introduce NVM XIP block storage emulation

add block storage emulation for NVM XIP flash devices

Some paltforms such as Corstone-1000 need to see NVM XIP raw flash
as a block storage device with read only capability.

Here NVM flash devices are devices with addressable
memory (e.g: QSPI NOR flash).

The implementation is generic and can be used by different platforms.

Two drivers are provided as follows.

  nvmxip-blk :

    a generic block driver allowing to read from the XIP flash

  nvmxip Uclass driver :

        When a device is described in the DT and associated with
        UCLASS_NVMXIP, the Uclass creates a block device and binds it with
 the nvmxip-blk.

Platforms can use multiple NVM XIP devices at the same time by defining a
DT node for each one of them.

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
20 months agoMerge branch '2023-04-27-IDE-code-cleanups'
Tom Rini [Thu, 27 Apr 2023 20:33:58 +0000 (16:33 -0400)]
Merge branch '2023-04-27-IDE-code-cleanups'

To quote the author:
This code was converted to driver model a long time again but it was a
pretty rough conversion. It introduced a few minor bugs, e.g. the device
capacity is incorrect and some flags are lost (such as lba48).

This series tidies up the code and fixes these bugs. This involves quite
a bit of refactoring, so it is done one patch at a time for easier
review.

20 months agoide: Make use of U-Boot types
Simon Glass [Tue, 25 Apr 2023 16:54:55 +0000 (10:54 -0600)]
ide: Make use of U-Boot types

Use standard U-Boot types in the file to make the code less verbose.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Simplify expressions and hex values
Simon Glass [Tue, 25 Apr 2023 16:54:54 +0000 (10:54 -0600)]
ide: Simplify expressions and hex values

The code has quite a few unnecessary brackets and comparisons to zero,
etc. Fix these up as well as some upper-case hex values and use of 0x in
printf() strings.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Convert to use log_debug()
Simon Glass [Tue, 25 Apr 2023 16:54:53 +0000 (10:54 -0600)]
ide: Convert to use log_debug()

Avoid the use of the function name in a few of the debug() calls, since
this causes a checkpatch warning. Convert all other calls too.

Use lower-case hex consistently.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Tidy up ide_reset()
Simon Glass [Tue, 25 Apr 2023 16:54:52 +0000 (10:54 -0600)]
ide: Tidy up ide_reset()

Avoid using #ifdef and use a single function declaration, so it is easier
to read.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Correct LBA setting
Simon Glass [Tue, 25 Apr 2023 16:54:51 +0000 (10:54 -0600)]
ide: Correct LBA setting

Fix a longstanding bug where the LBA is calculated as the size of the
media instead of the number of blocks. This was perhaps not noticed
earlier since it prints the correct value first, before setting the wrong
value.

Drop the unnecessary blksz variable while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 68e6f221ed0 ("block: ide: Fix block read/write with driver model")
20 months agoide: Use a single local blk_desc for ide_ident()
Simon Glass [Tue, 25 Apr 2023 16:54:50 +0000 (10:54 -0600)]
ide: Use a single local blk_desc for ide_ident()

We only use one member of the ide_dev_desc[] array at a time and it does
not stick around outside ide_probe(). Use a single element instead.

Copy over the missing members of blk_desc at the same, since this was
missing from the previous code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 68e6f221ed0 ("block: ide: Fix block read/write with driver model")
20 months agoide: Move all blk_desc init into ide_ident()
Simon Glass [Tue, 25 Apr 2023 16:54:49 +0000 (10:54 -0600)]
ide: Move all blk_desc init into ide_ident()

Rather than having the caller fill some of this in, do it all in the
ide_ident() function, since it knows all the values.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Make ide_ident() return an error code
Simon Glass [Tue, 25 Apr 2023 16:54:48 +0000 (10:54 -0600)]
ide: Make ide_ident() return an error code

Update ide_ident() to indicate whether it finds a device or not. Use
that to decide whether to create a block device for it, rather than
looking DEV_TYPE_UNKNOWN.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Use desc consistently for struct blk_desc
Simon Glass [Tue, 25 Apr 2023 16:54:47 +0000 (10:54 -0600)]
ide: Use desc consistently for struct blk_desc

Most of the code uses 'desc' as the variable name for a blk descriptor.
Change ide to do the same.

Tidy up some extra brackets and types while we are here.

Leave the code in ide_probe() alone since it is about to be refactored.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Combine the two loops in ide_probe()
Simon Glass [Tue, 25 Apr 2023 16:54:46 +0000 (10:54 -0600)]
ide: Combine the two loops in ide_probe()

The two loops in this function operate on the same ide_dev_desc[] array.
Combine them to reduce duplication.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Move ide_init() entirely within ide_probe()
Simon Glass [Tue, 25 Apr 2023 16:54:45 +0000 (10:54 -0600)]
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>
20 months agoide: Move setting of vendor strings into ide_probe()
Simon Glass [Tue, 25 Apr 2023 16:54:44 +0000 (10:54 -0600)]
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>
20 months agoide: Make ide_bus_ok a local variable
Simon Glass [Tue, 25 Apr 2023 16:54:43 +0000 (10:54 -0600)]
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>
20 months agoide: Move bus init into a function
Simon Glass [Tue, 25 Apr 2023 16:54:42 +0000 (10:54 -0600)]
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>
20 months agoide: Avoid preprocessor for CONFIG_LBA48
Simon Glass [Tue, 25 Apr 2023 16:54:41 +0000 (10:54 -0600)]
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>
20 months agoide: Avoid preprocessor for CONFIG_ATAPI
Simon Glass [Tue, 25 Apr 2023 16:54:40 +0000 (10:54 -0600)]
ide: Avoid preprocessor for CONFIG_ATAPI

Use IS_ENABLED() instead for all conditions.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Simplify success condition
Simon Glass [Tue, 25 Apr 2023 16:54:39 +0000 (10:54 -0600)]
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>
20 months agoide: Refactor confusing loop code
Simon Glass [Tue, 25 Apr 2023 16:54:38 +0000 (10:54 -0600)]
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>
20 months agoide: Change the retries variable
Simon Glass [Tue, 25 Apr 2023 16:54:37 +0000 (10:54 -0600)]
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>
20 months agoide: Make function static
Simon Glass [Tue, 25 Apr 2023 16:54:36 +0000 (10:54 -0600)]
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>
20 months agoide: Correct use of ATAPI
Simon Glass [Tue, 25 Apr 2023 16:54:35 +0000 (10:54 -0600)]
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: 145df842b44 ("dm: ide: Add support for driver-model block devices")
Fixes: d0075059e4d ("ide: Drop non-DM code for BLK")
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Create a prototype for ide_set_reset()
Simon Glass [Tue, 25 Apr 2023 16:54:34 +0000 (10:54 -0600)]
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>
20 months agoide: Drop weak functions
Simon Glass [Tue, 25 Apr 2023 16:54:33 +0000 (10:54 -0600)]
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>
20 months agoide: Move a few functions further up the file
Simon Glass [Tue, 25 Apr 2023 16:54:32 +0000 (10:54 -0600)]
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>
20 months agoide: Drop ide_device_present()
Simon Glass [Tue, 25 Apr 2023 16:54:31 +0000 (10:54 -0600)]
ide: Drop ide_device_present()

This function is not used anymore. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Move ide_init() into probing
Simon Glass [Tue, 25 Apr 2023 16:54:30 +0000 (10:54 -0600)]
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>
20 months agoide: Drop init for not using BLK
Simon Glass [Tue, 25 Apr 2023 16:54:29 +0000 (10:54 -0600)]
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>
20 months agoide: Drop CONFIG_START_IDE
Simon Glass [Tue, 25 Apr 2023 16:54:28 +0000 (10:54 -0600)]
ide: Drop CONFIG_START_IDE

This is not used by any board. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
20 months agoide: Use mdelay() for long delays
Simon Glass [Tue, 25 Apr 2023 16:54:27 +0000 (10:54 -0600)]
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>