summaryrefslogtreecommitdiff
path: root/include/pwm.h
blob: 401d3dc0ec8032f8aadd3a1d22b6653d5f868bfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* Copyright 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef __CROS_EC_PWM_H
#define __CROS_EC_PWM_H

/* The values are defined in board.h */
enum pwm_channel;

/**
 * Enable/disable a PWM channel.
 */
void pwm_enable(enum pwm_channel ch, int enabled);

/**
 * Get PWM channel enabled status.
 */
int pwm_get_enabled(enum pwm_channel ch);

/**
 * Set PWM channel duty cycle (0-65535).
 */
void pwm_set_raw_duty(enum pwm_channel ch, uint16_t duty);

/**
 * Get PWM channel duty cycle.
 */
uint16_t pwm_get_raw_duty(enum pwm_channel ch);

/**
 * Set PWM channel duty cycle (0-100).
 */
void pwm_set_duty(enum pwm_channel ch, int percent);

/**
 * Get PWM channel duty cycle.
 */
int pwm_get_duty(enum pwm_channel ch);


/* Flags for PWM config table */

/**
 * PWM output signal is inverted, so 100% duty means always low
 */
#define PWM_CONFIG_ACTIVE_LOW		BIT(0)
/**
 * PWM channel has a fan controller with a tach input and can auto-adjust
 * its duty cycle to produce a given fan RPM.
 */
#define PWM_CONFIG_HAS_RPM_MODE		BIT(1)
/**
 * PWM clock select alternate source.  The actual clock and alternate
 * source are chip dependent.
 */
#define PWM_CONFIG_ALT_CLOCK		BIT(2)
/**
 * PWM channel has a complementary output signal which should be enabled in
 * addition to the primary output.
 */
#define PWM_CONFIG_COMPLEMENTARY_OUTPUT	BIT(3)
/**
 * PWM channel must stay active in low-power idle, if enabled.
 */
#define PWM_CONFIG_DSLEEP		BIT(4)
/**
 * PWM channel's IO type is open-drain, if enabled. (default IO is push-pull.)
 */
#define PWM_CONFIG_OPEN_DRAIN		BIT(5)
#endif  /* __CROS_EC_PWM_H */