Skip to content

Commit f66d78f

Browse files
Lee Jonesthierryreding
authored andcommitted
pwm: sti: Supply PWM capture register addresses and bit locations
This is in preparation for subsequent patches that add support for PWM capture to this driver. Signed-off-by: Lee Jones <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent d81738b commit f66d78f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/pwm/pwm-sti.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,48 @@
2222
#include <linux/time.h>
2323

2424
#define PWM_OUT_VAL(x) (0x00 + (4 * (x))) /* Device's Duty Cycle register */
25+
#define PWM_CPT_VAL(x) (0x10 + (4 * (x))) /* Capture value */
26+
#define PWM_CPT_EDGE(x) (0x30 + (4 * (x))) /* Edge to capture on */
2527

2628
#define STI_PWM_CTRL 0x50 /* Control/Config register */
2729
#define STI_INT_EN 0x54 /* Interrupt Enable/Disable register */
30+
#define STI_INT_STA 0x58 /* Interrupt Status register */
31+
#define PWM_INT_ACK 0x5c
2832
#define PWM_PRESCALE_LOW_MASK 0x0f
2933
#define PWM_PRESCALE_HIGH_MASK 0xf0
34+
#define PWM_CPT_EDGE_MASK 0x03
35+
#define PWM_INT_ACK_MASK 0x1ff
36+
37+
#define STI_MAX_CPT_DEVS 4
38+
#define CPT_DC_MAX 0xff
3039

3140
/* Regfield IDs */
3241
enum {
3342
/* Bits in PWM_CTRL*/
3443
PWMCLK_PRESCALE_LOW,
3544
PWMCLK_PRESCALE_HIGH,
45+
CPTCLK_PRESCALE,
3646

3747
PWM_OUT_EN,
48+
PWM_CPT_EN,
3849

3950
PWM_CPT_INT_EN,
51+
PWM_CPT_INT_STAT,
4052

4153
/* Keep last */
4254
MAX_REGFIELDS
4355
};
4456

57+
/* Each capture input can be programmed to detect rising-edge, falling-edge,
58+
* either edge or neither egde
59+
*/
60+
enum sti_cpt_edge {
61+
CPT_EDGE_DISABLED,
62+
CPT_EDGE_RISING,
63+
CPT_EDGE_FALLING,
64+
CPT_EDGE_BOTH,
65+
};
66+
4567
struct sti_pwm_compat_data {
4668
const struct reg_field *reg_fields;
4769
unsigned int num_devs;
@@ -69,8 +91,11 @@ struct sti_pwm_chip {
6991
static const struct reg_field sti_pwm_regfields[MAX_REGFIELDS] = {
7092
[PWMCLK_PRESCALE_LOW] = REG_FIELD(STI_PWM_CTRL, 0, 3),
7193
[PWMCLK_PRESCALE_HIGH] = REG_FIELD(STI_PWM_CTRL, 11, 14),
94+
[CPTCLK_PRESCALE] = REG_FIELD(STI_PWM_CTRL, 4, 8),
7295
[PWM_OUT_EN] = REG_FIELD(STI_PWM_CTRL, 9, 9),
96+
[PWM_CPT_EN] = REG_FIELD(STI_PWM_CTRL, 10, 10),
7397
[PWM_CPT_INT_EN] = REG_FIELD(STI_INT_EN, 1, 4),
98+
[PWM_CPT_INT_STAT] = REG_FIELD(STI_INT_STA, 1, 4),
7499
};
75100

76101
static inline struct sti_pwm_chip *to_sti_pwmchip(struct pwm_chip *chip)

0 commit comments

Comments
 (0)