@@ -105,6 +105,7 @@ struct ehrpwm_context {
};
struct ehrpwm_pwm_chip {
+ struct device *parent;
unsigned long clk_rate;
void __iomem *mmio_base;
unsigned long period_cycles[NUM_PWM_CHANNEL];
@@ -255,7 +256,7 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
if (i == pwm->hwpwm)
continue;
- dev_err(chip->dev,
+ dev_err(pc->parent,
"period value conflicts with channel %u\n",
i);
return -EINVAL;
@@ -267,11 +268,11 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
/* Configure clock prescaler to support Low frequency PWM wave */
if (set_prescale_div(period_cycles/PERIOD_MAX, &ps_divval,
&tb_divval)) {
- dev_err(chip->dev, "Unsupported values\n");
+ dev_err(pc->parent, "Unsupported values\n");
return -EINVAL;
}
- pm_runtime_get_sync(chip->dev);
+ pm_runtime_get_sync(pc->parent);
/* Update clock prescaler values */
ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_CLKDIV_MASK, tb_divval);
@@ -298,7 +299,7 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
ehrpwm_write(pc->mmio_base, cmp_reg, duty_cycles);
- pm_runtime_put_sync(chip->dev);
+ pm_runtime_put_sync(pc->parent);
return 0;
}
@@ -321,7 +322,7 @@ static int ehrpwm_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
u16 aqcsfrc_val, aqcsfrc_mask;
/* Leave clock enabled on enabling PWM */
- pm_runtime_get_sync(chip->dev);
+ pm_runtime_get_sync(pc->parent);
/* Disabling Action Qualifier on PWM output */
if (pwm->hwpwm) {
@@ -376,7 +377,7 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
clk_disable(pc->tbclk);
/* Disable clock on PWM disable */
- pm_runtime_put_sync(chip->dev);
+ pm_runtime_put_sync(pc->parent);
}
static void ehrpwm_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
@@ -384,8 +385,8 @@ static void ehrpwm_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
if (pwm_is_enabled(pwm)) {
- dev_warn(chip->dev, "Removing PWM device without disabling\n");
- pm_runtime_put_sync(chip->dev);
+ dev_warn(pc->parent, "Removing PWM device without disabling\n");
+ pm_runtime_put_sync(pc->parent);
}
/* set period value to zero on free */
@@ -461,6 +462,7 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
if (IS_ERR(clk))
return dev_err_probe(&pdev->dev, PTR_ERR(clk), "Failed to get fck\n");
+ pc->parent = &pdev->dev;
pc->clk_rate = clk_get_rate(clk);
if (!pc->clk_rate) {
dev_err(&pdev->dev, "failed to get clock rate\n");
@@ -518,7 +520,7 @@ static void ehrpwm_pwm_save_context(struct pwm_chip *chip)
{
struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
- pm_runtime_get_sync(chip->dev);
+ pm_runtime_get_sync(pc->parent);
pc->ctx.tbctl = ehrpwm_read(pc->mmio_base, TBCTL);
pc->ctx.tbprd = ehrpwm_read(pc->mmio_base, TBPRD);
@@ -529,7 +531,7 @@ static void ehrpwm_pwm_save_context(struct pwm_chip *chip)
pc->ctx.aqsfrc = ehrpwm_read(pc->mmio_base, AQSFRC);
pc->ctx.aqcsfrc = ehrpwm_read(pc->mmio_base, AQCSFRC);
- pm_runtime_put_sync(chip->dev);
+ pm_runtime_put_sync(pc->parent);
}
static void ehrpwm_pwm_restore_context(struct pwm_chip *chip)
struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, store a pointer to the parent device in driver data. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-tiehrpwm.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)