2 * Copyright (c) 2013 Google, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
13 * struct dm_test_cdata - configuration data for test instance
15 * @ping_add: Amonut to add each time we get a ping
16 * @base: Base address of this device
18 struct dm_test_pdata {
24 * struct test_ops - Operations supported by the test device
26 * @ping: Ping operation
27 * @dev: Device to operate on
28 * @pingval: Value to ping the device with
29 * @pingret: Returns resulting value from driver
30 * @return 0 if OK, -ve on error
33 int (*ping)(struct udevice *dev, int pingval, int *pingret);
36 /* Operations that our test driver supports */
45 DM_TEST_OP_PRE_UNBIND,
46 DM_TEST_OP_POST_PROBE,
47 DM_TEST_OP_PRE_REMOVE,
54 /* Test driver types */
56 DM_TEST_TYPE_FIRST = 0,
60 /* The number added to the ping total on each probe */
61 #define DM_TEST_START_TOTAL 5
64 * struct dm_test_priv - private data for the test devices
68 int op_count[DM_TEST_OP_COUNT];
72 * struct dm_test_perdev_class_priv - private per-device data for test uclass
74 struct dm_test_uclass_perdev_priv {
79 * struct dm_test_uclass_priv - private data for test uclass
81 struct dm_test_uclass_priv {
86 * struct dm_test_parent_data - parent's information on each child
88 * @sum: Test value used to check parent data works correctly
90 struct dm_test_parent_data {
95 * Operation counts for the test driver, used to check that each method is
98 extern int dm_testdrv_op_count[DM_TEST_OP_COUNT];
100 extern struct dm_test_state global_test_state;
103 * struct dm_test_state - Entire state of dm test system
105 * This is often abreviated to dms.
108 * @testdev: Test device
109 * @fail_count: Number of tests that failed
110 * @force_fail_alloc: Force all memory allocs to fail
111 * @skip_post_probe: Skip uclass post-probe processing
113 struct dm_test_state {
114 struct udevice *root;
115 struct udevice *testdev;
117 int force_fail_alloc;
121 /* Test flags for each test */
123 DM_TESTF_SCAN_PDATA = 1 << 0, /* test needs platform data */
124 DM_TESTF_PROBE_TEST = 1 << 1, /* probe test uclass */
125 DM_TESTF_SCAN_FDT = 1 << 2, /* scan device tree */
129 * struct dm_test - Information about a driver model test
131 * @name: Name of test
132 * @func: Function to call to perform test
133 * @flags: Flags indicated pre-conditions for test
137 int (*func)(struct dm_test_state *dms);
141 /* Declare a new driver model test */
142 #define DM_TEST(_name, _flags) \
143 ll_entry_declare(struct dm_test, _name, dm_test) = { \
149 /* Declare ping methods for the drivers */
150 int test_ping(struct udevice *dev, int pingval, int *pingret);
151 int testfdt_ping(struct udevice *dev, int pingval, int *pingret);
154 * dm_check_operations() - Check that we can perform ping operations
156 * This checks that the ping operations work as expected for a device
158 * @dms: Overall test state
159 * @dev: Device to test
160 * @base: Base address, used to check ping return value
161 * @priv: Pointer to private test information
162 * @return 0 if OK, -ve on error
164 int dm_check_operations(struct dm_test_state *dms, struct udevice *dev,
165 uint32_t base, struct dm_test_priv *priv);
168 * dm_check_devices() - check the devices respond to operations correctly
170 * @dms: Overall test state
171 * @num_devices: Number of test devices to check
172 * @return 0 if OK, -ve on error
174 int dm_check_devices(struct dm_test_state *dms, int num_devices);
177 * dm_test_main() - Run all the tests
179 * This runs all available driver model tests
181 * @return 0 if OK, -ve on error
183 int dm_test_main(void);