aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm/pwm-hibvt.c
diff options
context:
space:
mode:
authorMathieu Othacehe <m.othacehe@gmail.com>2019-02-19 04:58:08 -0500
committerThierry Reding <thierry.reding@gmail.com>2019-03-04 05:38:52 -0500
commit7a58fc5448d186f57d71aac031ade3bf2a302afd (patch)
tree8716fab56b4c7e7da0ae83f9de50749c6bbaefac /drivers/pwm/pwm-hibvt.c
parent50e6914387ee22e9b06597512f8d49b5cce167fc (diff)
pwm: hibvt: Add hi3559v100 support
Add support for the hi3559v100-shub-pwm and hisilicon,hi3559v100-pwm platforms. They require a special quirk: the PWM has to be enabled twice to force a duty_cycle refresh. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-hibvt.c')
-rw-r--r--drivers/pwm/pwm-hibvt.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c
index ffc803818c3c..a0b09603d13d 100644
--- a/drivers/pwm/pwm-hibvt.c
+++ b/drivers/pwm/pwm-hibvt.c
@@ -54,6 +54,7 @@ struct hibvt_pwm_chip {
54 54
55struct hibvt_pwm_soc { 55struct hibvt_pwm_soc {
56 u32 num_pwms; 56 u32 num_pwms;
57 bool quirk_force_enable;
57}; 58};
58 59
59static const struct hibvt_pwm_soc hi3516cv300_soc_info = { 60static const struct hibvt_pwm_soc hi3516cv300_soc_info = {
@@ -64,6 +65,16 @@ static const struct hibvt_pwm_soc hi3519v100_soc_info = {
64 .num_pwms = 8, 65 .num_pwms = 8,
65}; 66};
66 67
68static const struct hibvt_pwm_soc hi3559v100_shub_soc_info = {
69 .num_pwms = 8,
70 .quirk_force_enable = true,
71};
72
73static const struct hibvt_pwm_soc hi3559v100_soc_info = {
74 .num_pwms = 2,
75 .quirk_force_enable = true,
76};
77
67static inline struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip) 78static inline struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip)
68{ 79{
69 return container_of(chip, struct hibvt_pwm_chip, chip); 80 return container_of(chip, struct hibvt_pwm_chip, chip);
@@ -152,13 +163,23 @@ static void hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
152static int hibvt_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, 163static int hibvt_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
153 struct pwm_state *state) 164 struct pwm_state *state)
154{ 165{
166 struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip);
167
155 if (state->polarity != pwm->state.polarity) 168 if (state->polarity != pwm->state.polarity)
156 hibvt_pwm_set_polarity(chip, pwm, state->polarity); 169 hibvt_pwm_set_polarity(chip, pwm, state->polarity);
157 170
158 if (state->period != pwm->state.period || 171 if (state->period != pwm->state.period ||
159 state->duty_cycle != pwm->state.duty_cycle) 172 state->duty_cycle != pwm->state.duty_cycle) {
160 hibvt_pwm_config(chip, pwm, state->duty_cycle, state->period); 173 hibvt_pwm_config(chip, pwm, state->duty_cycle, state->period);
161 174
175 /*
176 * Some implementations require the PWM to be enabled twice
177 * each time the duty cycle is refreshed.
178 */
179 if (hi_pwm_chip->soc->quirk_force_enable && state->enabled)
180 hibvt_pwm_enable(chip, pwm);
181 }
182
162 if (state->enabled != pwm->state.enabled) { 183 if (state->enabled != pwm->state.enabled) {
163 if (state->enabled) 184 if (state->enabled)
164 hibvt_pwm_enable(chip, pwm); 185 hibvt_pwm_enable(chip, pwm);
@@ -259,6 +280,10 @@ static const struct of_device_id hibvt_pwm_of_match[] = {
259 .data = &hi3516cv300_soc_info }, 280 .data = &hi3516cv300_soc_info },
260 { .compatible = "hisilicon,hi3519v100-pwm", 281 { .compatible = "hisilicon,hi3519v100-pwm",
261 .data = &hi3519v100_soc_info }, 282 .data = &hi3519v100_soc_info },
283 { .compatible = "hisilicon,hi3559v100-shub-pwm",
284 .data = &hi3559v100_shub_soc_info },
285 { .compatible = "hisilicon,hi3559v100-pwm",
286 .data = &hi3559v100_soc_info },
262 { } 287 { }
263}; 288};
264MODULE_DEVICE_TABLE(of, hibvt_pwm_of_match); 289MODULE_DEVICE_TABLE(of, hibvt_pwm_of_match);