mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 09:33:31 +02:00
pwm: mediatek: Rework parameters for clk helper function
Convert pwm_mediatek_clk_enable() and pwm_mediatek_clk_disable() to take lower level parameters. This enables these functions to be used in the next commit when there is no valid pwm_chip and pwm_device yet. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20250725154506.2610172-13-u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
This commit is contained in:
parent
88863c9d81
commit
f43e128073
|
|
@ -65,10 +65,9 @@ to_pwm_mediatek_chip(struct pwm_chip *chip)
|
|||
return pwmchip_get_drvdata(chip);
|
||||
}
|
||||
|
||||
static int pwm_mediatek_clk_enable(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm)
|
||||
static int pwm_mediatek_clk_enable(struct pwm_mediatek_chip *pc,
|
||||
unsigned int hwpwm)
|
||||
{
|
||||
struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip);
|
||||
int ret;
|
||||
|
||||
ret = clk_prepare_enable(pc->clk_top);
|
||||
|
|
@ -79,7 +78,7 @@ static int pwm_mediatek_clk_enable(struct pwm_chip *chip,
|
|||
if (ret < 0)
|
||||
goto disable_clk_top;
|
||||
|
||||
ret = clk_prepare_enable(pc->clk_pwms[pwm->hwpwm]);
|
||||
ret = clk_prepare_enable(pc->clk_pwms[hwpwm]);
|
||||
if (ret < 0)
|
||||
goto disable_clk_main;
|
||||
|
||||
|
|
@ -93,12 +92,10 @@ static int pwm_mediatek_clk_enable(struct pwm_chip *chip,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void pwm_mediatek_clk_disable(struct pwm_chip *chip,
|
||||
struct pwm_device *pwm)
|
||||
static void pwm_mediatek_clk_disable(struct pwm_mediatek_chip *pc,
|
||||
unsigned int hwpwm)
|
||||
{
|
||||
struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip);
|
||||
|
||||
clk_disable_unprepare(pc->clk_pwms[pwm->hwpwm]);
|
||||
clk_disable_unprepare(pc->clk_pwms[hwpwm]);
|
||||
clk_disable_unprepare(pc->clk_main);
|
||||
clk_disable_unprepare(pc->clk_top);
|
||||
}
|
||||
|
|
@ -141,7 +138,7 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||
u64 resolution;
|
||||
int ret;
|
||||
|
||||
ret = pwm_mediatek_clk_enable(chip, pwm);
|
||||
ret = pwm_mediatek_clk_enable(pc, pwm->hwpwm);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -198,7 +195,7 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||
}
|
||||
|
||||
out:
|
||||
pwm_mediatek_clk_disable(chip, pwm);
|
||||
pwm_mediatek_clk_disable(pc, pwm->hwpwm);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -206,6 +203,7 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||
static int pwm_mediatek_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
const struct pwm_state *state)
|
||||
{
|
||||
struct pwm_mediatek_chip *pc = to_pwm_mediatek_chip(chip);
|
||||
int err;
|
||||
|
||||
if (state->polarity != PWM_POLARITY_NORMAL)
|
||||
|
|
@ -214,7 +212,7 @@ static int pwm_mediatek_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||
if (!state->enabled) {
|
||||
if (pwm->state.enabled) {
|
||||
pwm_mediatek_disable(chip, pwm);
|
||||
pwm_mediatek_clk_disable(chip, pwm);
|
||||
pwm_mediatek_clk_disable(pc, pwm->hwpwm);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -225,7 +223,7 @@ static int pwm_mediatek_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||
return err;
|
||||
|
||||
if (!pwm->state.enabled)
|
||||
err = pwm_mediatek_clk_enable(chip, pwm);
|
||||
err = pwm_mediatek_clk_enable(pc, pwm->hwpwm);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user