Commit eb3f7cbe authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Douglas Anderson

drm/bridge: ti-sn65dsi86: Associate PWM device to auxiliary device

It's the ti_sn65dsi86.pwm auxiliary driver that creates the pwmchip, so
let the auxiliary device be the parent of the pwm device.

Note that getting a reference to the ti-sn65dsi86's pwm using pwm_get()
isn't affected by this change as ti_sn65dsi86_add_aux_device() sets the
auxiliary device's of_node to that of the main device.

Also change PM runtime tracking and diagnostic messages to use that one.
After enabling runtime PM operation for the auxiliary device, all works
as expected as parent devices are handled just fine.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tested-by: Nikita Travkin <nikita@trvn.ru> # Acer Aspire 1
Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20231209153108.1988551-2-u.kleine-koenig@pengutronix.de
parent 9e52d5c8
...@@ -1413,7 +1413,7 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -1413,7 +1413,7 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
int ret; int ret;
if (!pdata->pwm_enabled) { if (!pdata->pwm_enabled) {
ret = pm_runtime_resume_and_get(pdata->dev); ret = pm_runtime_resume_and_get(chip->dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
...@@ -1429,7 +1429,7 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -1429,7 +1429,7 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
SN_GPIO_MUX_MASK << (2 * SN_PWM_GPIO_IDX), SN_GPIO_MUX_MASK << (2 * SN_PWM_GPIO_IDX),
SN_GPIO_MUX_SPECIAL << (2 * SN_PWM_GPIO_IDX)); SN_GPIO_MUX_SPECIAL << (2 * SN_PWM_GPIO_IDX));
if (ret) { if (ret) {
dev_err(pdata->dev, "failed to mux in PWM function\n"); dev_err(chip->dev, "failed to mux in PWM function\n");
goto out; goto out;
} }
} }
...@@ -1505,7 +1505,7 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -1505,7 +1505,7 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
ret = regmap_write(pdata->regmap, SN_PWM_PRE_DIV_REG, pre_div); ret = regmap_write(pdata->regmap, SN_PWM_PRE_DIV_REG, pre_div);
if (ret) { if (ret) {
dev_err(pdata->dev, "failed to update PWM_PRE_DIV\n"); dev_err(chip->dev, "failed to update PWM_PRE_DIV\n");
goto out; goto out;
} }
...@@ -1517,7 +1517,7 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -1517,7 +1517,7 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
FIELD_PREP(SN_PWM_INV_MASK, state->polarity == PWM_POLARITY_INVERSED); FIELD_PREP(SN_PWM_INV_MASK, state->polarity == PWM_POLARITY_INVERSED);
ret = regmap_write(pdata->regmap, SN_PWM_EN_INV_REG, pwm_en_inv); ret = regmap_write(pdata->regmap, SN_PWM_EN_INV_REG, pwm_en_inv);
if (ret) { if (ret) {
dev_err(pdata->dev, "failed to update PWM_EN/PWM_INV\n"); dev_err(chip->dev, "failed to update PWM_EN/PWM_INV\n");
goto out; goto out;
} }
...@@ -1525,7 +1525,7 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -1525,7 +1525,7 @@ static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
out: out:
if (!pdata->pwm_enabled) if (!pdata->pwm_enabled)
pm_runtime_put_sync(pdata->dev); pm_runtime_put_sync(chip->dev);
return ret; return ret;
} }
...@@ -1585,12 +1585,14 @@ static int ti_sn_pwm_probe(struct auxiliary_device *adev, ...@@ -1585,12 +1585,14 @@ static int ti_sn_pwm_probe(struct auxiliary_device *adev,
{ {
struct ti_sn65dsi86 *pdata = dev_get_drvdata(adev->dev.parent); struct ti_sn65dsi86 *pdata = dev_get_drvdata(adev->dev.parent);
pdata->pchip.dev = pdata->dev; pdata->pchip.dev = &adev->dev;
pdata->pchip.ops = &ti_sn_pwm_ops; pdata->pchip.ops = &ti_sn_pwm_ops;
pdata->pchip.npwm = 1; pdata->pchip.npwm = 1;
pdata->pchip.of_xlate = of_pwm_single_xlate; pdata->pchip.of_xlate = of_pwm_single_xlate;
pdata->pchip.of_pwm_n_cells = 1; pdata->pchip.of_pwm_n_cells = 1;
devm_pm_runtime_enable(&adev->dev);
return pwmchip_add(&pdata->pchip); return pwmchip_add(&pdata->pchip);
} }
...@@ -1601,7 +1603,7 @@ static void ti_sn_pwm_remove(struct auxiliary_device *adev) ...@@ -1601,7 +1603,7 @@ static void ti_sn_pwm_remove(struct auxiliary_device *adev)
pwmchip_remove(&pdata->pchip); pwmchip_remove(&pdata->pchip);
if (pdata->pwm_enabled) if (pdata->pwm_enabled)
pm_runtime_put_sync(pdata->dev); pm_runtime_put_sync(&adev->dev);
} }
static const struct auxiliary_device_id ti_sn_pwm_id_table[] = { static const struct auxiliary_device_id ti_sn_pwm_id_table[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment