Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | 4581b71 | 2016-06-17 09:43:59 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016, NVIDIA CORPORATION. |
Stephen Warren | 4581b71 | 2016-06-17 09:43:59 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Simon Glass | 336d461 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 9 | #include <malloc.h> |
Stephen Warren | 4581b71 | 2016-06-17 09:43:59 -0600 | [diff] [blame] | 10 | #include <reset.h> |
| 11 | #include <asm/io.h> |
| 12 | #include <asm/reset.h> |
| 13 | |
| 14 | struct sandbox_reset_test { |
| 15 | struct reset_ctl ctl; |
Neil Armstrong | 91f5f8b | 2018-04-03 11:40:51 +0200 | [diff] [blame] | 16 | struct reset_ctl_bulk bulk; |
Stephen Warren | 4581b71 | 2016-06-17 09:43:59 -0600 | [diff] [blame] | 17 | }; |
| 18 | |
| 19 | int sandbox_reset_test_get(struct udevice *dev) |
| 20 | { |
| 21 | struct sandbox_reset_test *sbrt = dev_get_priv(dev); |
| 22 | |
| 23 | return reset_get_by_name(dev, "test", &sbrt->ctl); |
| 24 | } |
| 25 | |
Neil Armstrong | 91f5f8b | 2018-04-03 11:40:51 +0200 | [diff] [blame] | 26 | int sandbox_reset_test_get_bulk(struct udevice *dev) |
| 27 | { |
| 28 | struct sandbox_reset_test *sbrt = dev_get_priv(dev); |
| 29 | |
| 30 | return reset_get_bulk(dev, &sbrt->bulk); |
| 31 | } |
| 32 | |
Stephen Warren | 4581b71 | 2016-06-17 09:43:59 -0600 | [diff] [blame] | 33 | int sandbox_reset_test_assert(struct udevice *dev) |
| 34 | { |
| 35 | struct sandbox_reset_test *sbrt = dev_get_priv(dev); |
| 36 | |
| 37 | return reset_assert(&sbrt->ctl); |
| 38 | } |
| 39 | |
Neil Armstrong | 91f5f8b | 2018-04-03 11:40:51 +0200 | [diff] [blame] | 40 | int sandbox_reset_test_assert_bulk(struct udevice *dev) |
| 41 | { |
| 42 | struct sandbox_reset_test *sbrt = dev_get_priv(dev); |
| 43 | |
| 44 | return reset_assert_bulk(&sbrt->bulk); |
| 45 | } |
| 46 | |
Stephen Warren | 4581b71 | 2016-06-17 09:43:59 -0600 | [diff] [blame] | 47 | int sandbox_reset_test_deassert(struct udevice *dev) |
| 48 | { |
| 49 | struct sandbox_reset_test *sbrt = dev_get_priv(dev); |
| 50 | |
| 51 | return reset_deassert(&sbrt->ctl); |
| 52 | } |
| 53 | |
Neil Armstrong | 91f5f8b | 2018-04-03 11:40:51 +0200 | [diff] [blame] | 54 | int sandbox_reset_test_deassert_bulk(struct udevice *dev) |
| 55 | { |
| 56 | struct sandbox_reset_test *sbrt = dev_get_priv(dev); |
| 57 | |
| 58 | return reset_deassert_bulk(&sbrt->bulk); |
| 59 | } |
| 60 | |
Stephen Warren | 4581b71 | 2016-06-17 09:43:59 -0600 | [diff] [blame] | 61 | int sandbox_reset_test_free(struct udevice *dev) |
| 62 | { |
| 63 | struct sandbox_reset_test *sbrt = dev_get_priv(dev); |
| 64 | |
| 65 | return reset_free(&sbrt->ctl); |
| 66 | } |
| 67 | |
Neil Armstrong | 91f5f8b | 2018-04-03 11:40:51 +0200 | [diff] [blame] | 68 | int sandbox_reset_test_release_bulk(struct udevice *dev) |
| 69 | { |
| 70 | struct sandbox_reset_test *sbrt = dev_get_priv(dev); |
| 71 | |
| 72 | return reset_release_bulk(&sbrt->bulk); |
| 73 | } |
| 74 | |
Stephen Warren | 4581b71 | 2016-06-17 09:43:59 -0600 | [diff] [blame] | 75 | static const struct udevice_id sandbox_reset_test_ids[] = { |
| 76 | { .compatible = "sandbox,reset-ctl-test" }, |
| 77 | { } |
| 78 | }; |
| 79 | |
| 80 | U_BOOT_DRIVER(sandbox_reset_test) = { |
| 81 | .name = "sandbox_reset_test", |
| 82 | .id = UCLASS_MISC, |
| 83 | .of_match = sandbox_reset_test_ids, |
| 84 | .priv_auto_alloc_size = sizeof(struct sandbox_reset_test), |
| 85 | }; |