Commit Graph

198 Commits

Author SHA1 Message Date
Neil Armstrong
e068512ca6 test: regmap: add read/modify/write test
Add calls to regmap_read/modify_bits/write even if the proper memory
read/write calls are not executed in sandbox.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2018-05-08 09:07:40 -04:00
Patrick Bruenn
274fb461f4 dm: led: add testcase for "default-state" property
Add two more gpio-leds to sandbox test device tree with default-state
property set to "on"/"off".
Add dm_test_led_default_state() to check that these new LED's are set to
LEDST_ON and LEDST_OFF.

dm: led: add testcase for "default-state" property

Add two more gpio-leds to sandbox test device tree with default-state
property set to "on"/"off".
Add dm_test_led_default_state() to check that these new LED's are set to
LEDST_ON and LEDST_OFF.

Signed-off-by: Patrick Bruenn <p.bruenn@beckhoff.com>
2018-05-08 09:07:33 -04:00
Masahiro Yamada
04ca871459 test: ofnode: test ofnode_device_is_compatible()
Test ofnode_device_is_compatible(), and also ofnode_path().

Requested-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2018-05-07 15:49:52 -04:00
Masahiro Yamada
99552c3435 test: regmap: test Linux-compatible syscon_node_to_regmap()
Like Linux, syscon_node_to_regmap() allows a node to work as a syscon
provider without binding it to a syscon driver.  Test this.

Requested-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2018-05-07 15:49:52 -04:00
Masahiro Yamada
8c1de5e08b regmap: clean up regmap allocation
Putting zero length array at the end of struct is a common technique
to embed arbitrary length of members.  There is no good reason to let
regmap_alloc_count() branch by "if (count <= 1)".

As far as I understood the code, regmap->base is an alias of
regmap->ranges[0].start, but it is not helpful but make the code
just ugly.

Rename regmap_alloc_count() to regmap_alloc() because the _count
suffix seems pointless.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
[trini: fixup cpu_info-rcar.c]
Signed-off-by: Tom Rini <trini@konsulko.com>
2018-05-07 15:15:27 -04:00
Tom Rini
83d290c56f SPDX: Convert all of our single license tags to Linux Kernel style
When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from.  So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry.  Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents.  There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>
2018-05-07 09:34:12 -04:00
Masahiro Yamada
30d313688f test: dm: regmap: fix license header
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-04-28 18:32:22 -04:00
Tom Rini
d024236e5a Remove unnecessary instances of DECLARE_GLOBAL_DATA_PTR
We have a large number of places where while we historically referenced
gd in the code we no longer do, as well as cases where the code added
that line "just in case" during development and never dropped it.

Signed-off-by: Tom Rini <trini@konsulko.com>
2018-04-27 14:54:48 -04:00
Neil Armstrong
65388d0dc5 clk: add sandbox test for bulk API
This patch adds the bulk clock API tests for the sandbox test suite.

It's very similar to the main test but only uses the _bulk() API and
checks if the clocks are correctly enabled/disabled.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2018-04-10 15:18:56 -04:00
Neil Armstrong
91f5f8b73c reset: add sandbox test for bulk API
This patch adds the bulk reset API tests for the sandbox test suite.

Unlike the main test, it also check the "other" reset signal using the bulk API
and checks if the resets are correctly asserted/deasserted.

To allow the bulk API to work, and avoid changing the DT, the number of resets
of the sandbox reset controller has been bumped to 101 for the "other" reset
line to be valid.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2018-04-10 11:52:16 -04:00
Mario Six
e8d5291824 core: ofnode: Fix translation for #size-cells == 0
Commit 286ede6 ("drivers: core: Add translation in live tree case") made
dev_get_addr always use proper bus translations for addresses read from
the device tree. But this leads to problems with certain busses, e.g.
I2C busses, which run into an error during translation, and hence stop
working.

It turns out that of_translate_address() and fdt_translate_address()
stop the address translation with an error when they're asked to
translate addresses for busses where #size-cells == 0 (comment from
drivers/core/of_addr.c):

 * Note: We consider that crossing any level with #size-cells == 0 to mean
 * that translation is impossible (that is we are not dealing with a value
 * that can be mapped to a cpu physical address). This is not really specified
 * that way, but this is traditionally the way IBM at least do things

To fix this case, we check in both the live-tree and non-live tree-case,
whether the bus of the device whose address is about to be translated
has size-cell size zero. If this is the case, we just read the address
as a plain integer and return it, and only apply bus translations if the
size-cell size if greater than zero.

Signed-off-by: Mario Six <mario.six@gdsys.cc>
Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com>
Reported-by: Martin Fuzzey <mfuzzey@parkeon.com>
Fixes: 286ede6 ("drivers: core: Add translation in live tree case")
Reviewed-by: Simon Glass <sjg@chromium.org>
2018-04-01 22:19:10 +08:00
Heinrich Schuchardt
9ffa4d12a8 dm: video: support increased intensity (bold)
Support special rendition code 0 - reset attributes.
Support special rendition code 1 - increased intensity (bold).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2018-03-06 10:05:49 +01:00
Heinrich Schuchardt
3aeb0cbe12 dm: video: show correct colors in graphical console
Get RGB sequence in pixels right (swap blue and red).
Do not set reserved bits.

qemu-system-i386 -display sdl -vga virtio and
qemu-system-i386 -display sdl -vga cirrus
now display the similar colors (highlighting still missing) as
qemu-system-i386 -nographic

Testing is possible via

	setenv efi_selftest test output
	bootefi selftest

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2018-03-06 10:00:32 +01:00
Simon Glass
6e43d1b199 dm: core: Add a function to look up a uclass by name
Each uclass has a driver name which we can use to look up the uclass. This
is useful for logging, where the uclass ID is used as the category.

Add a function to handle this, as well as a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-02-03 10:08:40 -07:00
Rob Clark
f2006808f0 dm: core: parse chosen node
This is the node that would contain, for example, the framebuffer setup
by an earlier stage.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2018-01-15 11:35:38 -05:00
Felix Brack
bf802f5d54 power: extend prefix match to regulator-name property
This patch extends pmic_bind_children prefix matching. In addition to
the node name the property regulator-name is used while trying to match
prefixes. This allows assigning different drivers to regulator nodes
named regulator@1 and regulator@10 for example.
I have discarded the idea of using other properties then regulator-name
as I do not see any benefit in using property compatible or even
regulator-compatible. Of course I am open to change this if there are
good reasons to do so.

Signed-off-by: Felix Brack <fb@ltec.ch>
Reviewed-by: Simon Glass <sjg@chromium.org>
2017-12-12 19:53:45 -07:00
Tom Rini
74d90d17ee Merge git://git.denx.de/u-boot-video 2017-10-09 13:31:33 -04:00
Tom Rini
e2e6daed5a test/dm: Fix string handling issues in the eth test
Coverity scan has identified potential buffer overruns in these tests.
Correct this by zeroing our buffer and using strncpy not strcpy.

Reported-by: Coverity (CID: 155462, 155463)
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2017-10-06 11:28:20 -04:00
Bin Meng
f4d4f7d41c test: dm: usb: Update test cases for USB
Now that we have changed to remove all devices under the root hub in
usb_stop(), and corrected the USB emulator select logic, it makes no
sense to do various tests based on 'usb tree' output since the order
of devices is no longer fixed. Remove these USB test cases related
to 'usb tree'.

For the USB remove test, ideally we should remove an emulator device
node from the device tree, but this is so far not working. Change to
test the 'usb stop' only.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2017-10-01 16:32:51 +02:00
Rob Clark
40186ee213 video: test: Add ANSI escape sequence tests
This adds tests for clear, set-cursor and color escape sequences.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
2017-09-29 17:59:58 +02:00
Rob Clark
a7495ac872 video: test: Helper for writing strings
I'll need some more of this, let's not just copy-pasta the
vidconsole_put_char() loop.

Named to match vidconsole_put_char() in case that is ever useful
outside of the tests.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-09-29 17:58:45 +02:00
Patrice Chotard
ee87a097b0 dm: test: replace dm_scan_dt() by of dm_extended_scan_fdt() in dm_do_test
This allows to scan the DT including all "clocks" node's sub-nodes
in which fixed-clock are defined.
All fixed-clock should be defined inside a clocks node which collect all
external oscillators. Until now, all clocks sub-nodes can't be binded except
if the "simple-bus" compatible string is added which is a hack.

Update test.dts by moving clk_fixed node inside clocks.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2017-09-11 21:43:58 -06:00
Jean-Jacques Hiblot
5fe7702ecc blk: dm: make blk_create_device() take a number of block instead of a size
There is an overflow problem when taking the size instead of the number
of blocks in blk_create_device(). This results in a wrong device size: the
device apparent size is its real size  modulo 4GB.
Using the number of blocks instead of the device size fixes the problem and
is more coherent with the internals of the block layer.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2017-09-11 21:43:58 -06:00
Simon Glass
00caae6d47 env: Rename getenv/_f() to env_get()
We are now using an env_ prefix for environment functions. Rename these
two functions for consistency. Also add function comments in common.h.

Quite a few places use getenv() in a condition context, provoking a
warning from checkpatch. These are fixed up in this patch also.

Suggested-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16 08:30:24 -04:00
Simon Glass
382bee57f1 env: Rename setenv() to env_set()
We are now using an env_ prefix for environment functions. Rename setenv()
for consistency. Also add function comments in common.h.

Suggested-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16 08:22:18 -04:00
Simon Glass
95ce385a4a dm: core: Add uclass_first/next_device_check()
Sometimes it is useful to iterate through all devices in a uclass and
skip over those which do not work correctly (e.g fail to probe). Add two
new functions to provide this feature.

The caller must check the return value each time to make sure that the
device is valid. But the device pointer is always returned.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-11 10:08:19 -06:00
Simon Glass
9856157259 dm: core: Test uclass_first/next_device() on probe failure
Add some tests which check the behaviour of uclass_first_device() and
uclass_next_device() when probing of a device fails.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-11 10:08:19 -06:00
Simon Glass
4f414d392f test: bus: Add a check that dev is not NULL
We know that uclass_get_device() and device_find_child_by_of_offset() do
not return NULL for dev when they succeeds but coverity does not. Add an
extra check to hopefully keep it happy.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Coverity (CID: 163246)
Fixes: 0753bc2 (dm: Simple Watchdog uclass)
2017-06-12 08:38:10 -04:00
Simon Glass
9eace7f59e test: wdt: Add a check that dev is not NULL
We know that uclass_get_device() does not return NULL for dev when it
succeeds but coverity does not. Add an extra check to hopefully keep it
happy.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Coverity (CID: 163247)
Fixes: 0753bc2 (dm: Simple Watchdog uclass)
2017-06-12 08:38:09 -04:00
Simon Glass
1a596c44c0 test: pwm: Add a check that dev is not NULL
We know that uclass_get_device() does not return NULL for dev when it
succeeds but coverity does not. Add an extra check to hopefully keep it
happy.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Coverity (CID: 161690)
Fixes: 43b4156 (dm: sandbox: pwm: Add a basic pwm test)
2017-06-12 08:38:06 -04:00
Simon Glass
9f103b9cb5 dm: blk: Add a way to obtain a block device from its parent
Many devices support a child block device (e.g. MMC, USB). Add a
convenient way to get this device given the parent device.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2017-06-09 20:25:16 +09:00
Simon Glass
ac206a0f4e dm: phy: Update tests to use ut_asserteq()
Use ut_asserteq() to test equality since this gives a better error message
on failure. Also make a few of the tests more specific.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:14 -06:00
Simon Glass
86b54ece82 dm: test: Disable the fdt_offset test with livetree
We cannot run this test with livetree since it uses device tree offsets.
Mark it as flat tree only.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:14 -06:00
Simon Glass
298afb52cb dm: test: Separate out the bus DT offset test
We cannot access the device tree via an offset when running in livetree
mode. Separate out that part of the bus' children tests and mark it as
for the flat tree only.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:14 -06:00
Simon Glass
6fb2f57916 dm: core: Run tests with both livetree and flat tree
Some tests require either livetree or flat tree. Add flags to allow the
tests to specify this. Adjust the test runner to run with livetree (if
supported) and then flat tree.

Some video tests are quite slow and running on flat tree adds little extra
test value, so run these on livetree only.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:10 -06:00
Simon Glass
c166c47ba3 dm: test: Add support for running tests with livetree
It is useful to run the driver model tests with both livetree and flat
tree in case something is different between the two. Add this feature to
the test runner.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:10 -06:00
Simon Glass
801587bd77 dm: test: Show the test filename when running
Show the filename of the test being run. Skip the path and show just the
base name.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:09 -06:00
Simon Glass
f86db10cc5 dm: test: Move test running code into a separate function
We want to run the same test on flat and live trees. In preparation for
this, create a new function which handles running a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:09 -06:00
Simon Glass
34b744beb8 sandbox: Add a way to reset sandbox state for tests
Running a new test should reset the sandbox state to avoid tests
interferring with each other. Move the existing state-reset code into a
function so it can be used from tests.

Also update the code to reset the SPI devices and adjust the test code to
call it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:09 -06:00
Simon Glass
19c8205e68 dm: core: Scan the live tree when setting up driver model
When starting up driver model with a live tree we need to scan the tree
for devices. Add code to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:08 -06:00
Simon Glass
e48eeb9ea3 dm: blk: Improve block device claiming
The intention with block devices is that the device number (devnum field
in its descriptor) matches the alias of its parent device. For example,
with:

	aliases {
		mmc0 = "/sdhci@700b0600";
		mmc1 = "/sdhci@700b0400";
	}

we expect that the block devices for mmc0 and mmc1 would have device
numbers of 0 and 1 respectively.

Unfortunately this does not currently always happen. If there is another
MMC device earlier in the driver model data structures its block device
will be created first. It will therefore get device number 0 and mmc0
will therefore miss out. In this case the MMC device will have sequence
number 0 but its block device will not.

To avoid this, allow a device to request a device number and bump any
existing device number that is using it. This all happens during the
binding phase so it is safe to change these numbers around. This allows
device numbers to match the aliases in all circumstances.

Add a test to verify the behaviour.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:05 -06:00
Simon Glass
6139281a64 dm: blk: Allow finding block devices without probing
Sometimes it is useful to be able to find a block device without also
probing it. Add a function for this as well as the associated test.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01 07:03:04 -06:00
Kever Yang
5540e25aeb dm: sandbox: pwm: add test for pwm_set_invert()
Add test case for new interface set_invert().

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Acked-by: Simon Glass <sjg@chromium.org>
Fix typo in subject and build error in sandbox_pwm_set_invert():
Signed-off-by: Simon Glass <sjg@chromium.org>
2017-05-10 13:37:21 -06:00
Jean-Jacques Hiblot
86322f5982 dm: test: Add tests for the generic PHY uclass
Those tests check:
- the ability for a phy-user to get a phy based on its name or its index
- the ability of a phy device (provider) to manage multiple ports
- the ability to perform operations on the phy (init,deinit,on,off)
- the behavior of the uclass when optional operations are not implemented

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2017-05-09 12:14:16 -06:00
maxims@google.com
0753bc2d30 dm: Simple Watchdog uclass
This is a simple uclass for Watchdog Timers. It has four operations:
start, restart, reset, stop. Drivers must implement start, restart and
stop operations, while implementing reset is optional: It's default
implementation expires watchdog timer in one clock tick.

Signed-off-by: Maxim Sloyko <maxims@google.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2017-05-08 11:57:30 -04:00
Simon Glass
43b41566f7 dm: sandbox: pwm: Add a basic pwm test
Unfortunately a test for the PWM uclass was not included when it was
submitted. This was noticed when trying to add more functionality:

   http://patchwork.ozlabs.org/patch/748172/

Add a simple test to get us started.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-04-27 16:49:02 -04:00
Simon Glass
53378dac8d dm: led: Add support for blinking LEDs
Allow LEDs to be blinked if the driver supports it. Enable this for
sandbox so that the tests run.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ziping Chen <techping.chan@gmail.com>
2017-04-14 19:38:57 -06:00
Simon Glass
9413ad4f0d dm: led: Support toggling LEDs
Add support for toggling an LED into the uclass interface. This can be
efficiently implemented by the driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ziping Chen <techping.chan@gmail.com>
2017-04-14 19:38:57 -06:00
Simon Glass
8f4b612333 dm: led: Add support for getting the state of an LED
It is useful to be able to read the LED as well as write it. Add this to
the uclass and update the GPIO driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ziping Chen <techping.chan@gmail.com>
2017-04-14 19:38:57 -06:00
Simon Glass
ddae9fcddc dm: led: Adjust the LED uclass
At present this is very simple, supporting only on and off. We want to
also support toggling and blinking. As a first step, change the name of
the main method and use an enum to indicate the state.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ziping Chen <techping.chan@gmail.com>
2017-04-14 19:38:57 -06:00