mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
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>
This commit is contained in:
parent
50e6914387
commit
7a58fc5448
@ -54,6 +54,7 @@ struct hibvt_pwm_chip {
|
||||
|
||||
struct hibvt_pwm_soc {
|
||||
u32 num_pwms;
|
||||
bool quirk_force_enable;
|
||||
};
|
||||
|
||||
static const struct hibvt_pwm_soc hi3516cv300_soc_info = {
|
||||
@ -64,6 +65,16 @@ static const struct hibvt_pwm_soc hi3519v100_soc_info = {
|
||||
.num_pwms = 8,
|
||||
};
|
||||
|
||||
static const struct hibvt_pwm_soc hi3559v100_shub_soc_info = {
|
||||
.num_pwms = 8,
|
||||
.quirk_force_enable = true,
|
||||
};
|
||||
|
||||
static const struct hibvt_pwm_soc hi3559v100_soc_info = {
|
||||
.num_pwms = 2,
|
||||
.quirk_force_enable = true,
|
||||
};
|
||||
|
||||
static inline struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip)
|
||||
{
|
||||
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,
|
||||
static int hibvt_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
struct pwm_state *state)
|
||||
{
|
||||
struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip);
|
||||
|
||||
if (state->polarity != pwm->state.polarity)
|
||||
hibvt_pwm_set_polarity(chip, pwm, state->polarity);
|
||||
|
||||
if (state->period != pwm->state.period ||
|
||||
state->duty_cycle != pwm->state.duty_cycle)
|
||||
state->duty_cycle != pwm->state.duty_cycle) {
|
||||
hibvt_pwm_config(chip, pwm, state->duty_cycle, state->period);
|
||||
|
||||
/*
|
||||
* Some implementations require the PWM to be enabled twice
|
||||
* each time the duty cycle is refreshed.
|
||||
*/
|
||||
if (hi_pwm_chip->soc->quirk_force_enable && state->enabled)
|
||||
hibvt_pwm_enable(chip, pwm);
|
||||
}
|
||||
|
||||
if (state->enabled != pwm->state.enabled) {
|
||||
if (state->enabled)
|
||||
hibvt_pwm_enable(chip, pwm);
|
||||
@ -259,6 +280,10 @@ static const struct of_device_id hibvt_pwm_of_match[] = {
|
||||
.data = &hi3516cv300_soc_info },
|
||||
{ .compatible = "hisilicon,hi3519v100-pwm",
|
||||
.data = &hi3519v100_soc_info },
|
||||
{ .compatible = "hisilicon,hi3559v100-shub-pwm",
|
||||
.data = &hi3559v100_shub_soc_info },
|
||||
{ .compatible = "hisilicon,hi3559v100-pwm",
|
||||
.data = &hi3559v100_soc_info },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, hibvt_pwm_of_match);
|
||||
|
Loading…
Reference in New Issue
Block a user