summaryrefslogtreecommitdiff
path: root/chip/mec1322
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2015-11-12 16:33:03 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-11-13 15:28:23 -0800
commit43a4578a9b1b2f21a91c3747a29cca33bd27698c (patch)
tree4f10823e51c89595e2947bacffc2e6f979599e46 /chip/mec1322
parent467fe2836e0d37bda6c216c40ced6456313468f2 (diff)
downloadchrome-ec-43a4578a9b1b2f21a91c3747a29cca33bd27698c.tar.gz
pwm: Add option for alternate clock source
The PWM clock on some chips can be configured to use different sources, which will have a dramatic effect on the actual PWM frequency. In order to support a variety of devices attached to PWM outputs add an option to select an alternate source. This is then implemented on the mec1322 chip to use the 100kHz clock source for PWM which will allow it to drive a keyboard backlight at appropriate frequencies. BUG=chrome-os-partner:47435 BRANCH=none TEST=verify that kblight brightness can be changed on chell Change-Id: Ibe93a8e029baae5a2d5f520d590b0cc4ab9a7f93 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/312509 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'chip/mec1322')
-rw-r--r--chip/mec1322/pwm.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/chip/mec1322/pwm.c b/chip/mec1322/pwm.c
index d66c03da05..1643664855 100644
--- a/chip/mec1322/pwm.c
+++ b/chip/mec1322/pwm.c
@@ -44,11 +44,15 @@ int pwm_get_duty(enum pwm_channel ch)
return MEC1322_PWM_ON(pwm_channels[ch].channel);
}
-static void pwm_configure(int ch, int active_low)
+static void pwm_configure(int ch, int active_low, int clock_low)
{
+ /*
+ * clock_low=0 selects the 48MHz Ring Oscillator source
+ * clock_low=1 selects the 100kHz_Clk source
+ */
MEC1322_PWM_CFG(ch) = (15 << 3) | /* Pre-divider = 16 */
(active_low ? (1 << 2) : 0) |
- (0 << 1); /* 48M clock */
+ (clock_low ? (1 << 1) : 0);
}
static void pwm_init(void)
@@ -57,7 +61,8 @@ static void pwm_init(void)
for (i = 0; i < PWM_CH_COUNT; ++i) {
pwm_configure(pwm_channels[i].channel,
- pwm_channels[i].flags & PWM_CONFIG_ACTIVE_LOW);
+ pwm_channels[i].flags & PWM_CONFIG_ACTIVE_LOW,
+ pwm_channels[i].flags & PWM_CONFIG_ALT_CLOCK);
pwm_set_duty(i, 0);
}
}