diff options
Diffstat (limited to 'board/cr50/wp.c')
-rw-r--r-- | board/cr50/wp.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/board/cr50/wp.c b/board/cr50/wp.c new file mode 100644 index 0000000000..e32ce2189a --- /dev/null +++ b/board/cr50/wp.c @@ -0,0 +1,32 @@ +/* Copyright 2016 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "console.h" +#include "registers.h" + +static int command_wp(int argc, char **argv) +{ + int val; + + if (argc > 1) { + if (!parse_bool(argv[1], &val)) + return EC_ERROR_PARAM1; + + /* Invert, because active low */ + GREG32(RBOX, EC_WP_L) = !val; + } + + /* Invert, because active low */ + val = !GREG32(RBOX, EC_WP_L); + + ccprintf("Flash WP is %s\n", val ? "enabled" : "disabled"); + + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(wp, command_wp, + "[bool]", + "Get/set the flash HW write-protect signal", + NULL); |