mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
Add 'fanduty' command both EC console and ectool.
This forces the fan PWM duty cycle to a fixed percentage (0-100). It's only used for airflow testing. BUG=chrome-os-partner:10747 TEST=manual Using this ectool, try ectool fanduty 0 ectool pwmgetfanrpm ectool fanduty 50 ectool pwmgetfanrpm ectool fanduty 100 ectool pwmgetfanrpm You should see (and hear) the fan speed up. If you have an EC console, you can run faninfo and it should show that the 'Target:' is unrelated to the 'Actual:' value. Change-Id: Iac332fb3ba63f96726cf7f64061b3ce22d2e76fd Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/25965 Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
@@ -29,9 +29,6 @@
|
||||
/* Enable the fake developer switch. See crosbug.com/p/8884 */
|
||||
#define CONFIG_FAKE_DEV_SWITCH
|
||||
|
||||
/* Enable direct fan PWM control. See crosbug.com/p/10747 */
|
||||
#define CONFIG_CONSOLE_CMD_FANDUTY
|
||||
|
||||
/* Fan PWM channels */
|
||||
#define FAN_CH_CPU 0 /* CPU fan */
|
||||
#define FAN_CH_KBLIGHT 1 /* Keyboard backlight */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "console.h"
|
||||
#include "gpio.h"
|
||||
#include "hooks.h"
|
||||
#include "host_command.h"
|
||||
#include "lpc.h"
|
||||
#include "ec_commands.h"
|
||||
#include "pwm.h"
|
||||
@@ -212,23 +213,11 @@ DECLARE_CONSOLE_COMMAND(fanset, command_fan_set,
|
||||
"Set fan speed",
|
||||
NULL);
|
||||
|
||||
|
||||
#ifdef CONFIG_CONSOLE_CMD_FANDUTY
|
||||
/* TODO: this is a temporary command for debugging tach issues */
|
||||
static int command_fan_duty(int argc, char **argv)
|
||||
int pwm_set_fan_duty(int percent)
|
||||
{
|
||||
int d = 0, pwm;
|
||||
char *e;
|
||||
int pwm;
|
||||
|
||||
if (argc < 2)
|
||||
return EC_ERROR_PARAM_COUNT;
|
||||
|
||||
d = strtoi(argv[1], &e, 0);
|
||||
if (*e)
|
||||
return EC_ERROR_PARAM1;
|
||||
|
||||
pwm = (MAX_PWM * d) / 100;
|
||||
ccprintf("Setting fan duty cycle to %d%% = 0x%x...\n", d, pwm);
|
||||
pwm = (MAX_PWM * percent) / 100;
|
||||
|
||||
/* Move the fan to manual control */
|
||||
if (!(LM4_FAN_FANCH(FAN_CH_CPU) & 0x0001)) {
|
||||
@@ -248,12 +237,28 @@ static int command_fan_duty(int argc, char **argv)
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
DECLARE_CONSOLE_COMMAND(fanduty, command_fan_duty,
|
||||
|
||||
static int ec_command_fan_duty(int argc, char **argv)
|
||||
{
|
||||
int percent = 0;
|
||||
char *e;
|
||||
|
||||
if (argc < 2)
|
||||
return EC_ERROR_PARAM_COUNT;
|
||||
|
||||
percent = strtoi(argv[1], &e, 0);
|
||||
if (*e)
|
||||
return EC_ERROR_PARAM1;
|
||||
|
||||
ccprintf("Setting fan duty cycle to %d%%\n", percent);
|
||||
pwm_set_fan_duty(percent);
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
DECLARE_CONSOLE_COMMAND(fanduty, ec_command_fan_duty,
|
||||
"percent",
|
||||
"Set fan duty cycle",
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
|
||||
static int command_kblight(int argc, char **argv)
|
||||
{
|
||||
|
||||
@@ -37,6 +37,16 @@ DECLARE_HOST_COMMAND(EC_CMD_PWM_SET_FAN_TARGET_RPM,
|
||||
pwm_command_set_fan_target_rpm);
|
||||
|
||||
|
||||
int pwm_command_fan_duty(uint8_t *data, int *resp_size)
|
||||
{
|
||||
struct ec_params_pwm_set_fan_duty *p =
|
||||
(struct ec_params_pwm_set_fan_duty *)data;
|
||||
pwm_set_fan_duty(p->percent);
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
DECLARE_HOST_COMMAND(EC_CMD_PWM_SET_FAN_DUTY, pwm_command_fan_duty);
|
||||
|
||||
|
||||
int pwm_command_get_keyboard_backlight(uint8_t *data, int *resp_size)
|
||||
{
|
||||
struct ec_response_pwm_get_keyboard_backlight *r =
|
||||
|
||||
@@ -381,6 +381,12 @@ struct ec_params_pwm_set_keyboard_backlight {
|
||||
uint8_t percent;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Set target fan PWM duty cycle */
|
||||
#define EC_CMD_PWM_SET_FAN_DUTY 0x24
|
||||
struct ec_params_pwm_set_fan_duty {
|
||||
uint32_t percent;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Lightbar commands. This looks worse than it is. Since we only use one LPC
|
||||
* command to say "talk to the lightbar", we put the "and tell it to do X"
|
||||
|
||||
@@ -23,6 +23,9 @@ int pwm_get_fan_target_rpm(void);
|
||||
/* Set the target fan RPM. Pass -1 to set fan to maximum. */
|
||||
int pwm_set_fan_target_rpm(int rpm);
|
||||
|
||||
/* Set the fan PWM duty cycle (0-100), disabling the automatic control. */
|
||||
int pwm_set_fan_duty(int percent);
|
||||
|
||||
/* Enable/disable the keyboard backlight. */
|
||||
int pwm_enable_keyboard_backlight(int enable);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "battery.h"
|
||||
#include "board.h"
|
||||
#include "comm-host.h"
|
||||
#include "ec_commands.h"
|
||||
#include "lightbar.h"
|
||||
@@ -51,6 +52,8 @@ const char help_str[] =
|
||||
" Sets the SMI mask for EC host events\n"
|
||||
" eventsetwakemask <mask>\n"
|
||||
" Sets the wake mask for EC host events\n"
|
||||
" fanduty <percent>\n"
|
||||
" Forces the fan PWM to a constant duty cycle\n"
|
||||
" flasherase <offset> <size>\n"
|
||||
" Erases EC flash\n"
|
||||
" flashinfo\n"
|
||||
@@ -797,6 +800,31 @@ int cmd_pwm_set_keyboard_backlight(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_fanduty(int argc, char *argv[])
|
||||
{
|
||||
struct ec_params_pwm_set_fan_duty p;
|
||||
char *e;
|
||||
int rv;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr,
|
||||
"Usage: %s <targetrpm>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
p.percent = strtol(argv[1], &e, 0);
|
||||
if (e && *e) {
|
||||
fprintf(stderr, "Bad percent arg.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = ec_command(EC_CMD_PWM_SET_FAN_DUTY,
|
||||
&p, sizeof(p), NULL, 0);
|
||||
if (rv)
|
||||
return rv;
|
||||
|
||||
printf("Fan duty cycle set.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define LBMSG(state) #state
|
||||
#include "lightbar_msg_list.h"
|
||||
@@ -1556,6 +1584,7 @@ const struct command commands[] = {
|
||||
{"eventsetscimask", cmd_host_event_set_sci_mask},
|
||||
{"eventsetsmimask", cmd_host_event_set_smi_mask},
|
||||
{"eventsetwakemask", cmd_host_event_set_wake_mask},
|
||||
{"fanduty", cmd_fanduty},
|
||||
{"flasherase", cmd_flash_erase},
|
||||
{"flashread", cmd_flash_read},
|
||||
{"flashwrite", cmd_flash_write},
|
||||
|
||||
Reference in New Issue
Block a user