kevin: rk3399: ectool interface for EC RTC alarm

Only way to set alarm previously was through
rtcalarm command on EC console.  Implemented
interface through ectool so that the AP can set
it as well.

BUG=chrome-os-partner:52218
BRANCH=None
TEST=from AP console, run ectool rtcalarm <sec>
     Should see [event set 0x02000000] from EC
     console in approximately <sec> seconds.

Change-Id: I3202b826cb994dbca456b8b9c22bbca4dbe2766a
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/347493
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
This commit is contained in:
Shelley Chen
2016-05-26 11:13:40 -07:00
committed by chrome-bot
parent 641b02a46c
commit cebf8734d9
2 changed files with 38 additions and 0 deletions

View File

@@ -762,6 +762,17 @@ DECLARE_HOST_COMMAND(EC_CMD_RTC_SET_VALUE,
system_rtc_set_value,
EC_VER_MASK(0));
static int system_rtc_set_alarm(struct host_cmd_handler_args *args)
{
const struct ec_params_rtc *p = args->params;
system_set_rtc_alarm(p->time, 0);
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_RTC_SET_ALARM,
system_rtc_set_alarm,
EC_VER_MASK(0));
#ifdef CONFIG_EXTERNAL_STORAGE
void system_jump_to_booter(void)
{

View File

@@ -187,6 +187,8 @@ const char help_str[] =
" Reads a pattern from the EC via LPC\n"
" reboot_ec <RO|RW|cold|hibernate|disable-jump> [at-shutdown]\n"
" Reboot EC to RO or RW\n"
" rtcalarm <sec>\n"
" Set real-time clock alarm to go off in <sec> seconds\n"
" rtcget\n"
" Print real-time clock\n"
" rtcset <time>\n"
@@ -5962,6 +5964,30 @@ int cmd_rtc_set(int argc, char *argv[])
return 0;
}
int cmd_rtc_set_alarm(int argc, char *argv[])
{
struct ec_params_rtc p;
char *e;
int rv;
if (argc != 2) {
fprintf(stderr, "Usage: %s <sec>\n", argv[0]);
return -1;
}
p.time = strtol(argv[1], &e, 0);
if (e && *e) {
fprintf(stderr, "Bad time.\n");
return -1;
}
rv = ec_command(EC_CMD_RTC_SET_ALARM, 0, &p, sizeof(p), NULL, 0);
if (rv < 0)
return rv;
printf("Alarm Set to go off in %d secs.\n", p.time);
return 0;
}
int cmd_console(int argc, char *argv[])
{
char *out = (char *)ec_inbuf;
@@ -6736,6 +6762,7 @@ const struct command commands[] = {
{"pwmsetduty", cmd_pwm_set_duty},
{"readtest", cmd_read_test},
{"reboot_ec", cmd_reboot_ec},
{"rtcalarm", cmd_rtc_set_alarm},
{"rtcget", cmd_rtc_get},
{"rtcset", cmd_rtc_set},
{"rwhashpd", cmd_rw_hash_pd},