diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-10-30 12:32:28 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-10-30 15:33:25 -0700 |
commit | eee95c9448a8accc8416b32c55a89d5796cdf35b (patch) | |
tree | fdb155f4249e647736d7cc88f8860e7b4858ec1a | |
parent | 433f98c6b67e23641f9808e6ca6effc4285dd42e (diff) | |
download | chrome-ec-eee95c9448a8accc8416b32c55a89d5796cdf35b.tar.gz |
Switch PWM to use HOOK_SECOND instead of its own task
BUG=chrome-os-partner:15714
BRANCH=none
TEST=taskinfo no longer shows PWM task, and 'ectool pwmgetfanrpm'
updates as fan speed changes.
Change-Id: Ia23f52527c40c8117238ddc2ee4c023f59eba05a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36939
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | board/link/board.h | 1 | ||||
-rw-r--r-- | board/link/ec.tasklist | 1 | ||||
-rw-r--r-- | chip/lm4/build.mk | 2 | ||||
-rw-r--r-- | chip/lm4/lpc.c | 4 | ||||
-rw-r--r-- | chip/lm4/pwm.c | 39 | ||||
-rw-r--r-- | common/lightbar.c | 4 | ||||
-rw-r--r-- | test/charging.tasklist | 1 | ||||
-rw-r--r-- | test/kb_debounce.tasklist | 1 | ||||
-rw-r--r-- | test/kb_deghost.tasklist | 1 | ||||
-rw-r--r-- | test/power_button.tasklist | 1 | ||||
-rw-r--r-- | test/scancode.tasklist | 1 | ||||
-rw-r--r-- | test/thermal.tasklist | 1 | ||||
-rw-r--r-- | test/typematic.tasklist | 1 |
13 files changed, 24 insertions, 34 deletions
diff --git a/board/link/board.h b/board/link/board.h index 1e997c0190..9663365429 100644 --- a/board/link/board.h +++ b/board/link/board.h @@ -23,6 +23,7 @@ #define CONFIG_ONEWIRE #define CONFIG_PECI #define CONFIG_POWER_LED +#define CONFIG_PWM #define CONFIG_TASK_PROFILING #define CONFIG_TMP006 #define CONFIG_USB_CHARGE diff --git a/board/link/ec.tasklist b/board/link/ec.tasklist index eda9a9ea85..5b2c3ba956 100644 --- a/board/link/ec.tasklist +++ b/board/link/ec.tasklist @@ -21,7 +21,6 @@ TASK(CHARGER, charge_state_machine_task, NULL, TASK_STACK_SIZE) \ TASK(TEMPSENSOR, temp_sensor_task, NULL, TASK_STACK_SIZE) \ TASK(THERMAL, thermal_task, NULL, TASK_STACK_SIZE) \ - TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \ TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \ TASK(X86POWER, x86_power_task, NULL, TASK_STACK_SIZE) \ TASK(I8042CMD, i8042_command_task, NULL, TASK_STACK_SIZE) \ diff --git a/chip/lm4/build.mk b/chip/lm4/build.mk index c1405aeeb4..b2e99b20b4 100644 --- a/chip/lm4/build.mk +++ b/chip/lm4/build.mk @@ -20,8 +20,8 @@ chip-$(CONFIG_I2C)+=i2c.o chip-$(CONFIG_LPC)+=lpc.o chip-$(CONFIG_ONEWIRE)+=onewire.o chip-$(CONFIG_PECI)+=peci.o +chip-$(CONFIG_PWM)+=pwm.o chip-$(CONFIG_SPI)+=spi.o -chip-$(CONFIG_TASK_PWM)+=pwm.o chip-$(CONFIG_TASK_KEYSCAN)+=keyboard_scan.o keyboard_scan_stub.o chip-$(CONFIG_TASK_SWITCH)+=switch.o chip-$(CONFIG_TASK_TEMPSENSOR)+=chip_temp_sensor.o diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c index ce72083a3a..2ca762481d 100644 --- a/chip/lm4/lpc.c +++ b/chip/lm4/lpc.c @@ -367,7 +367,7 @@ static void handle_acpi_write(int is_cmd) case EC_ACPI_MEM_TEST_COMPLIMENT: result = 0xff - acpi_mem_test; break; -#ifdef CONFIG_TASK_PWM +#ifdef CONFIG_PWM case EC_ACPI_MEM_KEYBOARD_BACKLIGHT: /* * TODO: not very satisfying that LPC knows directly @@ -393,7 +393,7 @@ static void handle_acpi_write(int is_cmd) case EC_ACPI_MEM_TEST: acpi_mem_test = data; break; -#ifdef CONFIG_TASK_PWM +#ifdef CONFIG_PWM case EC_ACPI_MEM_KEYBOARD_BACKLIGHT: pwm_set_keyboard_backlight(data); break; diff --git a/chip/lm4/pwm.c b/chip/lm4/pwm.c index e3f359c389..3dd4a19bed 100644 --- a/chip/lm4/pwm.c +++ b/chip/lm4/pwm.c @@ -182,27 +182,6 @@ static int fan_is_stalled(void) return (((LM4_FAN_FANSTS >> (2 * FAN_CH_CPU)) & 0x03) == 0) ? 1 : 0; } -void pwm_task(void) -{ - uint16_t *mapped = (uint16_t *)host_get_memmap(EC_MEMMAP_FAN); - - while (1) { - if (fan_is_stalled()) { - mapped[0] = EC_FAN_SPEED_STALLED; - /* - * Issue warning. As we have thermal shutdown - * protection, issuing warning here should be enough. - */ - host_set_single_event(EC_HOST_EVENT_THERMAL); - cprintf(CC_PWM, "[%T Fan stalled!]\n"); - } else - mapped[0] = pwm_get_fan_rpm(); - - /* Update about once a second */ - sleep(1); - } -} - /*****************************************************************************/ /* Console commands */ @@ -443,6 +422,24 @@ static void pwm_init(void) } DECLARE_HOOK(HOOK_INIT, pwm_init, HOOK_PRIO_DEFAULT); +static void pwm_second(void) +{ + uint16_t *mapped = (uint16_t *)host_get_memmap(EC_MEMMAP_FAN); + + if (fan_is_stalled()) { + mapped[0] = EC_FAN_SPEED_STALLED; + /* + * Issue warning. As we have thermal shutdown + * protection, issuing warning here should be enough. + */ + host_set_single_event(EC_HOST_EVENT_THERMAL); + cprintf(CC_PWM, "[%T Fan stalled!]\n"); + } else { + mapped[0] = pwm_get_fan_rpm(); + } +} +DECLARE_HOOK(HOOK_SECOND, pwm_second, HOOK_PRIO_DEFAULT); + static void pwm_preserve_state(void) { struct pwm_state state; diff --git a/common/lightbar.c b/common/lightbar.c index dad881e18e..4fe6179837 100644 --- a/common/lightbar.c +++ b/common/lightbar.c @@ -253,7 +253,7 @@ static void lb_restore_state(void) * state by calling the demo_* functions directly. */ /******************************************************************************/ -#ifdef CONFIG_TASK_PWM +#ifdef CONFIG_PWM static int last_backlight_level; #endif @@ -289,7 +289,7 @@ static void get_battery_level(void) st.battery_level = bl; -#ifdef CONFIG_TASK_PWM +#ifdef CONFIG_PWM /* With nothing else to go on, use the keyboard backlight level to * set the brightness. If the keyboard backlight is OFF (which it is * when ambient is bright), use max brightness for lightbar. If diff --git a/test/charging.tasklist b/test/charging.tasklist index 69af3bc38e..b5ee86cfe7 100644 --- a/test/charging.tasklist +++ b/test/charging.tasklist @@ -17,7 +17,6 @@ #define CONFIG_TASK_LIST \ TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \ TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \ - TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \ TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \ TASK(CHARGER, charge_state_machine_task, NULL, TASK_STACK_SIZE) \ TASK(X86POWER, x86_power_task, NULL, TASK_STACK_SIZE) \ diff --git a/test/kb_debounce.tasklist b/test/kb_debounce.tasklist index 6415d6c2dd..1b1fa5a050 100644 --- a/test/kb_debounce.tasklist +++ b/test/kb_debounce.tasklist @@ -16,7 +16,6 @@ #define CONFIG_TASK_LIST \ TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \ TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \ - TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \ TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \ TASK(X86POWER, x86_power_task, NULL, TASK_STACK_SIZE) \ TASK(I8042CMD, i8042_command_task, NULL, TASK_STACK_SIZE) \ diff --git a/test/kb_deghost.tasklist b/test/kb_deghost.tasklist index 2c531cc4d5..7b03c3f854 100644 --- a/test/kb_deghost.tasklist +++ b/test/kb_deghost.tasklist @@ -17,7 +17,6 @@ #define CONFIG_TASK_LIST \ TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \ TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \ - TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \ TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \ TASK(X86POWER, x86_power_task, NULL, TASK_STACK_SIZE) \ TASK(I8042CMD, i8042_command_task, NULL, TASK_STACK_SIZE) \ diff --git a/test/power_button.tasklist b/test/power_button.tasklist index b5144b72e2..9f62015695 100644 --- a/test/power_button.tasklist +++ b/test/power_button.tasklist @@ -17,7 +17,6 @@ #define CONFIG_TASK_LIST \ TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \ TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \ - TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \ TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \ TASK(X86POWER, x86_power_task, NULL, TASK_STACK_SIZE) \ TASK(I8042CMD, i8042_command_task, NULL, TASK_STACK_SIZE) \ diff --git a/test/scancode.tasklist b/test/scancode.tasklist index 9ddf62aa95..7d8e3c14a0 100644 --- a/test/scancode.tasklist +++ b/test/scancode.tasklist @@ -17,7 +17,6 @@ #define CONFIG_TASK_LIST \ TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \ TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \ - TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \ TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \ TASK(X86POWER, x86_power_task, NULL, TASK_STACK_SIZE) \ TASK(I8042CMD, i8042_command_task, NULL, TASK_STACK_SIZE) \ diff --git a/test/thermal.tasklist b/test/thermal.tasklist index e099a0fa7b..fa92984118 100644 --- a/test/thermal.tasklist +++ b/test/thermal.tasklist @@ -19,7 +19,6 @@ TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \ TASK(TEMPSENSOR, temp_sensor_task, NULL, TASK_STACK_SIZE) \ TASK(THERMAL, thermal_task, NULL, TASK_STACK_SIZE) \ - TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \ TASK(X86POWER, x86_power_task, NULL, TASK_STACK_SIZE) \ TASK(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \ TASK(CONSOLE, console_task, NULL, TASK_STACK_SIZE) diff --git a/test/typematic.tasklist b/test/typematic.tasklist index 2c531cc4d5..7b03c3f854 100644 --- a/test/typematic.tasklist +++ b/test/typematic.tasklist @@ -17,7 +17,6 @@ #define CONFIG_TASK_LIST \ TASK(TICK, hook_task, NULL, TASK_STACK_SIZE) \ TASK(VBOOTHASH, vboot_hash_task, NULL, TASK_STACK_SIZE) \ - TASK(PWM, pwm_task, NULL, TASK_STACK_SIZE) \ TASK(TYPEMATIC, keyboard_typematic_task, NULL, TASK_STACK_SIZE) \ TASK(X86POWER, x86_power_task, NULL, TASK_STACK_SIZE) \ TASK(I8042CMD, i8042_command_task, NULL, TASK_STACK_SIZE) \ |