From a300a5681a40b9cc7f2b9a651f3c159e90a7753b Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 1 Oct 2019 12:01:46 -0600 Subject: [PATCH] Attempt to initialize PWM for CPU fan --- src/board/system76/galp3-c/pwm.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/board/system76/galp3-c/pwm.c b/src/board/system76/galp3-c/pwm.c index 3a66f2a..4b97649 100644 --- a/src/board/system76/galp3-c/pwm.c +++ b/src/board/system76/galp3-c/pwm.c @@ -3,6 +3,26 @@ void pwm_init(void) { // Set T0CHSEL to TACH0A and T1CHSEL to TACH1A TSWCTLR = 0; - // Turn on the CPU fan at full blast (temperature control TODO) - DCR2 = 0xFF; + + // Disable PWM + ZTIER = 0; + + // Set prescaler to 1159 + 1 + C6CPRS = 0x87; + C6MCPRS = 0x04; + + // Set cycle time to 255 + 1 + CTR2 = 0xFF; + + // Turn on the CPU fan at half blast (temperature control TODO) + DCR2 = 0x80; + + // Set gating clock source + PCSGR = 0xFF; + + // Set PWM2 output to use C6CPRS / CTR2 + PCSSGL = (0b10 << 4); + + // Enable PWM + ZTIER = (1 << 1); }