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
89 * @flag: Used to track calling of parent operations
91 struct dm_test_parent_data {
97 * Operation counts for the test driver, used to check that each method is
100 extern int dm_testdrv_op_count[DM_TEST_OP_COUNT];
102 extern struct dm_test_state global_test_state;
105 * struct dm_test_state - Entire state of dm test system
107 * This is often abreviated to dms.
110 * @testdev: Test device
111 * @fail_count: Number of tests that failed
112 * @force_fail_alloc: Force all memory allocs to fail
113 * @skip_post_probe: Skip uclass post-probe processing
114 * @removed: Used to keep track of a device that was removed
116 struct dm_test_state {
117 struct udevice *root;
118 struct udevice *testdev;
120 int force_fail_alloc;
122 struct udevice *removed;
125 /* Test flags for each test */
127 DM_TESTF_SCAN_PDATA = 1 << 0, /* test needs platform data */
128 DM_TESTF_PROBE_TEST = 1 << 1, /* probe test uclass */
129 DM_TESTF_SCAN_FDT = 1 << 2, /* scan device tree */
133 * struct dm_test - Information about a driver model test
135 * @name: Name of test
136 * @func: Function to call to perform test
137 * @flags: Flags indicated pre-conditions for test
141 int (*func)(struct dm_test_state *dms);
145 /* Declare a new driver model test */
146 #define DM_TEST(_name, _flags) \
147 ll_entry_declare(struct dm_test, _name, dm_test) = { \
153 /* Declare ping methods for the drivers */
154 int test_ping(struct udevice *dev, int pingval, int *pingret);
155 int testfdt_ping(struct udevice *dev, int pingval, int *pingret);
158 * dm_check_operations() - Check that we can perform ping operations
160 * This checks that the ping operations work as expected for a device
162 * @dms: Overall test state
163 * @dev: Device to test
164 * @base: Base address, used to check ping return value
165 * @priv: Pointer to private test information
166 * @return 0 if OK, -ve on error
168 int dm_check_operations(struct dm_test_state *dms, struct udevice *dev,
169 uint32_t base, struct dm_test_priv *priv);
172 * dm_check_devices() - check the devices respond to operations correctly
174 * @dms: Overall test state
175 * @num_devices: Number of test devices to check
176 * @return 0 if OK, -ve on error
178 int dm_check_devices(struct dm_test_state *dms, int num_devices);
181 * dm_test_main() - Run all the tests
183 * This runs all available driver model tests
185 * @return 0 if OK, -ve on error
187 int dm_test_main(void);