Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Google, Inc |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 9 | #include <mapmem.h> |
| 10 | #include <regmap.h> |
| 11 | #include <syscon.h> |
Jean-Jacques Hiblot | 0b89fc5 | 2020-09-24 10:04:18 +0530 | [diff] [blame] | 12 | #include <rand.h> |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 13 | #include <asm/test.h> |
| 14 | #include <dm/test.h> |
Jean-Jacques Hiblot | 0b89fc5 | 2020-09-24 10:04:18 +0530 | [diff] [blame] | 15 | #include <dm/devres.h> |
Simon Glass | d66c5f7 | 2020-02-03 07:36:15 -0700 | [diff] [blame] | 16 | #include <linux/err.h> |
Simon Glass | 75c4d41 | 2020-07-19 10:15:37 -0600 | [diff] [blame] | 17 | #include <test/test.h> |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 18 | #include <test/ut.h> |
| 19 | |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 20 | /* Base test of register maps */ |
| 21 | static int dm_test_regmap_base(struct unit_test_state *uts) |
| 22 | { |
| 23 | struct udevice *dev; |
| 24 | struct regmap *map; |
Masahiro Yamada | 42ab107 | 2018-04-23 13:26:53 +0900 | [diff] [blame] | 25 | ofnode node; |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 26 | int i; |
| 27 | |
| 28 | ut_assertok(uclass_get_device(UCLASS_SYSCON, 0, &dev)); |
| 29 | map = syscon_get_regmap(dev); |
| 30 | ut_assertok_ptr(map); |
| 31 | ut_asserteq(1, map->range_count); |
Masahiro Yamada | 54c5ecb | 2018-04-19 12:14:01 +0900 | [diff] [blame] | 32 | ut_asserteq(0x10, map->ranges[0].start); |
Mario Six | e3f59f4 | 2018-10-04 09:00:40 +0200 | [diff] [blame] | 33 | ut_asserteq(16, map->ranges[0].size); |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 34 | ut_asserteq(0x10, map_to_sysmem(regmap_get_range(map, 0))); |
| 35 | |
| 36 | ut_assertok(uclass_get_device(UCLASS_SYSCON, 1, &dev)); |
| 37 | map = syscon_get_regmap(dev); |
| 38 | ut_assertok_ptr(map); |
| 39 | ut_asserteq(4, map->range_count); |
Masahiro Yamada | 54c5ecb | 2018-04-19 12:14:01 +0900 | [diff] [blame] | 40 | ut_asserteq(0x20, map->ranges[0].start); |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 41 | for (i = 0; i < 4; i++) { |
| 42 | const unsigned long addr = 0x20 + 8 * i; |
| 43 | |
Masahiro Yamada | 54c5ecb | 2018-04-19 12:14:01 +0900 | [diff] [blame] | 44 | ut_asserteq(addr, map->ranges[i].start); |
| 45 | ut_asserteq(5 + i, map->ranges[i].size); |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 46 | ut_asserteq(addr, map_to_sysmem(regmap_get_range(map, i))); |
| 47 | } |
| 48 | |
| 49 | /* Check that we can't pretend a different device is a syscon */ |
| 50 | ut_assertok(uclass_get_device(UCLASS_I2C, 0, &dev)); |
| 51 | map = syscon_get_regmap(dev); |
| 52 | ut_asserteq_ptr(ERR_PTR(-ENOEXEC), map); |
| 53 | |
Masahiro Yamada | 42ab107 | 2018-04-23 13:26:53 +0900 | [diff] [blame] | 54 | /* A different device can be a syscon by using Linux-compat API */ |
| 55 | node = ofnode_path("/syscon@2"); |
| 56 | ut_assert(ofnode_valid(node)); |
| 57 | |
| 58 | map = syscon_node_to_regmap(node); |
| 59 | ut_assertok_ptr(map); |
| 60 | ut_asserteq(4, map->range_count); |
| 61 | ut_asserteq(0x40, map->ranges[0].start); |
| 62 | for (i = 0; i < 4; i++) { |
| 63 | const unsigned long addr = 0x40 + 8 * i; |
| 64 | |
| 65 | ut_asserteq(addr, map->ranges[i].start); |
| 66 | ut_asserteq(5 + i, map->ranges[i].size); |
| 67 | ut_asserteq(addr, map_to_sysmem(regmap_get_range(map, i))); |
| 68 | } |
| 69 | |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 70 | return 0; |
| 71 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 72 | DM_TEST(dm_test_regmap_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Simon Glass | 265142a | 2015-07-06 12:54:39 -0600 | [diff] [blame] | 73 | |
| 74 | /* Test we can access a regmap through syscon */ |
| 75 | static int dm_test_regmap_syscon(struct unit_test_state *uts) |
| 76 | { |
| 77 | struct regmap *map; |
| 78 | |
| 79 | map = syscon_get_regmap_by_driver_data(SYSCON0); |
| 80 | ut_assertok_ptr(map); |
| 81 | ut_asserteq(1, map->range_count); |
| 82 | |
| 83 | map = syscon_get_regmap_by_driver_data(SYSCON1); |
| 84 | ut_assertok_ptr(map); |
| 85 | ut_asserteq(4, map->range_count); |
| 86 | |
| 87 | map = syscon_get_regmap_by_driver_data(SYSCON_COUNT); |
| 88 | ut_asserteq_ptr(ERR_PTR(-ENODEV), map); |
| 89 | |
| 90 | ut_asserteq(0x10, map_to_sysmem(syscon_get_first_range(SYSCON0))); |
| 91 | ut_asserteq(0x20, map_to_sysmem(syscon_get_first_range(SYSCON1))); |
| 92 | ut_asserteq_ptr(ERR_PTR(-ENODEV), |
| 93 | syscon_get_first_range(SYSCON_COUNT)); |
| 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 98 | DM_TEST(dm_test_regmap_syscon, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Neil Armstrong | 7a59d1d | 2018-04-27 11:56:15 +0200 | [diff] [blame] | 99 | |
| 100 | /* Read/Write/Modify test */ |
| 101 | static int dm_test_regmap_rw(struct unit_test_state *uts) |
| 102 | { |
| 103 | struct udevice *dev; |
| 104 | struct regmap *map; |
| 105 | uint reg; |
| 106 | |
Jean-Jacques Hiblot | e7e7953 | 2019-10-11 16:16:50 -0600 | [diff] [blame] | 107 | sandbox_set_enable_memio(true); |
Neil Armstrong | 7a59d1d | 2018-04-27 11:56:15 +0200 | [diff] [blame] | 108 | ut_assertok(uclass_get_device(UCLASS_SYSCON, 0, &dev)); |
| 109 | map = syscon_get_regmap(dev); |
| 110 | ut_assertok_ptr(map); |
| 111 | |
| 112 | ut_assertok(regmap_write(map, 0, 0xcacafafa)); |
Jean-Jacques Hiblot | e7e7953 | 2019-10-11 16:16:50 -0600 | [diff] [blame] | 113 | ut_assertok(regmap_write(map, 5, 0x55aa2211)); |
Neil Armstrong | 7a59d1d | 2018-04-27 11:56:15 +0200 | [diff] [blame] | 114 | |
| 115 | ut_assertok(regmap_read(map, 0, ®)); |
Jean-Jacques Hiblot | e7e7953 | 2019-10-11 16:16:50 -0600 | [diff] [blame] | 116 | ut_asserteq(0xcacafafa, reg); |
| 117 | ut_assertok(regmap_read(map, 5, ®)); |
| 118 | ut_asserteq(0x55aa2211, reg); |
Neil Armstrong | 7a59d1d | 2018-04-27 11:56:15 +0200 | [diff] [blame] | 119 | |
Jean-Jacques Hiblot | e7e7953 | 2019-10-11 16:16:50 -0600 | [diff] [blame] | 120 | ut_assertok(regmap_read(map, 0, ®)); |
| 121 | ut_asserteq(0xcacafafa, reg); |
Neil Armstrong | 7a59d1d | 2018-04-27 11:56:15 +0200 | [diff] [blame] | 122 | ut_assertok(regmap_update_bits(map, 0, 0xff00ff00, 0x55aa2211)); |
Jean-Jacques Hiblot | e7e7953 | 2019-10-11 16:16:50 -0600 | [diff] [blame] | 123 | ut_assertok(regmap_read(map, 0, ®)); |
| 124 | ut_asserteq(0x55ca22fa, reg); |
| 125 | ut_assertok(regmap_update_bits(map, 5, 0x00ff00ff, 0xcacafada)); |
| 126 | ut_assertok(regmap_read(map, 5, ®)); |
| 127 | ut_asserteq(0x55ca22da, reg); |
Neil Armstrong | 7a59d1d | 2018-04-27 11:56:15 +0200 | [diff] [blame] | 128 | |
| 129 | return 0; |
| 130 | } |
| 131 | |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 132 | DM_TEST(dm_test_regmap_rw, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Mario Six | 460212e | 2018-10-15 09:24:13 +0200 | [diff] [blame] | 133 | |
| 134 | /* Get/Set test */ |
| 135 | static int dm_test_regmap_getset(struct unit_test_state *uts) |
| 136 | { |
| 137 | struct udevice *dev; |
| 138 | struct regmap *map; |
| 139 | uint reg; |
| 140 | struct layout { |
| 141 | u32 val0; |
| 142 | u32 val1; |
| 143 | u32 val2; |
| 144 | u32 val3; |
| 145 | }; |
| 146 | |
Jean-Jacques Hiblot | e7e7953 | 2019-10-11 16:16:50 -0600 | [diff] [blame] | 147 | sandbox_set_enable_memio(true); |
Mario Six | 460212e | 2018-10-15 09:24:13 +0200 | [diff] [blame] | 148 | ut_assertok(uclass_get_device(UCLASS_SYSCON, 0, &dev)); |
| 149 | map = syscon_get_regmap(dev); |
| 150 | ut_assertok_ptr(map); |
| 151 | |
| 152 | regmap_set(map, struct layout, val0, 0xcacafafa); |
| 153 | regmap_set(map, struct layout, val3, 0x55aa2211); |
| 154 | |
| 155 | ut_assertok(regmap_get(map, struct layout, val0, ®)); |
Jean-Jacques Hiblot | e7e7953 | 2019-10-11 16:16:50 -0600 | [diff] [blame] | 156 | ut_asserteq(0xcacafafa, reg); |
Mario Six | 460212e | 2018-10-15 09:24:13 +0200 | [diff] [blame] | 157 | ut_assertok(regmap_get(map, struct layout, val3, ®)); |
Jean-Jacques Hiblot | e7e7953 | 2019-10-11 16:16:50 -0600 | [diff] [blame] | 158 | ut_asserteq(0x55aa2211, reg); |
Mario Six | 460212e | 2018-10-15 09:24:13 +0200 | [diff] [blame] | 159 | |
| 160 | return 0; |
| 161 | } |
| 162 | |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 163 | DM_TEST(dm_test_regmap_getset, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Neil Armstrong | f9735be | 2018-11-22 11:01:04 +0100 | [diff] [blame] | 164 | |
| 165 | /* Read polling test */ |
| 166 | static int dm_test_regmap_poll(struct unit_test_state *uts) |
| 167 | { |
| 168 | struct udevice *dev; |
| 169 | struct regmap *map; |
| 170 | uint reg; |
| 171 | unsigned long start; |
| 172 | |
| 173 | ut_assertok(uclass_get_device(UCLASS_SYSCON, 0, &dev)); |
| 174 | map = syscon_get_regmap(dev); |
| 175 | ut_assertok_ptr(map); |
| 176 | |
| 177 | start = get_timer(0); |
| 178 | |
Jean-Jacques Hiblot | e7e7953 | 2019-10-11 16:16:50 -0600 | [diff] [blame] | 179 | ut_assertok(regmap_write(map, 0, 0x0)); |
Neil Armstrong | f9735be | 2018-11-22 11:01:04 +0100 | [diff] [blame] | 180 | ut_asserteq(-ETIMEDOUT, |
Simon Glass | c2a7c49 | 2018-12-09 17:11:10 -0700 | [diff] [blame] | 181 | regmap_read_poll_timeout_test(map, 0, reg, |
| 182 | (reg == 0xcacafafa), |
| 183 | 1, 5 * CONFIG_SYS_HZ, |
| 184 | 5 * CONFIG_SYS_HZ)); |
Neil Armstrong | f9735be | 2018-11-22 11:01:04 +0100 | [diff] [blame] | 185 | |
| 186 | ut_assert(get_timer(start) > (5 * CONFIG_SYS_HZ)); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 191 | DM_TEST(dm_test_regmap_poll, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
Jean-Jacques Hiblot | 0b89fc5 | 2020-09-24 10:04:18 +0530 | [diff] [blame] | 192 | |
| 193 | struct regmaptest_priv { |
| 194 | struct regmap *cfg_regmap; /* For testing regmap_config options. */ |
| 195 | struct regmap *fld_regmap; /* For testing regmap fields. */ |
| 196 | struct regmap_field **fields; |
| 197 | }; |
| 198 | |
| 199 | static const struct reg_field field_cfgs[] = { |
| 200 | { |
| 201 | .reg = 0, |
| 202 | .lsb = 0, |
| 203 | .msb = 6, |
| 204 | }, |
| 205 | { |
| 206 | .reg = 2, |
| 207 | .lsb = 4, |
| 208 | .msb = 12, |
| 209 | }, |
| 210 | { |
| 211 | .reg = 2, |
| 212 | .lsb = 12, |
| 213 | .msb = 15, |
| 214 | } |
| 215 | }; |
| 216 | |
| 217 | #define REGMAP_TEST_BUF_START 0 |
| 218 | #define REGMAP_TEST_BUF_SZ 5 |
| 219 | |
| 220 | static int remaptest_probe(struct udevice *dev) |
| 221 | { |
| 222 | struct regmaptest_priv *priv = dev_get_priv(dev); |
| 223 | struct regmap *regmap; |
| 224 | struct regmap_field *field; |
| 225 | struct regmap_config cfg; |
| 226 | int i; |
| 227 | static const int n = ARRAY_SIZE(field_cfgs); |
| 228 | |
| 229 | /* |
| 230 | * To exercise all the regmap config options, create a regmap that |
| 231 | * points to a custom memory area instead of the one defined in device |
| 232 | * tree. Use 2-byte elements. To allow directly indexing into the |
| 233 | * elements, use an offset shift of 1. So, accessing offset 1 gets the |
| 234 | * element at index 1 at memory location 2. |
| 235 | * |
| 236 | * REGMAP_TEST_BUF_SZ is the number of elements, so we need to multiply |
| 237 | * it by 2 because r_size expects number of bytes. |
| 238 | */ |
| 239 | cfg.reg_offset_shift = 1; |
| 240 | cfg.r_start = REGMAP_TEST_BUF_START; |
| 241 | cfg.r_size = REGMAP_TEST_BUF_SZ * 2; |
| 242 | cfg.width = REGMAP_SIZE_16; |
| 243 | |
| 244 | regmap = devm_regmap_init(dev, NULL, NULL, &cfg); |
| 245 | if (IS_ERR(regmap)) |
| 246 | return PTR_ERR(regmap); |
| 247 | priv->cfg_regmap = regmap; |
| 248 | |
| 249 | memset(&cfg, 0, sizeof(struct regmap_config)); |
| 250 | cfg.width = REGMAP_SIZE_16; |
| 251 | |
| 252 | regmap = devm_regmap_init(dev, NULL, NULL, &cfg); |
| 253 | if (IS_ERR(regmap)) |
| 254 | return PTR_ERR(regmap); |
| 255 | priv->fld_regmap = regmap; |
| 256 | |
| 257 | priv->fields = devm_kzalloc(dev, sizeof(struct regmap_field *) * n, |
| 258 | GFP_KERNEL); |
| 259 | if (!priv->fields) |
| 260 | return -ENOMEM; |
| 261 | |
| 262 | for (i = 0 ; i < n; i++) { |
| 263 | field = devm_regmap_field_alloc(dev, priv->fld_regmap, |
| 264 | field_cfgs[i]); |
| 265 | if (IS_ERR(field)) |
| 266 | return PTR_ERR(field); |
| 267 | priv->fields[i] = field; |
| 268 | } |
| 269 | |
| 270 | return 0; |
| 271 | } |
| 272 | |
| 273 | static const struct udevice_id regmaptest_ids[] = { |
| 274 | { .compatible = "sandbox,regmap_test" }, |
| 275 | { } |
| 276 | }; |
| 277 | |
| 278 | U_BOOT_DRIVER(regmap_test) = { |
| 279 | .name = "regmaptest_drv", |
| 280 | .of_match = regmaptest_ids, |
| 281 | .id = UCLASS_NOP, |
| 282 | .probe = remaptest_probe, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 283 | .priv_auto = sizeof(struct regmaptest_priv), |
Jean-Jacques Hiblot | 0b89fc5 | 2020-09-24 10:04:18 +0530 | [diff] [blame] | 284 | }; |
| 285 | |
| 286 | static int dm_test_devm_regmap(struct unit_test_state *uts) |
| 287 | { |
| 288 | int i = 0; |
Heinrich Schuchardt | 0922673 | 2021-04-11 11:21:56 +0200 | [diff] [blame] | 289 | u16 val; |
| 290 | void *valp = &val; |
Jean-Jacques Hiblot | 0b89fc5 | 2020-09-24 10:04:18 +0530 | [diff] [blame] | 291 | u16 pattern[REGMAP_TEST_BUF_SZ]; |
| 292 | u16 *buffer; |
| 293 | struct udevice *dev; |
| 294 | struct regmaptest_priv *priv; |
| 295 | |
| 296 | sandbox_set_enable_memio(true); |
| 297 | |
| 298 | /* |
| 299 | * Map the memory area the regmap should point to so we can make sure |
| 300 | * the writes actually go to that location. |
| 301 | */ |
| 302 | buffer = map_physmem(REGMAP_TEST_BUF_START, |
| 303 | REGMAP_TEST_BUF_SZ * 2, MAP_NOCACHE); |
| 304 | |
| 305 | ut_assertok(uclass_get_device_by_name(UCLASS_NOP, "regmap-test_0", |
| 306 | &dev)); |
| 307 | priv = dev_get_priv(dev); |
| 308 | |
| 309 | srand(get_ticks() + rand()); |
| 310 | for (i = 0; i < REGMAP_TEST_BUF_SZ; i++) { |
| 311 | pattern[i] = rand(); |
| 312 | ut_assertok(regmap_write(priv->cfg_regmap, i, pattern[i])); |
| 313 | } |
| 314 | for (i = 0; i < REGMAP_TEST_BUF_SZ; i++) { |
Heinrich Schuchardt | 0922673 | 2021-04-11 11:21:56 +0200 | [diff] [blame] | 315 | ut_assertok(regmap_read(priv->cfg_regmap, i, valp)); |
Jean-Jacques Hiblot | 0b89fc5 | 2020-09-24 10:04:18 +0530 | [diff] [blame] | 316 | ut_asserteq(val, buffer[i]); |
| 317 | ut_asserteq(val, pattern[i]); |
| 318 | } |
| 319 | |
| 320 | ut_asserteq(-ERANGE, regmap_write(priv->cfg_regmap, REGMAP_TEST_BUF_SZ, |
| 321 | val)); |
| 322 | ut_asserteq(-ERANGE, regmap_read(priv->cfg_regmap, REGMAP_TEST_BUF_SZ, |
Heinrich Schuchardt | 0922673 | 2021-04-11 11:21:56 +0200 | [diff] [blame] | 323 | valp)); |
Jean-Jacques Hiblot | 0b89fc5 | 2020-09-24 10:04:18 +0530 | [diff] [blame] | 324 | ut_asserteq(-ERANGE, regmap_write(priv->cfg_regmap, -1, val)); |
Heinrich Schuchardt | 0922673 | 2021-04-11 11:21:56 +0200 | [diff] [blame] | 325 | ut_asserteq(-ERANGE, regmap_read(priv->cfg_regmap, -1, valp)); |
Jean-Jacques Hiblot | 0b89fc5 | 2020-09-24 10:04:18 +0530 | [diff] [blame] | 326 | |
| 327 | return 0; |
| 328 | } |
| 329 | DM_TEST(dm_test_devm_regmap, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |
| 330 | |
| 331 | static int test_one_field(struct unit_test_state *uts, |
| 332 | struct regmap *regmap, |
| 333 | struct regmap_field *field, |
| 334 | struct reg_field field_cfg) |
| 335 | { |
| 336 | int j; |
| 337 | unsigned int val; |
| 338 | int mask = (1 << (field_cfg.msb - field_cfg.lsb + 1)) - 1; |
| 339 | int shift = field_cfg.lsb; |
| 340 | |
| 341 | ut_assertok(regmap_write(regmap, field_cfg.reg, 0)); |
| 342 | ut_assertok(regmap_read(regmap, field_cfg.reg, &val)); |
| 343 | ut_asserteq(0, val); |
| 344 | |
| 345 | for (j = 0; j <= mask; j++) { |
| 346 | ut_assertok(regmap_field_write(field, j)); |
| 347 | ut_assertok(regmap_field_read(field, &val)); |
| 348 | ut_asserteq(j, val); |
| 349 | ut_assertok(regmap_read(regmap, field_cfg.reg, &val)); |
| 350 | ut_asserteq(j << shift, val); |
| 351 | } |
| 352 | |
| 353 | ut_assertok(regmap_field_write(field, mask + 1)); |
| 354 | ut_assertok(regmap_read(regmap, field_cfg.reg, &val)); |
| 355 | ut_asserteq(0, val); |
| 356 | |
| 357 | ut_assertok(regmap_field_write(field, 0xFFFF)); |
| 358 | ut_assertok(regmap_read(regmap, field_cfg.reg, &val)); |
| 359 | ut_asserteq(mask << shift, val); |
| 360 | |
| 361 | ut_assertok(regmap_write(regmap, field_cfg.reg, 0xFFFF)); |
| 362 | ut_assertok(regmap_field_write(field, 0)); |
| 363 | ut_assertok(regmap_read(regmap, field_cfg.reg, &val)); |
| 364 | ut_asserteq(0xFFFF & ~(mask << shift), val); |
| 365 | return 0; |
| 366 | } |
| 367 | |
| 368 | static int dm_test_devm_regmap_field(struct unit_test_state *uts) |
| 369 | { |
| 370 | int i, rc; |
| 371 | struct udevice *dev; |
| 372 | struct regmaptest_priv *priv; |
| 373 | |
| 374 | ut_assertok(uclass_get_device_by_name(UCLASS_NOP, "regmap-test_0", |
| 375 | &dev)); |
| 376 | priv = dev_get_priv(dev); |
| 377 | |
| 378 | sandbox_set_enable_memio(true); |
| 379 | for (i = 0 ; i < ARRAY_SIZE(field_cfgs); i++) { |
| 380 | rc = test_one_field(uts, priv->fld_regmap, priv->fields[i], |
| 381 | field_cfgs[i]); |
| 382 | if (rc) |
| 383 | break; |
| 384 | } |
| 385 | |
| 386 | return 0; |
| 387 | } |
| 388 | DM_TEST(dm_test_devm_regmap_field, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |