mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
cr50: add console commands to have parity with servo
This change adds apreset, ecreset, ec_rst, sys_rst and powerbtn options to the ccd console command. BUG=chrome-os-partner:58123 BUG=chrome-os-partner:56835 BRANCH=none TEST=manual sysrst resets the AP sysrst on/off controls SYS_RST_L ecrst resets the ec ecrst on/off controls EC_RST_L powerbtn 500 will simulate a power button press for 500 ms Change-Id: I89adc88eb407730c9d57811a07bfef8fcf63c5b9 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/393809 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "device_state.h"
|
||||
#include "gpio.h"
|
||||
#include "hooks.h"
|
||||
#include "rbox.h"
|
||||
#include "rdd.h"
|
||||
#include "registers.h"
|
||||
#include "system.h"
|
||||
@@ -218,3 +219,78 @@ static int command_ccd(int argc, char **argv)
|
||||
DECLARE_CONSOLE_COMMAND(ccd, command_ccd,
|
||||
"[uart] [<BOOLEAN>]",
|
||||
"Get/set the case closed debug state");
|
||||
|
||||
static int command_sys_rst(int argc, char **argv)
|
||||
{
|
||||
int val;
|
||||
|
||||
if (argc > 1) {
|
||||
if (parse_bool(argv[1], &val)) {
|
||||
if (val)
|
||||
assert_sys_rst();
|
||||
else
|
||||
deassert_sys_rst();
|
||||
} else
|
||||
return EC_ERROR_PARAM1;
|
||||
ccprintf("SYS_RST_L is %s\n", is_sys_rst_asserted() ?
|
||||
"asserted" : "deasserted");
|
||||
} else {
|
||||
ccprintf("Issuing AP reset\n");
|
||||
assert_sys_rst();
|
||||
usleep(200);
|
||||
deassert_sys_rst();
|
||||
}
|
||||
|
||||
return EC_SUCCESS;
|
||||
|
||||
}
|
||||
DECLARE_SAFE_CONSOLE_COMMAND(sysrst, command_sys_rst,
|
||||
"[<BOOLEAN>]",
|
||||
"Assert/deassert SYS_RST_L to reset the AP");
|
||||
|
||||
static int command_ec_rst(int argc, char **argv)
|
||||
{
|
||||
int val;
|
||||
|
||||
|
||||
if (argc > 1) {
|
||||
if (parse_bool(argv[1], &val)) {
|
||||
if (val)
|
||||
assert_ec_rst();
|
||||
else
|
||||
deassert_ec_rst();
|
||||
} else
|
||||
return EC_ERROR_PARAM1;
|
||||
|
||||
ccprintf("EC_RST_L is %s\n", is_ec_rst_asserted() ?
|
||||
"asserted" : "deasserted");
|
||||
} else {
|
||||
ccprintf("Issuing EC reset\n");
|
||||
assert_ec_rst();
|
||||
usleep(200);
|
||||
deassert_ec_rst();
|
||||
}
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
DECLARE_SAFE_CONSOLE_COMMAND(ecrst, command_ec_rst,
|
||||
"[<BOOLEAN>]",
|
||||
"Assert/deassert EC_RST_L");
|
||||
|
||||
static int command_powerbtn(int argc, char **argv)
|
||||
{
|
||||
char *e;
|
||||
int ms = 200;
|
||||
|
||||
if (argc == 2) {
|
||||
ms = strtoi(argv[1], &e, 0);
|
||||
if (*e)
|
||||
return EC_ERROR_PARAM1;
|
||||
}
|
||||
ccprintf("Simulating %dms power button press\n", ms);
|
||||
rbox_press_power_btn(ms);
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
DECLARE_CONSOLE_COMMAND(powerbtn, command_powerbtn,
|
||||
"ms",
|
||||
"Simulate a power button press");
|
||||
|
||||
@@ -6,6 +6,24 @@
|
||||
#include "clock.h"
|
||||
#include "hooks.h"
|
||||
#include "registers.h"
|
||||
#include "timer.h"
|
||||
|
||||
#define POWER_BUTTON 2
|
||||
|
||||
void rbox_press_power_btn(int ms)
|
||||
{
|
||||
uint8_t val = GREAD_FIELD(RBOX, OVERRIDE_OUTPUT, VAL);
|
||||
|
||||
GWRITE_FIELD(RBOX, OVERRIDE_OUTPUT, VAL, ~(1 << POWER_BUTTON) & val);
|
||||
GWRITE_FIELD(RBOX, OVERRIDE_OUTPUT, OEN, 1 << POWER_BUTTON);
|
||||
GWRITE_FIELD(RBOX, OVERRIDE_OUTPUT, EN, 1 << POWER_BUTTON);
|
||||
|
||||
msleep(ms);
|
||||
|
||||
GWRITE_FIELD(RBOX, OVERRIDE_OUTPUT, EN, 0);
|
||||
GWRITE_FIELD(RBOX, OVERRIDE_OUTPUT, OEN, 0);
|
||||
GWRITE_FIELD(RBOX, OVERRIDE_OUTPUT, VAL, val);
|
||||
}
|
||||
|
||||
static void rbox_release_ec_reset(void)
|
||||
{
|
||||
|
||||
11
chip/g/rbox.h
Normal file
11
chip/g/rbox.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef __CROS_RBOX_H
|
||||
#define __CROS_RBOX_H
|
||||
|
||||
/* Simultate a power button press */
|
||||
void rbox_press_power_btn(int ms);
|
||||
#endif /* __CROS_RBOX_H */
|
||||
Reference in New Issue
Block a user