summaryrefslogtreecommitdiff
path: root/chip/lm4/clock.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-03-29 12:40:07 -0700
committerChromeBot <chrome-bot@google.com>2013-03-29 15:39:34 -0700
commit97bf36c9d3ad3d96ad6dea7cd6e6f3e164297c43 (patch)
tree5d4ba65334beb071e4cc09d8a404e859bca398ac /chip/lm4/clock.c
parentc317992194ea089a97c4d54ef77ff4b1e283c248 (diff)
downloadchrome-ec-97bf36c9d3ad3d96ad6dea7cd6e6f3e164297c43.tar.gz
Add parse_bool() to centralize parsing boolean options
This way debug commands which previously took only yes/no or on/off or enable/disable can take any of those options. BUG=chrome-os-partner:18467 BRANCH=none TEST=Try "on", "off", "yes", "no", "true", "false", "ena", "disable", for each of the following commands: - ilim (spring) - pll (link) - power (spring/snow) - hcdebug (all) - kblog (link) - ksscan (all) - lp5562 (spring) Change-Id: Ie8e0fae3775b1da711864bcba6682ba5e68a06f1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46900 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'chip/lm4/clock.c')
-rw-r--r--chip/lm4/clock.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/chip/lm4/clock.c b/chip/lm4/clock.c
index 357efb276d..fea8873969 100644
--- a/chip/lm4/clock.c
+++ b/chip/lm4/clock.c
@@ -252,28 +252,26 @@ DECLARE_CONSOLE_COMMAND(sleep, command_sleep,
static int command_pll(int argc, char **argv)
{
- int div = 1;
+ int v;
/* Toggle the PLL */
if (argc > 1) {
- if (!strcasecmp(argv[1], "off"))
- clock_enable_pll(0, 1);
- else if (!strcasecmp(argv[1], "on"))
- clock_enable_pll(1, 1);
- else {
+ if (parse_bool(argv[1], &v)) {
+ clock_enable_pll(v, 1);
+ } else {
/* Disable PLL and set extra divider */
char *e;
- div = strtoi(argv[1], &e, 10);
+ v = strtoi(argv[1], &e, 10);
if (*e)
return EC_ERROR_PARAM1;
- LM4_SYSTEM_RCC = LM4_SYSTEM_RCC_SYSDIV(div - 1) |
+ LM4_SYSTEM_RCC = LM4_SYSTEM_RCC_SYSDIV(v - 1) |
LM4_SYSTEM_RCC_BYPASS |
LM4_SYSTEM_RCC_PWRDN |
LM4_SYSTEM_RCC_OSCSRC(1) |
LM4_SYSTEM_RCC_MOSCDIS;
- freq = INTERNAL_CLOCK / div;
+ freq = INTERNAL_CLOCK / v;
/* Notify modules of frequency change */
hook_notify(HOOK_FREQ_CHANGE);