diff options
author | Anup Patel <anup.patel@wdc.com> | 2021-04-22 09:23:32 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-04-28 14:55:00 +0300 |
commit | 043d088e3964ec64b091f739e2282f53f7d264fb (patch) | |
tree | e5ec82451c097df3f3416ec077752527d81107a7 /lib/utils/reset | |
parent | dc39c7b630a607b96c25f8ea50f0bb1af619928a (diff) | |
download | opensbi-043d088e3964ec64b091f739e2282f53f7d264fb.tar.xz |
lib: sbi: Simplify system reset platform operations
Instead of having system_reset_check() and system_reset() callbacks
in platform operations, it will be much simpler for reset driver to
directly register these operations as a device to the sbi_system
implementation.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'lib/utils/reset')
-rw-r--r-- | lib/utils/reset/fdt_reset.c | 14 | ||||
-rw-r--r-- | lib/utils/reset/fdt_reset_htif.c | 9 | ||||
-rw-r--r-- | lib/utils/reset/fdt_reset_sifive.c | 2 | ||||
-rw-r--r-- | lib/utils/reset/fdt_reset_thead.c | 34 |
4 files changed, 28 insertions, 31 deletions
diff --git a/lib/utils/reset/fdt_reset.c b/lib/utils/reset/fdt_reset.c index 82532c2..b01b0d1 100644 --- a/lib/utils/reset/fdt_reset.c +++ b/lib/utils/reset/fdt_reset.c @@ -23,20 +23,6 @@ static struct fdt_reset *reset_drivers[] = { static struct fdt_reset *current_driver = NULL; -int fdt_system_reset_check(u32 reset_type, u32 reset_reason) -{ - if (current_driver && current_driver->system_reset_check) - return current_driver->system_reset_check(reset_type, - reset_reason); - return 0; -} - -void fdt_system_reset(u32 reset_type, u32 reset_reason) -{ - if (current_driver && current_driver->system_reset) - current_driver->system_reset(reset_type, reset_reason); -} - int fdt_reset_init(void) { int pos, noff, rc; diff --git a/lib/utils/reset/fdt_reset_htif.c b/lib/utils/reset/fdt_reset_htif.c index 587e7d6..dd08660 100644 --- a/lib/utils/reset/fdt_reset_htif.c +++ b/lib/utils/reset/fdt_reset_htif.c @@ -11,6 +11,12 @@ #include <sbi_utils/fdt/fdt_helper.h> #include <sbi_utils/sys/htif.h> +static int htif_reset_init(void *fdt, int nodeoff, + const struct fdt_match *match) +{ + return htif_system_reset_init(); +} + static const struct fdt_match htif_reset_match[] = { { .compatible = "ucb,htif0" }, { }, @@ -18,6 +24,5 @@ static const struct fdt_match htif_reset_match[] = { struct fdt_reset fdt_reset_htif = { .match_table = htif_reset_match, - .system_reset_check = htif_system_reset_check, - .system_reset = htif_system_reset + .init = htif_reset_init }; diff --git a/lib/utils/reset/fdt_reset_sifive.c b/lib/utils/reset/fdt_reset_sifive.c index 38b520c..928dee9 100644 --- a/lib/utils/reset/fdt_reset_sifive.c +++ b/lib/utils/reset/fdt_reset_sifive.c @@ -33,6 +33,4 @@ static const struct fdt_match sifive_test_reset_match[] = { struct fdt_reset fdt_reset_sifive = { .match_table = sifive_test_reset_match, .init = sifive_test_reset_init, - .system_reset_check = sifive_test_system_reset_check, - .system_reset = sifive_test_system_reset }; diff --git a/lib/utils/reset/fdt_reset_thead.c b/lib/utils/reset/fdt_reset_thead.c index ea81fc9..95f8c36 100644 --- a/lib/utils/reset/fdt_reset_thead.c +++ b/lib/utils/reset/fdt_reset_thead.c @@ -7,8 +7,10 @@ #include <sbi/sbi_bitops.h> #include <sbi/sbi_hart.h> #include <sbi/sbi_scratch.h> +#include <sbi/sbi_system.h> #include <sbi_utils/fdt/fdt_helper.h> #include <sbi_utils/reset/fdt_reset.h> + #include "fdt_reset_thead.h" struct custom_csr custom_csr[MAX_CUSTOM_CSR]; @@ -37,6 +39,22 @@ static void clone_csrs(int cnt) } } +static int thead_system_reset_check(u32 type, u32 reason) +{ + return 1; +} + +static void thead_system_reset(u32 type, u32 reason) +{ + ebreak(); +} + +static struct sbi_system_reset_device thead_reset = { + .name = "thead_reset", + .system_reset_check = thead_system_reset_check, + .system_reset = thead_system_reset +}; + extern void __thead_pre_start_warm(void); static int thead_reset_init(void *fdt, int nodeoff, const struct fdt_match *match) @@ -106,17 +124,9 @@ static int thead_reset_init(void *fdt, int nodeoff, } } - return 0; -} - -int thead_system_reset_check(u32 type, u32 reason) -{ - return 1; -} + sbi_system_reset_set_device(&thead_reset); -void thead_system_reset(u32 type, u32 reason) -{ - ebreak(); + return 0; } static const struct fdt_match thead_reset_match[] = { @@ -126,7 +136,5 @@ static const struct fdt_match thead_reset_match[] = { struct fdt_reset fdt_reset_thead = { .match_table = thead_reset_match, - .init = thead_reset_init, - .system_reset_check = thead_system_reset_check, - .system_reset = thead_system_reset + .init = thead_reset_init }; |