summaryrefslogtreecommitdiff
path: root/chip/lm4/pwm.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-02-21 12:51:42 -0800
committerRandall Spangler <rspangler@chromium.org>2012-02-21 12:59:44 -0800
commit12b12e53346a6c80e33e1f88beb620b01efac2d9 (patch)
tree7c0f7ae780a57e83d0c057cd82df49ebb1a14025 /chip/lm4/pwm.c
parent63c9ebaac95d0d95cae132533ca30708ea87a0f7 (diff)
downloadchrome-ec-12b12e53346a6c80e33e1f88beb620b01efac2d9.tar.gz
Add EC host commands for keyboard backlight
Signed-off-by: Randall Spangler <rspangler@chromium.org> BUG=chrome-os-partner:8128 TEST='ectool setkblight X && ectool getkblight' for X=1, 20, 99, 100, 0 Change-Id: I540fd2d05f4caa110cd1dc45e9b5184fc8777a06
Diffstat (limited to 'chip/lm4/pwm.c')
-rw-r--r--chip/lm4/pwm.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/chip/lm4/pwm.c b/chip/lm4/pwm.c
index d877e721ab..bcb19f49a0 100644
--- a/chip/lm4/pwm.c
+++ b/chip/lm4/pwm.c
@@ -64,9 +64,16 @@ int pwm_set_fan_target_rpm(int rpm)
}
+int pwm_get_keyboard_backlight(void)
+{
+ return ((LM4_FAN_FANCMD(FAN_CH_KBLIGHT) >> 16) * 100 +
+ MAX_PWM / 2) / MAX_PWM;
+}
+
+
int pwm_set_keyboard_backlight(int percent)
{
- LM4_FAN_FANCMD(FAN_CH_KBLIGHT) = ((percent * MAX_PWM) / 100) << 16;
+ LM4_FAN_FANCMD(FAN_CH_KBLIGHT) = ((percent * MAX_PWM + 50) / 100) << 16;
return EC_SUCCESS;
}
@@ -164,8 +171,9 @@ static int command_kblight(int argc, char **argv)
int i;
if (argc < 2) {
- uart_puts("Usage: kblight <percent>\n");
- return EC_ERROR_UNKNOWN;
+ uart_printf("Keyboard backlight is at %d%%\n",
+ pwm_get_keyboard_backlight());
+ return EC_SUCCESS;
}
i = strtoi(argv[1], &e, 0);
@@ -182,14 +190,6 @@ static int command_kblight(int argc, char **argv)
}
DECLARE_CONSOLE_COMMAND(kblight, command_kblight);
-static const struct console_command console_commands[] = {
- {"fanduty", command_fan_duty},
- {"faninfo", command_fan_info},
- {"fanset", command_fan_set},
- {"kblight", command_kblight},
-};
-
-
/*****************************************************************************/
/* Initialization */