summaryrefslogtreecommitdiff
path: root/board/it8380dev
diff options
context:
space:
mode:
authorDino Li <dino.li@ite.com.tw>2015-06-24 11:43:29 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-25 05:32:30 +0000
commitd5c43a880c7dadf76df152422f8b0f5e68455f61 (patch)
treec34a9357877ac5ae4b625b3a8c96824d68d5697f /board/it8380dev
parent52ee6aa1312b71472196015a4bf70f384f9f27d4 (diff)
downloadchrome-ec-d5c43a880c7dadf76df152422f8b0f5e68455f61.tar.gz
it8380dev: add fan control module
1. pwm, add frequency select function for pwm channels. 2. timer, add external timer 3~8 apis. 3. add fan control module for emulation board. Signed-off-by: Dino Li <dino.li@ite.com.tw> BRANCH=none BUG=none TEST=console command "faninfo, fanset, fanduty, and fanauto" fanset 3333 Setting fan 0 rpm target to 3333 faninfo Actual: 3390 rpm Target: 3333 rpm Duty: 35% Status: 1 (changing) Mode: rpm Auto: no Enable: yes faninfo Actual: 3301 rpm Target: 3333 rpm Duty: 34% Status: 2 (locked) Mode: rpm Auto: no Enable: yes fanduty 80 Setting fan 0 duty cycle to 80% faninfo Actual: 5952 rpm Target: 3333 rpm Duty: 80% Status: 2 (locked) Mode: duty Auto: no Enable: yes faninfo Actual: 5971 rpm Target: 3333 rpm Duty: 80% Status: 2 (locked) Mode: duty Auto: no Enable: yes fanauto faninfo Actual: 3330 rpm Target: 3333 rpm Duty: 36% Status: 2 (locked) Mode: rpm Auto: yes Enable: yes fanset 8000 Setting fan 0 rpm target to 8000 faninfo Actual: 6793 rpm Target: 8000 rpm Duty: 100% Status: 3 (frustrated) Mode: rpm Auto: no Enable: yes fanset 3456 Setting fan 0 rpm target to 3456 faninfo Actual: 5053 rpm Target: 3456 rpm Duty: 56% Status: 1 (changing) Mode: rpm Auto: no Enable: yes faninfo Actual: 3440 rpm Target: 3456 rpm Duty: 34% Status: 2 (locked) Mode: rpm Auto: no Enable: yes /* force stop the fan */ [87.035136 Fan 0 stalled!] [87.035520 event set 0x00000400] [88.035712 Fan 0 stalled!] [89.036288 Fan 0 stalled!] [90.036864 Fan 0 stalled!] [91.037440 Fan 0 stalled!] [92.038016 Fan 0 stalled!] [93.038592 Fan 0 stalled!] [94.039168 Fan 0 stalled!] /* release */ faninfo Actual: 3427 rpm Target: 3456 rpm Duty: 35% Status: 2 (locked) Mode: rpm Auto: no Enable: yes Change-Id: Icbe1917902d033a8be42b8d834ffc6045d08b985 Reviewed-on: https://chromium-review.googlesource.com/266625 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Dino Li <dino.li@ite.com.tw> Tested-by: Dino Li <dino.li@ite.com.tw>
Diffstat (limited to 'board/it8380dev')
-rw-r--r--board/it8380dev/board.c56
-rw-r--r--board/it8380dev/board.h4
-rw-r--r--board/it8380dev/gpio.inc2
3 files changed, 53 insertions, 9 deletions
diff --git a/board/it8380dev/board.c b/board/it8380dev/board.c
index 0c363182f1..4179dfce19 100644
--- a/board/it8380dev/board.c
+++ b/board/it8380dev/board.c
@@ -22,6 +22,7 @@
#include "timer.h"
#include "lpc.h"
#include "intc.h"
+#include "fan.h"
/* Test GPIO interrupt function that toggles one LED. */
void test_interrupt(enum gpio_signal signal)
@@ -35,19 +36,58 @@ void test_interrupt(enum gpio_signal signal)
#include "gpio_list.h"
-/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
+/*
+ * PWM channels. Must be in the exactly same order as in enum pwm_channel.
+ * There total three 16 bits clock prescaler registers for all pwm channels,
+ * so use the same frequency and prescaler register setting is required if
+ * number of pwm channel greater than three.
+ */
const struct pwm_t pwm_channels[] = {
- {0, 0},
- {1, PWM_CONFIG_ACTIVE_LOW},
- {2, 0},
- {3, PWM_CONFIG_ACTIVE_LOW},
- {4, 0},
- {5, PWM_CONFIG_ACTIVE_LOW},
- {7, PWM_CONFIG_ACTIVE_LOW},
+ {7, 0, 30000, PWM_PRESCALER_C4},
+ {1, PWM_CONFIG_ACTIVE_LOW, 1000, PWM_PRESCALER_C6},
+ {2, 0, 200, PWM_PRESCALER_C7},
+ {3, PWM_CONFIG_ACTIVE_LOW, 1000, PWM_PRESCALER_C6},
+ {4, 0, 30000, PWM_PRESCALER_C4},
+ {5, PWM_CONFIG_ACTIVE_LOW, 200, PWM_PRESCALER_C7},
+ {0, PWM_CONFIG_ACTIVE_LOW, 1000, PWM_PRESCALER_C6},
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+const struct fan_t fans[] = {
+ {.flags = FAN_USE_RPM_MODE,
+ .rpm_min = 1500,
+ .rpm_start = 1500,
+ .rpm_max = 6500,
+ /*
+ * index of pwm_channels, not pwm output channel.
+ * pwm output channel is member "channel" of pwm_t.
+ */
+ .ch = 0,
+ .pgood_gpio = -1,
+ .enable_gpio = -1,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(fans) == CONFIG_FANS);
+
+/*
+ * PWM HW channelx binding tachometer channelx for fan control.
+ * Four tachometer input pins but two tachometer modules only,
+ * so always binding [TACH_CH_TACH0A | TACH_CH_TACH0B] and/or
+ * [TACH_CH_TACH1A | TACH_CH_TACH1B]
+ */
+const struct fan_tach_t fan_tach[] = {
+ {TACH_CH_NULL, -1, -1, -1},
+ {TACH_CH_NULL, -1, -1, -1},
+ {TACH_CH_NULL, -1, -1, -1},
+ {TACH_CH_NULL, -1, -1, -1},
+ {TACH_CH_NULL, -1, -1, -1},
+ {TACH_CH_NULL, -1, -1, -1},
+ {TACH_CH_NULL, -1, -1, -1},
+ {TACH_CH_TACH0A, 2, 50, 30},
+};
+BUILD_ASSERT(ARRAY_SIZE(fan_tach) == PWM_HW_CH_TOTAL);
+
/* PNPCFG settings */
const struct ec2i_t pnpcfg_settings[] = {
/* Select logical device 06h(keyboard) */
diff --git a/board/it8380dev/board.h b/board/it8380dev/board.h
index 6d5b5f07cc..4e13c58b86 100644
--- a/board/it8380dev/board.h
+++ b/board/it8380dev/board.h
@@ -17,6 +17,8 @@
#define CONFIG_PECI_TJMAX 100
/* For IT839X series and IT838X DX only. */
#define CONFIG_PECI_WITH_INTERRUPT
+#define CONFIG_FANS 1
+#undef CHIP_FAMILY_IT839X
/* Debug */
#undef CONFIG_KEYBOARD_DEBUG
@@ -28,7 +30,7 @@
#include "gpio_signal.h"
enum pwm_channel {
- PWM_CH_0,
+ PWM_CH_FAN,
PWM_CH_1,
PWM_CH_2,
PWM_CH_3,
diff --git a/board/it8380dev/gpio.inc b/board/it8380dev/gpio.inc
index b7685f69af..4a443c67eb 100644
--- a/board/it8380dev/gpio.inc
+++ b/board/it8380dev/gpio.inc
@@ -44,3 +44,5 @@ ALTERNATE(PIN_MASK(G, 0x01), 3, MODULE_SPI, 0) /* SSCE1# of SPI */
#else
ALTERNATE(PIN_MASK(G, 0x04), 3, MODULE_SPI, 0) /* SSCE0# of SPI */
#endif
+ALTERNATE(PIN_MASK(A, 0x80), 1, MODULE_PWM_FAN, 0) /* PWM7 for FAN1 */
+ALTERNATE(PIN_MASK(D, 0x40), 3, MODULE_PWM_FAN, 0) /* TACH0A for FAN1 */