X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fsysreset%2Fsysreset_sandbox.c;h=38e2a7e241ddd6679cb54fabfd850fa4a9149d36;hb=7225a27ffae5d1119eb25b6b9c9e091a852e6b13;hp=0c4e2e1a93a696903cee0c8fb8f6e7e303854155;hpb=576a085c1d224b8a5a3ccf5c4114d07a1f695f20;p=oweals%2Fu-boot.git diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c index 0c4e2e1a93..38e2a7e241 100644 --- a/drivers/sysreset/sysreset_sandbox.c +++ b/drivers/sysreset/sysreset_sandbox.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2015 Google, Inc * Written by Simon Glass - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -12,8 +11,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - static int sandbox_warm_sysreset_request(struct udevice *dev, enum sysreset_t type) { @@ -32,6 +29,18 @@ static int sandbox_warm_sysreset_request(struct udevice *dev, return -EINPROGRESS; } +int sandbox_warm_sysreset_get_status(struct udevice *dev, char *buf, int size) +{ + strlcpy(buf, "Reset Status: WARM", size); + + return 0; +} + +int sandbox_warm_sysreset_get_last(struct udevice *dev) +{ + return SYSRESET_WARM; +} + static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) { struct sandbox_state *state = state_get_current(); @@ -41,7 +50,7 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) * (see the U_BOOT_DEVICE() declaration below) should not do anything. * If we are that device, return an error. */ - if (state->fdt_fname && dev_of_offset(dev) == -1) + if (state->fdt_fname && !dev_of_valid(dev)) return -ENODEV; switch (type) { @@ -54,6 +63,9 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) return -EACCES; sandbox_exit(); break; + case SYSRESET_POWER_OFF: + if (!state->sysreset_allowed[type]) + return -EACCES; default: return -ENOSYS; } @@ -63,8 +75,28 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) return -EINPROGRESS; } +int sandbox_sysreset_get_status(struct udevice *dev, char *buf, int size) +{ + strlcpy(buf, "Reset Status: COLD", size); + + return 0; +} + +int sandbox_sysreset_get_last(struct udevice *dev) +{ + struct sandbox_state *state = state_get_current(); + + /* + * The first phase is a power reset, after that we assume we don't + * know. + */ + return state->jumped_fname ? SYSRESET_WARM : SYSRESET_POWER; +} + static struct sysreset_ops sandbox_sysreset_ops = { .request = sandbox_sysreset_request, + .get_status = sandbox_sysreset_get_status, + .get_last = sandbox_sysreset_get_last, }; static const struct udevice_id sandbox_sysreset_ids[] = { @@ -81,6 +113,8 @@ U_BOOT_DRIVER(sysreset_sandbox) = { static struct sysreset_ops sandbox_warm_sysreset_ops = { .request = sandbox_warm_sysreset_request, + .get_status = sandbox_warm_sysreset_get_status, + .get_last = sandbox_warm_sysreset_get_last, }; static const struct udevice_id sandbox_warm_sysreset_ids[] = {