summaryrefslogtreecommitdiff
path: root/test/dm
AgeCommit message (Collapse)AuthorFilesLines
2022-12-06global: Move remaining CONFIG_SYS_SDRAM_* to CFG_SYS_SDRAM_*Tom Rini1-3/+3
The rest of the unmigrated CONFIG symbols in the CONFIG_SYS_SDRAM namespace do not easily transition to Kconfig. In many cases they likely should come from the device tree instead. Move these out of CONFIG namespace and in to CFG namespace. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-05test: dm: eth: Add ip6_make_lladdr testViacheslav Mitrofanov1-0/+18
Add a test that checks generated Link Local Address. Use in sandbox Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-05test: dm: eth: Add ip6_make_snma testViacheslav Mitrofanov1-0/+20
Add a test that checks generated Solicited Node Multicast Address from our ipv6 address. Use in sandbox Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-05test: dm: eth: Add ip6_addr_in_subnet testViacheslav Mitrofanov1-0/+25
Add a test if two address are in the same subnet. Use in sandbox Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-05test: dm: eth: Add csum_ipv6_magic testViacheslav Mitrofanov1-0/+29
Test checksum computation. csum_ipv6_magic() uses in upper layer protocols as TCP/UDP/ICMPv6/etc to calculate payload checksum. Series-changes: 3 - Fixed style problems Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-05test: dm: eth: Add string_to_ip6 testViacheslav Mitrofanov1-0/+55
Add a test to check convertation from char* to struct in6_addr. Use in sandbox Series-changes: 3 - Fixed tests to use length param in string_to_ip6() Series-changes: 5 - Add test under #ifdef Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-11-08dm: Add tests for the sandbox host driverSimon Glass2-0/+196
Add some unit tests for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-08dm: sandbox: Switch over to using the new host uclassSimon Glass1-22/+25
Update the sandbox implementation to use UCLASS_HOST and adjust all the pieces to continue to work: - Update the 'host' command to use the new API - Replace various uses of UCLASS_ROOT with UCLASS_HOST - Disable test_eficonfig since it doesn't work (this should have a unit test to allow this to be debugged) - Update the blk test to use the new API - Drop the old header file Unfortunately it does not seem to be possible to split this change up further. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-08dm: blk: Tidy up obtaining a block device from its parentSimon Glass1-1/+1
This function now finds its block-device child by looking for a child device of the correct uclass (UCLASS_BLK). It cannot produce a device of any other type, so drop the superfluous check. Provide a version which does not probe the device, since that is often needed when setting up the device's platdata. Also fix up the function's comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-08dm: test: Drop the special function for running DM testsSimon Glass1-45/+4
This is not needed since the flag takes care of all differences. Make use of the common function. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31test: dm: Add test cases for FWU Metadata uclassSughosh Ganu3-0/+260
Add test cases for accessing the FWU Metadata on the sandbox platform. The sandbox platform also uses the metadata access driver for GPT partitioned block devices. The FWU feature will be tested on the sandbox64 variant with a raw capsule. Remove the FIT capsule testing from sandbox64 defconfig -- the FIT capsule test will be run on the sandbox_flattree variant. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-10-31usb: Update the test to cover reading and writingSimon Glass1-1/+18
Add test coverage for blk_write() as well. The blk_erase() is not tested for now as the USB stor interface does not support erase. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31dm: blk: Add udevice functionsSimon Glass1-3/+8
At present we have functions called blk_dread(), etc., which take a struct blk_desc * to refer to the block device. Add some functions which use udevice instead, since this is more in keeping with how driver model is supposed to work. Update one of the tests to use this. Note that it would be nice to update the functions in disk-uclass.c to use these new functions. However they are not quite the same. For example, disk_blk_read() adds the partition offset to 'start' when calling the cache read/fill functions, but does not with part_blk_read(), which does the addition itself. So as designed the code is duplicated. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31test: Support tests which can only be run manuallySimon Glass1-1/+1
At present we normally write tests either in Python or in C. But most Python tests end up doing a lot of checks which would be better done in C. Checks done in C are orders of magnitude faster and it is possible to get full access to U-Boot's internal workings, rather than just relying on the command line. The model is to have a Python test set up some things and then use C code (in a unit test) to check that they were done correctly. But we don't want those checks to happen as part of normal test running, since each C unit tests is dependent on the associate Python tests, so cannot run without it. To acheive this, add a new UT_TESTF_MANUAL flag to use with the C 'check' tests, so that they can be skipped by default when the 'ut' command is used. Require that tests have a name ending with '_norun', so that pytest knows to skip them. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31test: Update tests to use the skip featureSimon Glass2-11/+16
Some tests currently return 0 when they want to be skipped. Update them to return -EAGAIN instead, so they are counted as skipped. A few tests are in two parts, with the latter part being skipped in certain situations. Split these into two and use the correct condition for the second part. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31Merge tag 'video-20221030' of ↵Tom Rini1-2/+2
https://source.denx.de/u-boot/custodians/u-boot-video - fix [hv]sync active vs back porch in dw_mipi_dsi - simplefb rotation support - support splash as raw image from MMC - enhancements to Truetype console (multiple fonts and sizes) - drop old LCD support
2022-10-30video: Rename CONFIG_DM_VIDEO to CONFIG_VIDEOSimon Glass1-2/+2
Now that all the old code is gone, rename this option. Driver model migration is now complete. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-29dm: core: Do not stop uclass iteration on errorMichal Suchanek2-13/+24
When probing a device fails NULL pointer is returned, and following devices in uclass list cannot be iterated. Skip to next device on error instead. With that the only condition under which these simple iteration functions return error is when the dm is not initialized at uclass_get time. This is not all that interesting, change return type to void. Fixes: 6494d708bf ("dm: Add base driver model support") Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-26dm: memory: Introduce new uclassRoger Quadros2-0/+22
Introduce UCLASS_MEMORY for future Memory Controller device drivers. Signed-off-by: Roger Quadros <rogerq@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-20k210: fix k210_pll_calc_config()Heinrich Schuchardt1-1/+1
The k210 driver is selected by sandbox_defconfig. Building the sandbox on 32bit systems fails with: test/dm/k210_pll.c: In function ‘dm_test_k210_pll_calc_config’: include/linux/bitops.h:11:38: warning: left shift count >= width of type [-Wshift-count-overflow] 11 | #define BIT(nr) (1UL << (nr)) | ^~ test/dm/k210_pll.c:36:54: note: in expansion of macro ‘BIT’ 36 | error = abs((error - BIT(32))) >> 16; | ^~~ Use the BIT_ULL() macro to create a u64 value. Replace abs() by abs64() to get correct results on 32bit system Apply the same for the unit test. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Sean Anderson <seanga2@gmail.com>
2022-10-18dm: treewide: Use uclass_first_device_err when accessing one deviceMichal Suchanek5-18/+18
There is a number of users that use uclass_first_device to access the first and (assumed) only device in uclass. Some check the return value of uclass_first_device and also that a device was returned which is exactly what uclass_first_device_err does. Some are not checking that a device was returned and can potentially crash if no device exists in the uclass. Finally there is one that returns NULL on error either way. Convert all of these to use uclass_first_device_err instead, the return value will be removed from uclass_first_device in a later patch. Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-18dm: treewide: Do not opencode uclass_probe_all()Michal Suchanek1-14/+3
We already have a function for probing all devices of a specific class, use it. Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-18dm: core: Fix uclass_probe_all to really probe all devicesMichal Suchanek1-4/+15
uclass_probe_all uses uclass_first_device/uclass_next_device assigning the return value. The interface for getting meaningful error is uclass_first_device_check/uclass_next_device_check, use it. Also do not stop iteration when an error is encountered. Probing all devices includes those that happen to be after a failing device in the uclass order. Fixes: a59153dfeb ("dm: core: add function uclass_probe_all() to probe all devices") Signed-off-by: Michal Suchanek <msuchanek@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-10-05dm: fpga: Introduce new uclassAlexander Dahl2-0/+21
For future DM based FPGA drivers and for now to have a meaningful logging class for old FPGA drivers. Suggested-by: Michal Simek <michal.simek@amd.com> Suggested-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Dahl <post@lespocky.de> Reviewed-by: Simon Glass <sjg@chromium.org> Link: https://lore.kernel.org/r/20220930120430.42307-2-post@lespocky.de Signed-off-by: Michal Simek <michal.simek@amd.com>
2022-09-30dm: core: Support copying properties with ofnodeSimon Glass1-0/+59
Add a function to copy properties from one node to another. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Allow copying ofnode property data when writingSimon Glass1-1/+61
At present ofnode_write_prop() is inconsistent between livetree and flattree, in that livetree requires the caller to ensure the property value is stable (e.g. in rodata or allocated) but flattree does not, since it makes a copy. This makes the API call a bit painful to use, since the caller must do different things depending on OF_LIVE. Add a new 'copy' argument which tells the function to make a copy if needed. Add some tests to cover this behaviour. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Expand ofnode testsSimon Glass1-17/+212
The current tests do not cover all functions, nor do they cover the new multi-tree functionality. Add and update the tests accordingly and update the 'future work' notes in the documentation. There is a still more testing needed for the failure cases, since at present some ofnode functions return a libfdt error code instead of converting it to an errno. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Create a function to get a live tree in a testSimon Glass1-8/+49
Move this logic out of the test into separate functions, so we can use it in other tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Complete phandle implementation using the other FDTSimon Glass1-0/+80
We need to be able to look up phandles in any FDT, not just the control FDT. Use the 'other' FDT to test this, with a helper function which gets this as an oftree that can then we used as needed. Add a few more tests and some comments at the top of the file, to explain what is going on. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Split ofnode_path_root() into two functionsSimon Glass1-3/+3
This function turns out to be a little confusing since it looks up a path and also registers the tree. Split it into two, one that gets the root node and one that looks up a path, so the purpose is clear. Registering the tree will happen in a function to be added in a later patch, called oftree_from_fdt(). Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Add a way to look up a phandle in an oftreeSimon Glass1-0/+2
When we have multiple trees, the ofnode logic needs to be told which one to use. Create a new function which takes an oftree argument, along with a helper to obtain the FDT pointer from an oftree. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Add ofnode functions to obtain an oftreeSimon Glass1-2/+5
At present dm_test_ofnode_root() does this manually. Add some inline functions to handle it, so this code can be centralised. Add oftree functions to produce a null tree and to check whether a tree is valid or not. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Expand integer-reading testsSimon Glass1-0/+102
The current tests do not cover all the behaviour. Add some more. Tidy up a few inconsistencies between livetree and flattree which come to light with these tests. Also drop the -ENODATA error since it is never actually returned. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Add a macro to iterate through propertiesSimon Glass1-0/+24
Add a 'for_each' macro like we have for nodes. Fix the comment for struct ofprop while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Rename ofnode_get_property_by_prop()Simon Glass1-4/+3
The current name is quite unwieldy. Change it to use an ofprop_ prefix and shorten it. Fix the return-value comment while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Rename ofnode_get_first/next_property()Simon Glass1-2/+2
Drop the 'get' in these names since it does not fit with the rest of the API. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29test: Drop the UT_TESTF_LIVE_OR_FLAT flagSimon Glass1-13/+3
This was a workaround for a rare situation. Now that it will be more common and we have a proper fix, drop the flag. We can run both types of tests in the same sandbox executable, even if the flat device tree is modified. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Support writing a property to an empty nodeSimon Glass1-0/+3
At present this does not work with livetree. Fix it and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29dm: core: Allow adding ofnode subnodesSimon Glass1-0/+71
Add this feature to the ofnode interface, supporting both livetree and flattree. If the node exists it is returned, along with a -EEXIST error. Update the functions it calls to handle this too. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29test: Fix missing livetree test runsSimon Glass1-0/+4
At present the live tree tests are not run on sandbox. This bug is in two parts, with a duplicate flag value and incorrect logic in the test runner. This was not noticed because the bug was fixed in a later commit and does not cause test failures. Fix this. Fixes: 7b1dfc9fd7e ("dm: core: Prepare for updating the device tree with ofnode") Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-25sandbox: Add a test for SCSISimon Glass2-0/+40
Add a simple uclass test for SCSI. It reads the partition table from a disk image and checks that it looks correct. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-19Merge branch 'master' into nextTom Rini2-0/+35
Signed-off-by: Tom Rini <trini@konsulko.com>
2022-09-18cyclic: Use schedule() instead of WATCHDOG_RESET()Stefan Roese1-4/+5
Globally replace all occurances of WATCHDOG_RESET() with schedule(), which handles the HW_WATCHDOG functionality and the cyclic infrastructure. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Tom Rini <trini@konsulko.com> [am335x_evm, mx6cuboxi, rpi_3,dra7xx_evm, pine64_plus, am65x_evm, j721e_evm]
2022-09-16blk: Switch over to using uclass IDsSimon Glass1-12/+12
We currently have an if_type (interface type) and a uclass id. These are closely related and we don't need to have both. Drop the if_type values and use the uclass ones instead. Maintain the existing, subtle, one-way conversion between UCLASS_USB and UCLASS_MASS_STORAGE for now, and add a comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-15gpio: sandbox: Add GPIOD_IS_AF for gpio configured in alternate functionPatrice Chotard1-0/+30
This allows to test if a pin's label if displayed using gpio_get_status() when this pin is configured in alternate function. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2022-09-14dm: core: Add functions to read 8/16-bit integersStefan Herbrechtsmeier1-0/+19
Add functions to read 8/16-bit integers like the existing functions for 32/64-bit to simplify read of 8/16-bit integers from device tree properties. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-03tpm: Allow reporting the internal stateSimon Glass2-0/+35
It is useful to read information about the current TPM state, where supported, e.g. for debugging purposes when verified boot fails. Add support for this to the TPM interface as well as Cr50. Add a simple sandbox test. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-09-02dm: rtc: Try to handle the localtime() raceSimon Glass1-13/+19
At present the sandbox timer uses localtime() which can jump around twice a year when daylight-saving time changes. It would be tricky to make use of gmtime() since we still need to present the time in local time, as seems to be required by U-Boot's RTC interface. The problem can only happen once, so use a loop to detect it and try again. This should be sufficient to detect either a change in the 'second' value, or a daylight-saving change. We can assume that the latter also incorporates a 'second' change, so there is no need to loop more than twice. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-02dm: rtc: Try to avoid a race in rtc_set_get testSimon Glass1-5/+17
It seems that the time can change in between getting it and reading the offset. Check for this and try again if this happens. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-02dm: rtc: Avoid a race in the rtc_reset testSimon Glass1-2/+7
Since resetting the RTC on sandbox causes it to read the base time from the system, we cannot rely on this being unchanged since it was last read. Allow for a one-second delay. Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Fixes: https://source.denx.de/u-boot/u-boot/-/issues/4 Reported-by: Bin Meng <bmeng.cn@gmail.com> Reported-by: Tom Rini <trini@konsulko.com> Suggested-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: Simon Glass <sjg@chromium.org>