dm: test: Add test code for new uclasses
Subsystems (5)
cover dm: test: Add test code for new uclasses
Several new uclasses have been written and we need tests for these before they can be merged. This series adds the test code.
Simon Glass (18):
dm: Add platform data advice and admonishment
dm: test: Allow test names to leave out the dm_test_ prefix
dm: test: Add tests for the clk uclass
dm: test: Add tests for the pinctrl uclass
sandbox: Support multiple reset types
dm: reset: Allow reset_walk() to return
sandbox: Add a warm and cold reset driver
sandbox: Use the reset driver to handle reset
dm: test: Add a test for the reset uclass
dm: test: Add a test for the ram uclass
dm: test: Add a test for the mmc uclass
led: Return -ENODEV if the LED device cannot be found
dm: test: Add a test for the LED uclass
dm: test: Add a test for the system controller uclass
dm: test: Add a size to each reg property
test: Add a macro to check that a value is not an error pointer
dm: core: Add device checking to syscon_get_regmap()
test: Add a test for regmap
arch/sandbox/cpu/cpu.c | 9 +-- arch/sandbox/cpu/state.c | 4 ++ arch/sandbox/dts/test.dts | 76 ++++++++++++++++++++--- arch/sandbox/include/asm/state.h | 3 + arch/sandbox/include/asm/test.h | 19 ++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 3 + configs/sandbox_defconfig | 8 +++ doc/driver-model/README.txt | 17 ++++- drivers/clk/Makefile | 1 + drivers/clk/clk_sandbox.c | 85 +++++++++++++++++++++++++ drivers/core/syscon-uclass.c | 7 ++- drivers/led/led-uclass.c | 5 +- drivers/led/led_gpio.c | 6 ++ drivers/misc/Makefile | 2 + drivers/misc/reset-uclass.c | 31 +++++++-- drivers/misc/reset_sandbox.c | 100 ++++++++++++++++++++++++++++++ drivers/misc/syscon_sandbox.c | 27 ++++++++ drivers/mmc/Makefile | 1 + drivers/mmc/sandbox_mmc.c | 25 ++++++++ drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl_sandbox.c | 80 ++++++++++++++++++++++++ drivers/ram/Makefile | 1 + drivers/ram/sandbox_ram.c | 38 ++++++++++++ include/dm/platdata.h | 9 +++ include/dt-bindings/clock/sandbox-clk.h | 10 +++ include/led.h | 2 +- include/reset.h | 11 +++- include/test/ut.h | 15 +++++ test/dm/Makefile | 8 +++ test/dm/clk.c | 59 ++++++++++++++++++ test/dm/led.c | 72 +++++++++++++++++++++ test/dm/mmc.c | 27 ++++++++ test/dm/pinctrl.c | 63 +++++++++++++++++++ test/dm/ram.c | 28 +++++++++ test/dm/regmap.c | 82 ++++++++++++++++++++++++ test/dm/reset.c | 74 ++++++++++++++++++++++ test/dm/syscon.c | 31 +++++++++ test/dm/test-main.c | 15 ++++- 38 files changed, 1021 insertions(+), 34 deletions(-) create mode 100644 drivers/clk/clk_sandbox.c create mode 100644 drivers/misc/reset_sandbox.c create mode 100644 drivers/misc/syscon_sandbox.c create mode 100644 drivers/mmc/sandbox_mmc.c create mode 100644 drivers/pinctrl/pinctrl_sandbox.c create mode 100644 drivers/ram/sandbox_ram.c create mode 100644 include/dt-bindings/clock/sandbox-clk.h create mode 100644 test/dm/clk.c create mode 100644 test/dm/led.c create mode 100644 test/dm/mmc.c create mode 100644 test/dm/pinctrl.c create mode 100644 test/dm/ram.c create mode 100644 test/dm/regmap.c create mode 100644 test/dm/reset.c create mode 100644 test/dm/syscon.c
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 1/18 dm: Add platform data advice and admonishment
We should guide people more strongly towards device tree to avoid the proliferation of platform data structures. Add documentation to the driver model README, and also the platform data header file.
---
doc/driver-model/README.txt | 17 +++++++++++++++-- include/dm/platdata.h | 9 +++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)
doc/driver-model/README.txt +15 -2
@@ -301,6 +301,15 @@ device tree) and probe. Platform Data ------------- +*** Note: platform data is the old way of doing things. It is +*** basically a C structure which is passed to drivers to tell them about +*** platform-specific settings like the address of its registers, bus +*** speed, etc. Device tree is now the preferred way of handling this. +*** Unless you have a good reason not to use device tree (the main one +*** being you need serial support in SPL and don't have enough SRAM for +*** the cut-down device tree and libfdt libraries) you should stay away +*** from platform data. + Platform data is like Linux platform data, if you are familiar with that. It provides the board-specific information to start up a device.
@@ -366,8 +375,12 @@ Device Tree ----------- While platdata is useful, a more flexible way of providing device data is -by using device tree. With device tree we replace the above code with the -following device tree fragment: +by using device tree. In U-Boot you should use this where possible. Avoid +sending patches which make use of the U_BOOT_DEVICE() macro unless strictly +necessary. + +With device tree we replace the above code with the following device tree +fragment: red-square { compatible = "demo-shape";
include/dm/platdata.h +9 -0
@@ -16,6 +16,10 @@/** * struct driver_info - Information required to instantiate a device * +* NOTE: Avoid using this except in extreme circumstances, where device tree +* is not feasible (e.g. serial driver in SPL where <8KB of SRAM is +* available). U-Boot's driver model uses device tree for configuration. +* * @name: Driver name * @platdata: Driver-specific platform data */
@@ -24,6 +28,11 @@ struct driver_info {const void *platdata; }; +/** +* NOTE: Avoid using these except in extreme circumstances, where device tree +* is not feasible (e.g. serial driver in SPL where <8KB of SRAM is +* available). U-Boot's driver model uses device tree for configuration. +*/ #define U_BOOT_DEVICE (__name) \ ll_entry_declare(struct driver_info, __name, driver_info)
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 1/18 dm: Add platform data advice and admonishment
Quoted 11 lines · Simon Glass
We should guide people more strongly towards device tree to avoid the proliferation of platform data structures. Add documentation to the driver model README, and also the platform data header file.
Signed-off-by Simon Glass <[email protected]>---
doc/driver-model/README.txt | 17 +++++++++++++++-- include/dm/platdata.h | 9 +++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)
Applied to u-boot-dm.
PATCH 2/18 dm: test: Allow test names to leave out the dm_test_ prefix
In reply to Simon GlassAll driver model tests have a dm_test_ prefix. Ignore it when matching a test name. This makes it easier to run individual tests, like this:
./sandbox/u-boot -d ./sandbox/arch/sandbox/dts/test.dtb \
-c "ut dm clk_periph"
We can use 'clk_periph' instead of 'dm_test_clk_periph'.
Also print a message if the requested test is not found.
---
test/dm/test-main.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
test/dm/test-main.c +13 -2
@@ -76,6 +76,7 @@ static int dm_test_main(const char *test_name)struct unit_test_state *uts = &global_dm_test_state; uts->priv = &_global_priv_dm_test_state;struct unit_test *test; +int run_count;/* * If we have no device tree, or it only has a root node, then these
@@ -90,10 +91,17 @@ static int dm_test_main(const char *test_name)if (!test_name)printf ("Running %d driver model tests\n" , n_ents); + run_count =0 ;for (test = tests; test < tests + n_ents; test++) { -if (test_name &&strcmp (test_name, test->name)) +const char *name = test->name; + +/* All tests have this prefix */ +if (!strncmp (name,"dm_test_" ,8 )) + name +=8 ; +if (test_name &&strcmp (test_name, name))continue ;printf ("Test: %s\n" , test->name); + run_count++;ut_assertok (dm_test_init (uts)); uts->start =mallinfo ();
@@ -109,7 +117,10 @@ static int dm_test_main(const char *test_name)ut_assertok (dm_test_destroy (uts)); } -printf ("Failures: %d\n" , uts->fail_count); +if (test_name && !run_count) +printf ("Test '%s' not found\n" , test_name); +else +printf ("Failures: %d\n" , uts->fail_count); gd->dm_root =NULL ;ut_assertok (dm_init ());
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 2/18 dm: test: Allow test names to leave out the dm_test_ prefix
Quoted 8 lines · Simon Glass
All driver model tests have a
dm_test_prefix. Ignore it when matching a test name. This makes it easier to run individual tests, like this:./sandbox/u-boot -d ./sandbox/arch/sandbox/dts/test.dtb \ -c "ut dm clk_periph"We can use '
clk_periph' instead of 'dm_test_clk_periph'.
Quoted 7 lines
Also print a message if the requested test is not found.
Signed-off-by Simon Glass <[email protected]>---
test/dm/test-main.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
Applied to u-boot-dm.
PATCH 3/18 dm: test: Add tests for the clk uclass
In reply to Simon GlassAdd tests of each API call using a sandbox clock device.
---
arch/sandbox/dts/test.dts | 4 ++ arch/sandbox/include/asm/test.h | 11 ++++++ configs/sandbox_defconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/clk_sandbox.c | 85 +++++++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/clk.c | 59 ++++++++++++++++++++++++++++ 7 files changed, 162 insertions(+) create mode 100644 drivers/clk/clk_sandbox.c create mode 100644 test/dm/clk.c
arch/sandbox/dts/test.dts +4 -0
@@ -105,6 +105,10 @@ compatible = "denx,u-boot-fdt-test"; }; + clk at 0 { + compatible = "sandbox,clk"; + }; + eth at 10002000 { compatible = "sandbox,eth"; reg = <0x10002000 0x1000>;
arch/sandbox/include/asm/test.h +11 -0
@@ -17,6 +17,17 @@#define SANDBOX_PCI_CLASS_CODE PCI_CLASS_CODE_COMM#define SANDBOX_PCI_CLASS_SUB_CODE PCI_CLASS_SUB_CODE_COMM_SERIAL +#define SANDBOX_CLK_RATE 32768 + +enum { +PERIPH_ID_FIRST =0 , +PERIPH_ID_SPI =PERIPH_ID_FIRST , +PERIPH_ID_I2C , +PERIPH_ID_PCI , + +PERIPH_ID_COUNT , +}; +/** * sandbox_i2c_set_test_mode() - set test mode for running unit tests *
configs/sandbox_defconfig +1 -0
@@ -43,3 +43,4 @@ CONFIG_UT_TIME=y CONFIG_UT_DM=y CONFIG_UT_ENV=y CONFIG_SANDBOX_SERIAL=y +CONFIG_CLK=y
drivers/clk/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_CLK) += clk-uclass.o obj-$(CONFIG_ROCKCHIP_RK3288) += clk_rk3288.o +obj-$(CONFIG_SANDBOX) += clk_sandbox.o
drivers/clk/clk_sandbox.c new file +85 -0
85 lines not on this page · raw message
test/dm/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_UT_DM) += test-uclass.o # subsystem you must add sandbox tests here. obj-$(CONFIG_UT_DM) += core.o ifneq ($(CONFIG_SANDBOX),) +obj-$(CONFIG_CLK) += clk.o obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_I2C) += i2c.o
test/dm/clk.c new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 3/18 dm: test: Add tests for the clk uclass
Quoted 5 lines · Simon Glass
Add tests of each API call using a sandbox clock device.
Signed-off-by Simon Glass <[email protected]>---
Quoted 11 lines
arch/sandbox/dts/test.dts | 4 ++ arch/sandbox/include/asm/test.h | 11 ++++++ configs/sandbox_defconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/clk_sandbox.c | 85 +++++++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/clk.c | 59 ++++++++++++++++++++++++++++ 7 files changed, 162 insertions(+) create mode 100644 drivers/clk/clk_sandbox.c create mode 100644 test/dm/clk.c
Applied to u-boot-dm.
PATCH 4/18 dm: test: Add tests for the pinctrl uclass
In reply to Simon GlassAdd tests of each API call using a sandbox pinctrl device.
---
arch/sandbox/dts/test.dts | 11 ++++- configs/sandbox_defconfig | 1 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl_sandbox.c | 80 +++++++++++++++++++++++++++++++++ include/dt-bindings/clock/sandbox-clk.h | 10 +++++ test/dm/Makefile | 1 + test/dm/pinctrl.c | 63 ++++++++++++++++++++++++++ 7 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 drivers/pinctrl/pinctrl_sandbox.c create mode 100644 include/dt-bindings/clock/sandbox-clk.h create mode 100644 test/dm/pinctrl.c
arch/sandbox/dts/test.dts +10 -1
@@ -1,3 +1,5 @@ +#include <dt-bindings/clock/sandbox-clk.h> + /dts-v1/; / {
@@ -105,7 +107,7 @@ compatible = "denx,u-boot-fdt-test"; }; - clk at 0 { + clk: clk at 0 { compatible = "sandbox,clk"; };
@@ -149,6 +151,7 @@ reg = <0>; compatible = "sandbox,i2c"; clock-frequency = <100000>; + clocks = <&clk SANDBOX_CLK_I2C>; eeprom at 2c { reg = <0x2c>; compatible = "i2c-eeprom";
@@ -183,6 +186,7 @@ pci: pci-controller { compatible = "sandbox,pci"; device_type = "pci"; + clocks = <&clk SANDBOX_CLK_PCI>; #address-cells = <3>; #size-cells = <2>; ranges = <0x02000000 0 0x10000000 0x10000000 0 0x2000
@@ -196,10 +200,15 @@ }; }; + pinctrl at 0 { + compatible = "sandbox,pinctrl"; + }; + spi@0 { #address-cells = <1>; #size-cells = <0>; reg = <0>; + clocks = <&clk SANDBOX_CLK_SPI>; compatible = "sandbox,spi"; cs-gpios = <0>, <&gpio_a 0>; spi.bin at 0 {
configs/sandbox_defconfig +1 -0
@@ -44,3 +44,4 @@ CONFIG_UT_DM=y CONFIG_UT_ENV=y CONFIG_SANDBOX_SERIAL=y CONFIG_CLK=y +CONFIG_PINCTRL=y
drivers/pinctrl/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_PINCTRL) += pinctrl-uclass.o obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/ +obj-$(CONFIG_SANDBOX) += pinctrl_sandbox.o
drivers/pinctrl/pinctrl_sandbox.c new file +80 -0
80 lines not on this page · raw message
include/dt-bindings/clock/sandbox-clk.h new file +10 -0
@@ -0,0 +1,10 @@ +/* +* Copyright (c) 2015 Google, Inc +* Author: Simon Glass <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#define SANDBOX_CLK_SPI 42 +#define SANDBOX_CLK_PCI 43 +#define SANDBOX_CLK_I2C 44
test/dm/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_I2C) += i2c.o obj-$(CONFIG_DM_PCI) += pci.o +obj-$(CONFIG_PINCTRL) += pinctrl.o obj-$(CONFIG_DM_RTC) += rtc.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_DM_SPI) += spi.o
test/dm/pinctrl.c new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 4/18 dm: test: Add tests for the pinctrl uclass
Quoted 5 lines · Simon Glass
Add tests of each API call using a sandbox pinctrl device.
Signed-off-by Simon Glass <[email protected]>---
Quoted 11 lines
arch/sandbox/dts/test.dts | 11 ++++- configs/sandbox_defconfig | 1 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl_sandbox.c | 80 +++++++++++++++++++++++++++++++++ include/dt-bindings/clock/sandbox-clk.h | 10 +++++ test/dm/Makefile | 1 + test/dm/pinctrl.c | 63 ++++++++++++++++++++++++++ 7 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 drivers/pinctrl/pinctrl_sandbox.c create mode 100644 include/dt-bindings/clock/sandbox-clk.h create mode 100644 test/dm/pinctrl.c
Applied to u-boot-dm.
PATCH 5/18 sandbox: Support multiple reset types
In reply to Simon GlassAdd settings for the last reset generated, and the types of resets which are permitted. This will be used for testing.
---
arch/sandbox/cpu/state.c | 4 ++++ arch/sandbox/include/asm/state.h | 3 +++ 2 files changed, 7 insertions(+)
arch/sandbox/cpu/state.c +4 -0
@@ -345,6 +345,10 @@ int state_init(void) state->ram_buf =os_malloc (state->ram_size);assert (state->ram_buf); +/* No reset yet, so mark it as such. Always allow power reset */ + state->last_reset =RESET_COUNT ; + state->reset_allowed[RESET_POWER ] = true; +/* * Example of how to use GPIOs: *
arch/sandbox/include/asm/state.h +3 -0
@@ -7,6 +7,7 @@#define __SANDBOX_STATE_H#include <config.h> +#include <reset.h> #include <stdbool.h> #include <linux/stringify.h>
@@ -59,6 +60,8 @@ struct sandbox_state {bool write_state;/* Write sandbox state on exit */ bool ignore_missing_state_on_read;/* No error if state missing */ bool show_lcd;/* Show LCD on start-up */ +enum reset_t last_reset;/* Last reset type */ +bool reset_allowed[RESET_COUNT ];/* Allowed reset types */ enum state_terminal_raw term_raw;/* Terminal raw/cooked */ /* Pointer to information for each SPI bus/cs */
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 5/18 sandbox: Support multiple reset types
Quoted 9 lines · Simon Glass
Add settings for the last reset generated, and the types of resets which are permitted. This will be used for testing.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/cpu/state.c | 4 ++++ arch/sandbox/include/asm/state.h | 3 +++ 2 files changed, 7 insertions(+)
Applied to u-boot-dm.
PATCH 6/18 dm: reset: Allow reset_walk() to return
In reply to Simon GlassAdd a new reset_walk_halt() function to cause a reset and then halt on failure. The reset_walk() function returns an error code.
This is needed for testing since otherwise U-Boot will halt in the middle of a test.
---
drivers/misc/reset-uclass.c | 31 +++++++++++++++++++++++++------ include/reset.h | 11 ++++++++++- 2 files changed, 35 insertions(+), 7 deletions(-)
drivers/misc/reset-uclass.c +25 -6
@@ -25,23 +25,34 @@ int reset_request(struct udevice *dev, enum reset_t type)return ops->request (dev, type); } -void reset_walk (enum reset_t type) +int reset_walk (enum reset_t type) {struct udevice *dev; -int ret =0 ; +int ret = -ENOSYS ;while (ret != -EINPROGRESS && type <RESET_COUNT ) {for (uclass_first_device (UCLASS_RESET , &dev); - dev; -uclass_next_device (&dev)) { + dev; +uclass_next_device (&dev)) { ret =reset_request (dev, type);if (ret == -EINPROGRESS )break ; } + type++; } +return ret; +} + +void reset_walk_halt (enum reset_t type) +{ +int ret; + + ret =reset_walk (type); +/* Wait for the reset to take effect */ -mdelay (100 ); +if (ret == -EINPROGRESS ) +mdelay (100 );/* Still no reset? Give up */ printf ("Reset not supported on this platform\n" );
@@ -53,7 +64,15 @@ void reset_walk(enum reset_t type)*/ void reset_cpu (ulong addr) { -reset_walk (RESET_WARM ); +reset_walk_halt (RESET_WARM ); +} + + +int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +reset_walk_halt (RESET_WARM ); + +return 0 ; }UCLASS_DRIVER (reset) = {
include/reset.h +10 -1
@@ -51,8 +51,17 @@ int reset_request(struct udevice *dev, enum reset_t type);* If this function fails to reset, it will display a message and halt * * @type: Reset type to request +* @return -EINPROGRESS if a reset is in progress, -ENOSYS if not available */ -void reset_walk (enum reset_t type); +int reset_walk (enum reset_t type); + +/** +* reset_walk_halt() - try to reset, otherwise halt +* +* This calls reset_walk(). If it returns, indicating that reset is not +* supported, it prints a message and halts. +*/ +void reset_walk_halt (enum reset_t type);/** * reset_cpu() - calls reset_walk(RESET_WARM)
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 6/18 dm: reset: Allow reset_walk() to return
Quoted 6 lines · Simon Glass
Add a new
reset_walk_halt()function to cause a reset and then halt on failure. Thereset_walk()function returns an error code.This is needed for testing since otherwise U-Boot will halt in the middle of a test.
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/misc/reset-uclass.c | 31 +++++++++++++++++++++++++------ include/reset.h | 11 ++++++++++- 2 files changed, 35 insertions(+), 7 deletions(-)
Applied to u-boot-dm.
PATCH 7/18 sandbox: Add a warm and cold reset driver
In reply to Simon GlassAdd drivers for sandbox. One can only perform a warm reset (which does nothing). The other can perform a cold reset or a power reset (the latter will quit U-Boot). These can be used for testing the reset uclass.
---
drivers/misc/Makefile | 1 + drivers/misc/reset_sandbox.c | 100 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 drivers/misc/reset_sandbox.c
drivers/misc/Makefile +1 -0
@@ -22,6 +22,7 @@ obj-$(CONFIG_MXC_OCOTP) += mxc_ocotp.o obj-$(CONFIG_MXS_OCOTP) += mxs_ocotp.o obj-$(CONFIG_NS87308) += ns87308.o obj-$(CONFIG_PDSP188x) += pdsp188x.o +obj-$(CONFIG_SANDBOX) += reset_sandbox.o ifdef CONFIG_DM_I2C obj-$(CONFIG_SANDBOX) += i2c_eeprom_emul.o endif
drivers/misc/reset_sandbox.c new file +100 -0
100 lines not on this page · raw message
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 7/18 sandbox: Add a warm and cold reset driver
Quoted 11 lines · Simon Glass
Add drivers for sandbox. One can only perform a warm reset (which does nothing). The other can perform a cold reset or a power reset (the latter will quit U-Boot). These can be used for testing the reset uclass.
Signed-off-by Simon Glass <[email protected]>---
drivers/misc/Makefile | 1 + drivers/misc/reset_sandbox.c | 100 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 drivers/misc/reset_sandbox.c
Applied to u-boot-dm.
PATCH 8/18 sandbox: Use the reset driver to handle reset
In reply to Simon GlassMove sandbox over to use the reset uclass for reset, instead of a direct call to do_reset(). This allows us to add tests.
---
arch/sandbox/cpu/cpu.c | 9 +-------- arch/sandbox/dts/test.dts | 8 ++++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 3 +++ configs/sandbox_defconfig | 1 + 4 files changed, 13 insertions(+), 8 deletions(-)
arch/sandbox/cpu/cpu.c +1 -8
@@ -20,7 +20,7 @@ static struct udevice *map_dev;unsigned long map_len;#endif -void reset_cpu (ulong ignored) +void sandbox_exit (void ) {/* Do this here while it still has an effect */ os_fd_restore ();
@@ -34,13 +34,6 @@ void reset_cpu(ulong ignored)os_exit (0 ); } -int do_reset (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) -{ -reset_cpu (0 ); - -return 0 ; -} -/* delay x useconds */ void __udelay (unsigned long usec) {
arch/sandbox/dts/test.dts +8 -0
@@ -204,6 +204,14 @@ compatible = "sandbox,pinctrl"; }; + reset at 0 { + compatible = "sandbox,warm-reset"; + }; + + reset at 1 { + compatible = "sandbox,reset"; + }; + spi at 0 { #address-cells = <1>; #size-cells = <0>;
arch/sandbox/include/asm/u-boot-sandbox.h +3 -0
@@ -83,4 +83,7 @@ void sandbox_set_enable_pci_map(int enable);*/ int sandbox_read_fdt_from_file (void ); +/* Exit sandbox (quit U-Boot) */ +void sandbox_exit (void ); +#endif /* _U_BOOT_SANDBOX_H_ */
configs/sandbox_defconfig +1 -0
@@ -45,3 +45,4 @@ CONFIG_UT_ENV=y CONFIG_SANDBOX_SERIAL=y CONFIG_CLK=y CONFIG_PINCTRL=y +CONFIG_RESET=y
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 8/18 sandbox: Use the reset driver to handle reset
Quoted 11 lines · Simon Glass
Move sandbox over to use the reset uclass for reset, instead of a direct call to
do_reset(). This allows us to add tests.Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/cpu/cpu.c | 9 +-------- arch/sandbox/dts/test.dts | 8 ++++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 3 +++ configs/sandbox_defconfig | 1 + 4 files changed, 13 insertions(+), 8 deletions(-)
Applied to u-boot-dm.
PATCH 8/18 sandbox: Use the reset driver to handle reset
Quoted 7 lines · Simon Glass
Quoted 6 lines · Simon Glass
Move sandbox over to use the reset uclass for reset, instead of a direct call to
do_reset(). This allows us to add tests.Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
arch/sandbox/cpu/cpu.c | 9 +-------- arch/sandbox/dts/test.dts | 8 ++++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 3 +++ configs/sandbox_defconfig | 1 + 4 files changed, 13 insertions(+), 8 deletions(-)Applied to u-boot-dm.
This patch causes the reset command to stop working in sandbox. It now prints:
=> reset
Reset not supported on this platform
### ERROR ### Please RESET the board ###
Among other things, this causes ./test/fs/fs-test.sh to hang without any particular indication why. (In that test, running under expect/pyexpect might be nicer, so the user could see progress; the error above doesn't even show up in the test log files).
PATCH 8/18 sandbox: Use the reset driver to handle reset
Hi Stephen,
Quoted 19 lines · Stephen Warren
Quoted 7 lines · Simon Glass
Quoted 6 lines · Simon Glass
Move sandbox over to use the reset uclass for reset, instead of a direct call to
do_reset(). This allows us to add tests.Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
arch/sandbox/cpu/cpu.c | 9 +-------- arch/sandbox/dts/test.dts | 8 ++++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 3 +++ configs/sandbox_defconfig | 1 + 4 files changed, 13 insertions(+), 8 deletions(-)Applied to u-boot-dm.
This patch causes the reset command to stop working in sandbox. It now prints:
Quoted 8 lines
=> reset
Reset not supported on this platform
### ERROR ### Please RESET the board ###Among other things, this causes
./test/fs/fs-test.shto hang without any particular indication why. (In that test, running under expect/pyexpect might be nicer, so the user could see progress; the error above doesn't even show up in the test log files).
Yes I noticed the reset problem recently but haven't got back to it yet sorry. Ctrl-C works if you are at the command line, but will not fix the test.
One problem is that sandbox.dts needs a reset node, one of the ones from test.dts. Then at least 'u-boot -D' will work.
The other is that we need a U_BOOT_DEVICE() declaration for the reset controller. This is how drivers/serial/sandbox.c gets around this problem.
It would be good if we could run all the tests easily. At present it involves lots of steps and the method used to run each is different.
Regards,
Simon
PATCH 8/18 sandbox: Use the reset driver to handle reset
Quoted 38 lines · Simon Glass
Hi Stephen,
Quoted 19 lines · Stephen Warren
Quoted 7 lines · Simon Glass
Quoted 6 lines · Simon Glass
Move sandbox over to use the reset uclass for reset, instead of a direct call to
do_reset(). This allows us to add tests.Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
arch/sandbox/cpu/cpu.c | 9 +-------- arch/sandbox/dts/test.dts | 8 ++++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 3 +++ configs/sandbox_defconfig | 1 + 4 files changed, 13 insertions(+), 8 deletions(-)Applied to u-boot-dm.
This patch causes the reset command to stop working in sandbox. It now prints:
Quoted 8 lines
=> reset
Reset not supported on this platform
### ERROR ### Please RESET the board ###Among other things, this causes
./test/fs/fs-test.shto hang without any particular indication why. (In that test, running under expect/pyexpect might be nicer, so the user could see progress; the error above doesn't even show up in the test log files).Yes I noticed the reset problem recently but haven't got back to it yet sorry. Ctrl-C works if you are at the command line, but will not fix the test.
One problem is that
sandbox.dtsneeds a reset node, one of the ones fromtest.dts. Then at least 'u-boot -D' will work.
Quoted 6 lines
The other is that we need a
U_BOOT_DEVICE()declaration for the reset controller. This is howdrivers/serial/sandbox.cgets around this problem.It would be good if we could run all the tests easily. At present it involves lots of steps and the method used to run each is different.
Any update on this? I had forgotten about this issue and just debugged the exact same problem again. Unfortunately, reverting this commit seems to make U-Boot hang() at early init time now, so I can't work around the issue either (unless I made a mistake implementing the revert; I'll try again).
PATCH 8/18 sandbox: Use the reset driver to handle reset
Quoted 43 lines · Stephen Warren
Quoted 42 lines · Simon Glass
Hi Stephen,
Quoted 19 lines · Stephen Warren
Quoted 7 lines · Simon Glass
Quoted 6 lines · Simon Glass
Move sandbox over to use the reset uclass for reset, instead of a direct call to
do_reset(). This allows us to add tests.Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
arch/sandbox/cpu/cpu.c | 9 +-------- arch/sandbox/dts/test.dts | 8 ++++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 3 +++ configs/sandbox_defconfig | 1 + 4 files changed, 13 insertions(+), 8 deletions(-)Applied to u-boot-dm.
This patch causes the reset command to stop working in sandbox. It now prints:
Quoted 8 lines
=> reset
Reset not supported on this platform
### ERROR ### Please RESET the board ###Among other things, this causes
./test/fs/fs-test.shto hang without any particular indication why. (In that test, running under expect/pyexpect might be nicer, so the user could see progress; the error above doesn't even show up in the test log files).Yes I noticed the reset problem recently but haven't got back to it yet sorry. Ctrl-C works if you are at the command line, but will not fix the test.
One problem is that
sandbox.dtsneeds a reset node, one of the ones fromtest.dts. Then at least 'u-boot -D' will work.The other is that we need a
U_BOOT_DEVICE()declaration for the reset controller. This is howdrivers/serial/sandbox.cgets around this problem.
Quoted 8 lines
Quoted 2 lines
It would be good if we could run all the tests easily. At present it involves lots of steps and the method used to run each is different.
Any update on this? I had forgotten about this issue and just debugged the exact same problem again. Unfortunately, reverting this commit seems to make U-Boot
hang()at early init time now, so I can't work around the issue either (unless I made a mistake implementing the revert; I'll try again).
The following hack makes reset work again. This sounds like something other than the issues you mentioned above?
Quoted 17 lines
https://github.com/swarren/u-boot/commit/2e41c317516e414326620374725a25b7b531d2e2
drivers/misc/reset_sandbox.c +2
-0@@ -40,8 +40,10 @@ static int sandbox_reset_request(struct udevice *dev, enum reset_t type)* (see the U_BOOT_DEVICE() declaration below) should not do anything. * If we are that device, return an error. */ +#if 0 if (gd->fdt_blob && dev->of_offset ==-1 )return -ENODEV ; +#endif switch (type) {case RESET_COLD :
PATCH 8/18 sandbox: Use the reset driver to handle reset
Hi Stephen,
Quoted 71 lines · Stephen Warren
Quoted 43 lines · Stephen Warren
Quoted 42 lines · Simon Glass
Hi Stephen,
Quoted 19 lines · Stephen Warren
Quoted 7 lines · Simon Glass
Quoted 6 lines · Simon Glass
Move sandbox over to use the reset uclass for reset, instead of a direct call to
do_reset(). This allows us to add tests.Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
Quoted 5 lines
arch/sandbox/cpu/cpu.c | 9 +-------- arch/sandbox/dts/test.dts | 8 ++++++++ arch/sandbox/include/asm/u-boot-sandbox.h | 3 +++ configs/sandbox_defconfig | 1 + 4 files changed, 13 insertions(+), 8 deletions(-)Applied to u-boot-dm.
This patch causes the reset command to stop working in sandbox. It now prints:
Quoted 8 lines
=> reset
Reset not supported on this platform
### ERROR ### Please RESET the board ###Among other things, this causes
./test/fs/fs-test.shto hang without any particular indication why. (In that test, running under expect/pyexpect might be nicer, so the user could see progress; the error above doesn't even show up in the test log files).Yes I noticed the reset problem recently but haven't got back to it yet sorry. Ctrl-C works if you are at the command line, but will not fix the test.
One problem is that
sandbox.dtsneeds a reset node, one of the ones fromtest.dts. Then at least 'u-boot -D' will work.The other is that we need a
U_BOOT_DEVICE()declaration for the reset controller. This is howdrivers/serial/sandbox.cgets around this problem.Quoted 8 lines
Quoted 2 lines
It would be good if we could run all the tests easily. At present it involves lots of steps and the method used to run each is different.
Any update on this? I had forgotten about this issue and just debugged the exact same problem again. Unfortunately, reverting this commit seems to make U-Boot
hang()at early init time now, so I can't work around the issue either (unless I made a mistake implementing the revert; I'll try again).The following hack makes reset work again. This sounds like something other than the issues you mentioned above?
Quoted 15 lines
https://github.com/swarren/u-boot/commit/2e41c317516e414326620374725a25b7b531d2e2
drivers/misc/reset_sandbox.c +2
-0@@ -40,8 +40,10 @@ static int sandbox_reset_request(struct udevice *dev, enum reset_t type)* (see the U_BOOT_DEVICE() declaration below) should not do anything. * If we are that device, return an error. */ +#if 0 if (gd->fdt_blob && dev->of_offset ==-1 )return -ENODEV ; +#endif
Quoted 3 lines
drivers/misc/reset_sandbox.c static int sandbox_reset_request(struct udevice *dev, enum reset_t type) · line 49
Quoted 2 lines
drivers/misc/reset_sandbox.c +0
-0switch (type) {case RESET_COLD :
I've sent a patch:
http://patchwork.ozlabs.org/patch/525967/
Regards,
Simon
PATCH 9/18 dm: test: Add a test for the reset uclass
In reply to Simon GlassAdd tests that confirm that the drivers work as expected, and we can walk through the available reset types trying to reset the board.
---
test/dm/Makefile | 1 + test/dm/reset.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 test/dm/reset.c
test/dm/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_I2C) += i2c.o obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_PINCTRL) += pinctrl.o +obj-$(CONFIG_RESET) += reset.o obj-$(CONFIG_DM_RTC) += rtc.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_DM_SPI) += spi.o
test/dm/reset.c new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 9/18 dm: test: Add a test for the reset uclass
Quoted 10 lines · Simon Glass
Add tests that confirm that the drivers work as expected, and we can walk through the available reset types trying to reset the board.
Signed-off-by Simon Glass <[email protected]>---
test/dm/Makefile | 1 + test/dm/reset.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 test/dm/reset.c
Applied to u-boot-dm.
PATCH 10/18 dm: test: Add a test for the ram uclass
In reply to Simon GlassAdd a test to confirm that we can probe this device and get information on the available RAM.
---
arch/sandbox/dts/test.dts | 4 ++++ configs/sandbox_defconfig | 1 + drivers/ram/Makefile | 1 + drivers/ram/sandbox_ram.c | 38 ++++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/ram.c | 28 ++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 drivers/ram/sandbox_ram.c create mode 100644 test/dm/ram.c
arch/sandbox/dts/test.dts +4 -0
@@ -204,6 +204,10 @@ compatible = "sandbox,pinctrl"; }; + ram { + compatible = "sandbox,ram"; + }; + reset at 0 { compatible = "sandbox,warm-reset"; };
configs/sandbox_defconfig +1 -0
@@ -46,3 +46,4 @@ CONFIG_SANDBOX_SERIAL=y CONFIG_CLK=y CONFIG_PINCTRL=y CONFIG_RESET=y +CONFIG_RAM=y
drivers/ram/Makefile +1 -0
@@ -5,3 +5,4 @@ # SPDX-License-Identifier: GPL-2.0+ # obj-$(CONFIG_RAM) += ram-uclass.o +obj-$(CONFIG_SANDBOX) += sandbox_ram.o
drivers/ram/sandbox_ram.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Copyright (c) 2015 Google, Inc +* Written by Simon Glass <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <ram.h> +#include <asm/test.h> + +DECLARE_GLOBAL_DATA_PTR ; + +static int sandbox_get_info (struct udevice *dev,struct ram_info *info) +{ + info->base =0 ; + info->size = gd->ram_size; + +return 0 ; +} + +static const struct ram_ops sandbox_ram_ops = { + .get_info = sandbox_get_info, +}; + +static const struct udevice_id sandbox_ram_ids[] = { + { .compatible ="sandbox,ram" }, + { } +}; + +U_BOOT_DRIVER (warm_ram_sandbox) = { + .name ="ram_sandbox" , + .id =UCLASS_RAM , + .of_match = sandbox_ram_ids, + .ops = &sandbox_ram_ops, +};
test/dm/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_I2C) += i2c.o obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_PINCTRL) += pinctrl.o +obj-$(CONFIG_RAM) += ram.o obj-$(CONFIG_RESET) += reset.o obj-$(CONFIG_DM_RTC) += rtc.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o
test/dm/ram.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (C) 2015 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <ram.h> +#include <dm/test.h> +#include <test/ut.h> + +DECLARE_GLOBAL_DATA_PTR ; + +/* Basic test of the ram uclass */ +static int dm_test_ram_base (struct unit_test_state *uts) +{ +struct udevice *dev; +struct ram_info info; + +ut_assertok (uclass_get_device (UCLASS_RAM ,0 , &dev)); +ut_assertok (ram_get_info (dev, &info)); +ut_asserteq (0 , info.base); +ut_asserteq (gd->ram_size, info.size); + +return 0 ; +} +DM_TEST (dm_test_ram_base,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 10/18 dm: test: Add a test for the ram uclass
Quoted 6 lines · Simon Glass
Add a test to confirm that we can probe this device and get information on the available RAM.
Signed-off-by Simon Glass <[email protected]>---
Quoted 9 lines
arch/sandbox/dts/test.dts | 4 ++++ configs/sandbox_defconfig | 1 + drivers/ram/Makefile | 1 + drivers/ram/sandbox_ram.c | 38 ++++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/ram.c | 28 ++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 drivers/ram/sandbox_ram.c create mode 100644 test/dm/ram.c
Applied to u-boot-dm.
PATCH 11/18 dm: test: Add a test for the mmc uclass
In reply to Simon GlassAdd a test to confirm that we can probe this device. Since there is no MMC stack support in sandbox at present, this is as far as the test goes.
---
arch/sandbox/dts/test.dts | 4 ++++ configs/sandbox_defconfig | 1 + drivers/mmc/Makefile | 1 + drivers/mmc/sandbox_mmc.c | 25 +++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/mmc.c | 27 +++++++++++++++++++++++++++ 6 files changed, 59 insertions(+) create mode 100644 drivers/mmc/sandbox_mmc.c create mode 100644 test/dm/mmc.c
arch/sandbox/dts/test.dts +4 -0
@@ -183,6 +183,10 @@ }; }; + mmc { + compatible = "sandbox,mmc"; + }; + pci: pci-controller { compatible = "sandbox,pci"; device_type = "pci";
configs/sandbox_defconfig +1 -0
@@ -47,3 +47,4 @@ CONFIG_CLK=y CONFIG_PINCTRL=y CONFIG_RESET=y CONFIG_RAM=y +CONFIG_DM_MMC=y
drivers/mmc/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_ROCKCHIP_MMC) += rockchip_mmc.o obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o obj-$(CONFIG_S3C_SDI) += s3c_sdi.o obj-$(CONFIG_S5P_SDHCI) += s5p_sdhci.o +obj-$(CONFIG_SANDBOX) += sandbox_mmc.o obj-$(CONFIG_SDHCI) += sdhci.o obj-$(CONFIG_SH_MMCIF) += sh_mmcif.o obj-$(CONFIG_SH_SDHI) += sh_sdhi.o
drivers/mmc/sandbox_mmc.c new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (c) 2015 Google, Inc +* Written by Simon Glass <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <mmc.h> +#include <asm/test.h> + +DECLARE_GLOBAL_DATA_PTR ; + +static const struct udevice_id sandbox_mmc_ids[] = { + { .compatible ="sandbox,mmc" }, + { } +}; + +U_BOOT_DRIVER (warm_mmc_sandbox) = { + .name ="mmc_sandbox" , + .id =UCLASS_MMC , + .of_match = sandbox_mmc_ids, +};
test/dm/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_CLK) += clk.o obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_I2C) += i2c.o +obj-$(CONFIG_DM_MMC) += mmc.o obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_PINCTRL) += pinctrl.o obj-$(CONFIG_RAM) += ram.o
test/dm/mmc.c new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (C) 2015 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <mmc.h> +#include <dm/test.h> +#include <test/ut.h> + +DECLARE_GLOBAL_DATA_PTR ; + +/* +* Basic test of the mmc uclass. We could expand this by implementing an MMC +* stack for sandbox, or at least implementing the basic operation. +*/ +static int dm_test_mmc_base (struct unit_test_state *uts) +{ +struct udevice *dev; + +ut_assertok (uclass_get_device (UCLASS_MMC ,0 , &dev)); + +return 0 ; +} +DM_TEST (dm_test_mmc_base,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 11/18 dm: test: Add a test for the mmc uclass
Quoted 6 lines · Simon Glass
Add a test to confirm that we can probe this device. Since there is no MMC stack support in sandbox at present, this is as far as the test goes.
Signed-off-by Simon Glass <[email protected]>---
Quoted 9 lines
arch/sandbox/dts/test.dts | 4 ++++ configs/sandbox_defconfig | 1 + drivers/mmc/Makefile | 1 + drivers/mmc/sandbox_mmc.c | 25 +++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/mmc.c | 27 +++++++++++++++++++++++++++ 6 files changed, 59 insertions(+) create mode 100644 drivers/mmc/sandbox_mmc.c create mode 100644 test/dm/mmc.c
Applied to u-boot-dm.
PATCH 12/18 led: Return -ENODEV if the LED device cannot be found
In reply to Simon GlassWe normally use -ENODEV for a missing device, rather than -ENOENT. The latter is reserved for when we have a device but cannot find something within it.
Also avoid looking at the root LED device since it is only a container.
---
drivers/led/led-uclass.c | 5 +++-- include/led.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/led/led-uclass.c +3 -2
@@ -24,11 +24,12 @@ int led_get_by_label(const char *label, struct udevice **devp) uclass_foreach_dev(dev, uc) {struct led_uclass_plat *uc_plat =dev_get_uclass_platdata (dev); -if (!strcmp (label, uc_plat->label)) +/* Ignore the top-level LED node */ +if (uc_plat->label && !strcmp (label, uc_plat->label))return uclass_get_device_tail (dev,0 , devp); } -return -ENOENT ; +return -ENODEV ; }int led_set_on (struct udevice *dev,int on)
include/led.h +1 -1
@@ -35,7 +35,7 @@ struct led_ops {* * @label: LED label to look up * @devp: Returns the associated device, if found -* @return 0 if found, -ve on error +* @return 0 if found, -ENODEV if not found, other -ve on error */ int led_get_by_label (const char *label,struct udevice **devp);
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 12/18 led: Return -ENODEV if the LED device cannot be found
Quoted 4 lines · Simon Glass
We normally use
-ENODEVfor a missing device, rather than-ENOENT. The latter is reserved for when we have a device but cannot find something within it.
Quoted 8 lines
Also avoid looking at the root LED device since it is only a container.
Signed-off-by Simon Glass <[email protected]>---
drivers/led/led-uclass.c | 5 +++-- include/led.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-)
Applied to u-boot-dm.
PATCH 13/18 dm: test: Add a test for the LED uclass
In reply to Simon GlassAdd a test to confirm that we can adjust LEDs using the led_gpio driver.
---
arch/sandbox/dts/test.dts | 14 +++++++++ configs/sandbox_defconfig | 2 ++ drivers/led/led_gpio.c | 6 ++++ test/dm/Makefile | 1 + test/dm/led.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 test/dm/led.c
arch/sandbox/dts/test.dts +14 -0
@@ -183,6 +183,20 @@ }; }; + leds { + compatible = "gpio-leds"; + + iracibble { + gpios = <&gpio_a 1 0>; + label = "sandbox:red"; + }; + + martinet { + gpios = <&gpio_a 2 0>; + label = "sandbox:green"; + }; + }; + mmc { compatible = "sandbox,mmc"; };
configs/sandbox_defconfig +2 -0
@@ -48,3 +48,5 @@ CONFIG_PINCTRL=y CONFIG_RESET=y CONFIG_RAM=y CONFIG_DM_MMC=y +CONFIG_LED=y +CONFIG_LED_GPIO=y
drivers/led/led_gpio.c +6 -0
@@ -41,10 +41,16 @@ static int led_gpio_probe(struct udevice *dev)static int led_gpio_remove (struct udevice *dev) { +/* +* The GPIO driver may have already been removed. We will need to +* address this more generally. +*/ +#ifndef CONFIG_SANDBOX struct led_gpio_priv *priv =dev_get_priv (dev);if (dm_gpio_is_valid (&priv->gpio))dm_gpio_free (dev, &priv->gpio); +#endif return 0 ; }
test/dm/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_CLK) += clk.o obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_I2C) += i2c.o +obj-$(CONFIG_LED) += led.o obj-$(CONFIG_DM_MMC) += mmc.o obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_PINCTRL) += pinctrl.o
test/dm/led.c new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 13/18 dm: test: Add a test for the LED uclass
Quoted 5 lines · Simon Glass
Add a test to confirm that we can adjust LEDs using the
led_gpiodriver.Signed-off-by Simon Glass <[email protected]>---
Quoted 7 lines
arch/sandbox/dts/test.dts | 14 +++++++++ configs/sandbox_defconfig | 2 ++ drivers/led/led_gpio.c | 6 ++++ test/dm/Makefile | 1 + test/dm/led.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 test/dm/led.c
Applied to u-boot-dm.
PATCH 14/18 dm: test: Add a test for the system controller uclass
In reply to Simon GlassAdd a test to confirm that we can access system controllers and find their driver data.
---
arch/sandbox/dts/test.dts | 10 ++++++++++ arch/sandbox/include/asm/test.h | 8 ++++++++ configs/sandbox_defconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/syscon_sandbox.c | 27 +++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/syscon.c | 31 +++++++++++++++++++++++++++++++ 7 files changed, 79 insertions(+) create mode 100644 drivers/misc/syscon_sandbox.c create mode 100644 test/dm/syscon.c
arch/sandbox/dts/test.dts +10 -0
@@ -249,6 +249,16 @@ }; }; + syscon at 0 { + compatible = "sandbox,syscon0"; + reg = <0x10>; + }; + + syscon at 1 { + compatible = "sandbox,syscon1"; + reg = <0x20>; + }; + uart0: serial { compatible = "sandbox,serial"; u-boot,dm-pre-reloc;
arch/sandbox/include/asm/test.h +8 -0
@@ -28,6 +28,14 @@ enum { PERIPH_ID_COUNT, }; +/* System controller driver data */ +enum { +SYSCON0 =32 , +SYSCON1 , + +SYSCON_COUNT +}; +/** * sandbox_i2c_set_test_mode() - set test mode for running unit tests *
configs/sandbox_defconfig +1 -0
@@ -50,3 +50,4 @@ CONFIG_RAM=y CONFIG_DM_MMC=y CONFIG_LED=y CONFIG_LED_GPIO=y +CONFIG_SYSCON=y
drivers/misc/Makefile +1 -0
@@ -29,6 +29,7 @@ endif obj-$(CONFIG_SMSC_LPC47M) += smsc_lpc47m.o obj-$(CONFIG_STATUS_LED) += status_led.o obj-$(CONFIG_SANDBOX) += swap_case.o +obj-$(CONFIG_SANDBOX) += syscon_sandbox.o obj-$(CONFIG_TWL4030_LED) += twl4030_led.o obj-$(CONFIG_FSL_IFC) += fsl_ifc.o obj-$(CONFIG_FSL_SEC_MON) += fsl_sec_mon.o
drivers/misc/syscon_sandbox.c new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (c) 2015 Google, Inc +* Written by Simon Glass <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <syscon.h> +#include <asm/test.h> +#include <dm/lists.h> + +DECLARE_GLOBAL_DATA_PTR ; + +static const struct udevice_id sandbox_syscon_ids[] = { + { .compatible ="sandbox,syscon0" , .data =SYSCON0 }, + { .compatible ="sandbox,syscon1" , .data =SYSCON1 }, + { } +}; + +U_BOOT_DRIVER (sandbox_syscon) = { + .name ="sandbox_syscon" , + .id =UCLASS_SYSCON , + .of_match = sandbox_syscon_ids, +};
test/dm/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_RESET) += reset.o obj-$(CONFIG_DM_RTC) += rtc.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_DM_SPI) += spi.o +obj-y += syscon.o obj-$(CONFIG_DM_USB) += usb.o obj-$(CONFIG_DM_PMIC) += pmic.o obj-$(CONFIG_DM_REGULATOR) += regulator.o
test/dm/syscon.c new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright (C) 2015 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <syscon.h> +#include <asm/test.h> +#include <dm/test.h> +#include <test/ut.h> + +DECLARE_GLOBAL_DATA_PTR ; + +/* Base test of system controllers */ +static int dm_test_syscon_base (struct unit_test_state *uts) +{ +struct udevice *dev; + +ut_assertok (uclass_get_device (UCLASS_SYSCON ,0 , &dev)); +ut_asserteq (SYSCON0 , dev->driver_data); + +ut_assertok (uclass_get_device (UCLASS_SYSCON ,1 , &dev)); +ut_asserteq (SYSCON1 , dev->driver_data); + +ut_asserteq (-ENODEV ,uclass_get_device (UCLASS_SYSCON ,2 , &dev)); + +return 0 ; +} +DM_TEST (dm_test_syscon_base,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 14/18 dm: test: Add a test for the system controller uclass
Quoted 6 lines · Simon Glass
Add a test to confirm that we can access system controllers and find their driver data.
Signed-off-by Simon Glass <[email protected]>---
Quoted 11 lines
arch/sandbox/dts/test.dts | 10 ++++++++++ arch/sandbox/include/asm/test.h | 8 ++++++++ configs/sandbox_defconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/syscon_sandbox.c | 27 +++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/syscon.c | 31 +++++++++++++++++++++++++++++++ 7 files changed, 79 insertions(+) create mode 100644 drivers/misc/syscon_sandbox.c create mode 100644 test/dm/syscon.c
Applied to u-boot-dm.
PATCH 15/18 dm: test: Add a size to each reg property
In reply to Simon GlassEach sandbox peripheral should have a size as well as a base address. This is required for regmaps to work, so make this change for all nodes that have an address.
---
arch/sandbox/dts/test.dts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
arch/sandbox/dts/test.dts +15 -12
@@ -6,7 +6,7 @@ model = "sandbox"; compatible = "sandbox"; #address-cells = <1>; - #size-cells = <0>; + #size-cells = <1>; aliases { console = &uart0;
@@ -30,7 +30,7 @@ }; a-test { - reg = <0>; + reg = <0 1>; compatible = "denx,u-boot-fdt-test"; ping-expect = <0>; ping-add = <0>;
@@ -43,16 +43,16 @@ }; junk { - reg = <1>; + reg = <1 1>; compatible = "not,compatible"; }; no-compatible { - reg = <2>; + reg = <2 1>; }; b-test { - reg = <3>; + reg = <3 1>; compatible = "denx,u-boot-fdt-test"; ping-expect = <3>; ping-add = <3>;
@@ -62,7 +62,7 @@ #address-cells = <1>; #size-cells = <0>; compatible = "denx,u-boot-test-bus"; - reg = <3>; + reg = <3 1>; ping-expect = <4>; ping-add = <4>; c-test at 5 {
@@ -86,14 +86,14 @@ }; d-test { - reg = <3>; + reg = <3 1>; ping-expect = <6>; ping-add = <6>; compatible = "google,another-fdt-test"; }; e-test { - reg = <3>; + reg = <3 1>; ping-expect = <6>; ping-add = <6>; compatible = "google,another-fdt-test";
@@ -148,7 +148,7 @@ i2c at 0 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <0 1>; compatible = "sandbox,i2c"; clock-frequency = <100000>; clocks = <&clk SANDBOX_CLK_I2C>;
@@ -237,7 +237,7 @@ spi at 0 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <0 1>; clocks = <&clk SANDBOX_CLK_SPI>; compatible = "sandbox,spi"; cs-gpios = <0>, <&gpio_a 0>;
@@ -251,12 +251,15 @@ syscon at 0 { compatible = "sandbox,syscon0"; - reg = <0x10>; + reg = <0x10 4>; }; syscon at 1 { compatible = "sandbox,syscon1"; - reg = <0x20>; + reg = <0x20 5 + 0x28 6 + 0x30 7 + 0x38 8>; }; uart0: serial {
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 15/18 dm: test: Add a size to each reg property
Quoted 9 lines · Simon Glass
Each sandbox peripheral should have a size as well as a base address. This is required for regmaps to work, so make this change for all nodes that have an address.
Signed-off-by Simon Glass <[email protected]>---
arch/sandbox/dts/test.dts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
Applied to u-boot-dm.
PATCH 16/18 test: Add a macro to check that a value is not an error pointer
In reply to Simon GlassSome functions can return ERR_PTR(errval). Add a unit test macro to check that no error is returned in a pointer.
---
include/test/ut.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
include/test/ut.h +15 -0
@@ -9,6 +9,8 @@#ifndef __TEST_UT_H#define __TEST_UT_H +#include <linux/err.h> +struct unit_test_state ;/**
@@ -101,6 +103,19 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line, } \ } +/* Assert that a pointer is not an error pointer */ +#define ut_assertok_ptr (expr) { \ + const void *val = (expr); \ + \ + if (IS_ERR(val)) { \ + ut_failf(uts, __FILE__, __LINE__, __func__, \ + #expr " = NULL", \ + "Expected pointer, got error %ld", \ + PTR_ERR(val)); \ + return CMD_RET_FAILURE; \ + } \ +} +/* Assert that an operation succeeds (returns 0) */ #define ut_assertok (cond) ut_asserteq(0, cond)
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 16/18 test: Add a macro to check that a value is not an error pointer
Quoted 8 lines · Simon Glass
Some functions can return
ERR_PTR(errval). Add a unit test macro to check that no error is returned in a pointer.Signed-off-by Simon Glass <[email protected]>---
include/test/ut.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Applied to u-boot-dm.
PATCH 17/18 dm: core: Add device checking to syscon_get_regmap()
In reply to Simon GlassThis function can only handle a syscon device. It is possible that someone will make a mistake, so add a check for this.
Also we should return -ENODEV when a device cannot be found, so update the syscon_get_regmap_by_driver_data() to follow this convention.
---
drivers/core/syscon-uclass.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/core/syscon-uclass.c +5 -2
@@ -17,8 +17,11 @@struct regmap *syscon_get_regmap (struct udevice *dev) { -struct syscon_uc_info *priv =dev_get_uclass_priv (dev); +struct syscon_uc_info *priv; +if (device_get_uclass_id (dev) !=UCLASS_SYSCON ) +return ERR_PTR (-ENOEXEC ); + priv =dev_get_uclass_priv (dev);return priv->regmap; }
@@ -52,7 +55,7 @@ struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data) } } -return ERR_PTR (-ENOENT ); +return ERR_PTR (-ENODEV ); }void *syscon_get_first_range (ulong driver_data)
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 17/18 dm: core: Add device checking to syscon_get_regmap()
Quoted 11 lines · Simon Glass
This function can only handle a syscon device. It is possible that someone will make a mistake, so add a check for this.
Also we should return
-ENODEVwhen a device cannot be found, so update thesyscon_get_regmap_by_driver_data()to follow this convention.Signed-off-by Simon Glass <[email protected]>---
drivers/core/syscon-uclass.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Applied to u-boot-dm.
PATCH 18/18 test: Add a test for regmap
In reply to Simon GlassWe use syscon to test that the regmap functions work as expected.
---
test/dm/Makefile | 1 + test/dm/regmap.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 test/dm/regmap.c
test/dm/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_DM_MMC) += mmc.o obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_PINCTRL) += pinctrl.o obj-$(CONFIG_RAM) += ram.o +obj-y += regmap.o obj-$(CONFIG_RESET) += reset.o obj-$(CONFIG_DM_RTC) += rtc.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o
test/dm/regmap.c new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.4.3.573.g4eafbef
PATCH 18/18 test: Add a test for regmap
Quoted 9 lines · Simon Glass
We use syscon to test that the regmap functions work as expected.
Signed-off-by Simon Glass <[email protected]>---
test/dm/Makefile | 1 + test/dm/regmap.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 test/dm/regmap.c
Applied to u-boot-dm.