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 * Operation counts for the test driver, used to check that each method is
89 extern int dm_testdrv_op_count[DM_TEST_OP_COUNT];
91 extern struct dm_test_state global_test_state;
94 * struct dm_test_state - Entire state of dm test system
96 * This is often abreviated to dms.
99 * @testdev: Test device
100 * @fail_count: Number of tests that failed
101 * @force_fail_alloc: Force all memory allocs to fail
102 * @skip_post_probe: Skip uclass post-probe processing
104 struct dm_test_state {
105 struct udevice *root;
106 struct udevice *testdev;
108 int force_fail_alloc;
112 /* Test flags for each test */
114 DM_TESTF_SCAN_PDATA = 1 << 0, /* test needs platform data */
115 DM_TESTF_PROBE_TEST = 1 << 1, /* probe test uclass */
116 DM_TESTF_SCAN_FDT = 1 << 2, /* scan device tree */
120 * struct dm_test - Information about a driver model test
122 * @name: Name of test
123 * @func: Function to call to perform test
124 * @flags: Flags indicated pre-conditions for test
128 int (*func)(struct dm_test_state *dms);
132 /* Declare a new driver model test */
133 #define DM_TEST(_name, _flags) \
134 ll_entry_declare(struct dm_test, _name, dm_test) = { \
140 /* Declare ping methods for the drivers */
141 int test_ping(struct udevice *dev, int pingval, int *pingret);
142 int testfdt_ping(struct udevice *dev, int pingval, int *pingret);
145 * dm_check_operations() - Check that we can perform ping operations
147 * This checks that the ping operations work as expected for a device
149 * @dms: Overall test state
150 * @dev: Device to test
151 * @base: Base address, used to check ping return value
152 * @priv: Pointer to private test information
153 * @return 0 if OK, -ve on error
155 int dm_check_operations(struct dm_test_state *dms, struct udevice *dev,
156 uint32_t base, struct dm_test_priv *priv);
159 * dm_test_main() - Run all the tests
161 * This runs all available driver model tests
163 * @return 0 if OK, -ve on error
165 int dm_test_main(void);