aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-2023.07' of ↵WIP/29Apr2023Tom Rini2023-04-299-81/+343
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * spi: mpc8xxx: Add support for SPI on mpc832xChristophe Leroy2023-04-061-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On mpc832x, SPI can be either handled by CPU or QE. In order to work in CPU mode, bit 17 of SPMODE has to be set to 1, that bit is called OP. Also, data is located at a different place than the one expected by the driver today. In 8 bits mode with REV set, data to be transmitted is located in the most significant byte while received data is located in second byte. So perform the necessary shifts. In order to differentiate with other CPUs, a new compatible is added for mpc832x: fsl,mpc832x-spi Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
| * gpio: Add QUICC Engine GPIOs driverChristophe Leroy2023-04-063-0/+189
| | | | | | | | | | | | | | | | | | | | The mpc832x has GPIOs handled by the QUICC Engine. The registers are different from the one for the non QE mpc83xx GPIOs. Implement a GPIO driver for those. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
| * clk: mpc83xx: Fix clocks for mpc832xChristophe Leroy2023-04-061-0/+7
| | | | | | | | | | | | | | | | | | | | gd->arch.sdhc_clk only exists when CONFIG_FSL_ESDHC is set, so enclose it inside ifdefs. gd->arch.qe_clk and gd->arch.brg_clk must be populated when CONFIG_QE is set. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
| * watchdog: mpc8xxx: Add support for mpc83xxChristophe Leroy2023-04-062-1/+2
| | | | | | | | | | | | | | | | | | | | Introduce a new compatible "fsl,pq2pro-wdt" On mpc83xx, the prescaling factor is 0x10000. Don't write the watchdog configuration register in start.S as it can be written only once. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
| * watchdog: mpc8xxx: Make it genericChristophe Leroy2023-04-062-19/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mpc8xx, mpc83xx and mpc86xx have similar watchdog with almost same memory registers. Refactor the driver to get the register addresses from the device tree and use the compatible to know the prescale factor. Calculate the watchdog setup value from the provided timeout. Don't declare it anymore as an HW_WATCHDOG, u-boot will start servicing the watchdog early enough. On mpc8xx the watchdog configuration register is also used for configuring the bus monitor. So add it as an option to the watchdog when it is mpc8xx. When watchdog is not selected, leave the configuration of the initial SYPCR from Kconfig. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
| * watchdog: mpc8xx: Rename it mpc8xxxChristophe Leroy2023-04-053-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | mpc8xx, mpc83xx and mpc86xx have similar watchdog with almost same memory registers. Rename it mpc8xxx which is the generic name used for drivers supporting several mpc families. The driver will be made more generic in following patch. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
* | core: fdtaddr: use map_sysmem() as cast for the returnJohan Jonker2023-04-281-1/+5
| | | | | | | | | | | | | | | | | | | | | | 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>
* | dm: core: introduce uclass_get_device_by_of_path()Rasmus Villemoes2023-04-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | uclass: add uclass_find_device_by_phandle_id() helperRasmus Villemoes2023-04-281-25/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | dm: core: Make aliases_lookup staticBin Meng2023-04-281-1/+1
| | | | | | | | | | | | | | aliases_lookup is only referenced in of_access.c Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Simon Glass <sjg@chromium.org>
* | drivers: tee: sandbox: Fix SCP03 control emulatorJorge Ramirez-Ortiz2023-04-281-4/+11
| | | | | | | | | | | | | | | | | | | | 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>
* | sandbox: fix return type of os_filesize()Heinrich Schuchardt2023-04-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | sandbox: mark sandbox_exit() as no return.Heinrich Schuchardt2023-04-281-1/+0
| | | | | | | | | | | | | | 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>
* | sandbox: spi: sandbox_sf_process_cmd() missing fallthroughHeinrich Schuchardt2023-04-281-0/+1
| | | | | | | | | | | | | | 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>
* | sandbox: fix sandbox_hub_submit_control_msg()Heinrich Schuchardt2023-04-281-21/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | sandbox: fix fall through in sandbox_flash_bulk()Heinrich Schuchardt2023-04-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | 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>
* | sandbox64: add support for NVMXIP QSPIAbdellatif El Khlifi2023-04-271-0/+7
| | | | | | | | | | | | | | | | | | 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>
* | drivers/mtd/nvmxip: introduce QSPI XIP driverAbdellatif El Khlifi2023-04-273-0/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | drivers/mtd/nvmxip: introduce NVM XIP block storage emulationAbdellatif El Khlifi2023-04-278-0/+242
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | ide: Make use of U-Boot typesWIP/2023-04-27-IDE-code-cleanupsSimon Glass2023-04-271-42/+37
| | | | | | | | | | | | Use standard U-Boot types in the file to make the code less verbose. Signed-off-by: Simon Glass <sjg@chromium.org>
* | ide: Simplify expressions and hex valuesSimon Glass2023-04-271-59/+56
| | | | | | | | | | | | | | | | 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>
* | ide: Convert to use log_debug()Simon Glass2023-04-271-40/+40
| | | | | | | | | | | | | | | | | | 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>
* | ide: Tidy up ide_reset()Simon Glass2023-04-271-11/+10
| | | | | | | | | | | | | | Avoid using #ifdef and use a single function declaration, so it is easier to read. Signed-off-by: Simon Glass <sjg@chromium.org>
* | ide: Correct LBA settingSimon Glass2023-04-271-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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")
* | ide: Use a single local blk_desc for ide_ident()Simon Glass2023-04-271-12/+12
| | | | | | | | | | | | | | | | | | | | | | 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")
* | ide: Move all blk_desc init into ide_ident()Simon Glass2023-04-271-8/+4
| | | | | | | | | | | | | | 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>
* | ide: Make ide_ident() return an error codeSimon Glass2023-04-271-48/+53
| | | | | | | | | | | | | | | | 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>
* | ide: Use desc consistently for struct blk_descSimon Glass2023-04-271-54/+47
| | | | | | | | | | | | | | | | | | | | | | 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>
* | ide: Combine the two loops in ide_probe()Simon Glass2023-04-271-6/+6
| | | | | | | | | | | | | | 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>
* | ide: Move ide_init() entirely within ide_probe()Simon Glass2023-04-271-46/+38
| | | | | | | | | | | | | | | | | | 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>
* | ide: Move setting of vendor strings into ide_probe()Simon Glass2023-04-271-24/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | ide: Make ide_bus_ok a local variableSimon Glass2023-04-271-9/+3
| | | | | | | | | | | | This is only used in one place now, so make it a local variable. Signed-off-by: Simon Glass <sjg@chromium.org>
* | ide: Move bus init into a functionSimon Glass2023-04-271-39/+48
| | | | | | | | | | | | | | Move this code into a separate function which returns whether the bus was found, or not. Signed-off-by: Simon Glass <sjg@chromium.org>
* | ide: Avoid preprocessor for CONFIG_LBA48Simon Glass2023-04-271-37/+20
| | | | | | | | | | | | | | | | | | 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>
* | ide: Avoid preprocessor for CONFIG_ATAPISimon Glass2023-04-271-10/+3
| | | | | | | | | | | | Use IS_ENABLED() instead for all conditions. Signed-off-by: Simon Glass <sjg@chromium.org>
* | ide: Simplify success conditionSimon Glass2023-04-271-19/+17
| | | | | | | | | | | | | | | | 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>
* | ide: Refactor confusing loop codeSimon Glass2023-04-271-28/+15
| | | | | | | | | | | | | | | | 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>
* | ide: Change the retries variableSimon Glass2023-04-271-5/+5
| | | | | | | | | | | | | | | | 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>
* | ide: Make function staticSimon Glass2023-04-271-12/+11
| | | | | | | | | | | | | | Only one function is called from outside this file. Make all the others static. Signed-off-by: Simon Glass <sjg@chromium.org>
* | ide: Correct use of ATAPISimon Glass2023-04-271-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | ide: Create a prototype for ide_set_reset()Simon Glass2023-04-271-2/+0
| | | | | | | | | | | | This is used by a board so should be in the header file. Add it. Signed-off-by: Simon Glass <sjg@chromium.org>
* | ide: Drop weak functionsSimon Glass2023-04-271-7/+7
| | | | | | | | | | | | | | 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>
* | ide: Move a few functions further up the fileSimon Glass2023-04-271-34/+34
| | | | | | | | | | | | Move these functions so they appear before they are used. Signed-off-by: Simon Glass <sjg@chromium.org>
* | ide: Drop ide_device_present()Simon Glass2023-04-271-9/+0
| | | | | | | | | | | | This function is not used anymore. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
* | ide: Move ide_init() into probingSimon Glass2023-04-271-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | ide: Use mdelay() for long delaysSimon Glass2023-04-271-14/+11
| | | | | | | | | | | | | | Rather than using very large numbers with udelay(), use mdelay(), which is easier to follow. Signed-off-by: Simon Glass <sjg@chromium.org>
* | ide: Move ATA_CURR_BASE to C fileSimon Glass2023-04-271-0/+3
| | | | | | | | | | | | | | 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>
* | virtio: Ensure PCI is set up firstSimon Glass2023-04-261-0/+6
| | | | | | | | | | | | | | 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>
* | gpio-uclass: fix off-by-one in gpio_request_list_by_name_nodev()WIP/2023-04-25-assorted-updates-and-fixesRasmus Villemoes2023-04-251-1/+1
| | | | | | | | | | | | | | | | | | 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>