Re: [PATCH v3 2/2] pwm: add T-HEAD PWM driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> T-HEAD SoCs such as the TH1520 contain a PWM controller used
> to control the LCD backlight, fan and so on. Add driver for it.
>
> Signed-off-by: Jisheng Zhang <jszhang@xxxxxxxxxx > ---

Hello,
I've just tested your driver and it works flawlessly on the BeagleV-Ahead with the last mainline kernel. However, I had to modify some portion of the code to comply with the last kernel needs.

> +static const struct pwm_ops thead_pwm_ops = {
> +    .apply = thead_pwm_apply,
> +    .get_state = thead_pwm_get_state,
> +    .owner = THIS_MODULE,

Since commit 384461abcab6, the owner of a pwm_ops structure is implicit and so, you can (must) remove this last line now.

> +};
> ...
> +static int thead_pwm_probe(struct platform_device *pdev)
> +{
> +    struct thead_pwm_chip *priv;
> +    int ret, i;
> +    u32 val;
> +
> +    priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> +    if (!priv)
> +        return -ENOMEM;
> +
> +    platform_set_drvdata(pdev, priv);
> +
> +    priv->mmio_base = devm_platform_ioremap_resource(pdev, 0);
> +    if (IS_ERR(priv->mmio_base))
> +        return PTR_ERR(priv->mmio_base);
> +
> +    priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> +    if (IS_ERR(priv->clk))
> +        return PTR_ERR(priv->clk);
> +
> +    priv->chip.ops = &thead_pwm_ops;
> +    priv->chip.dev = &pdev->dev;
> +    priv->chip.npwm = THEAD_PWM_MAX_NUM;
> +
> +    /* check whether PWM is ever started or not */
> +    for (i = 0; i < priv->chip.npwm; i++) {
> +        val = readl(priv->mmio_base + THEAD_PWM_FP(i));
> +        if (val)
> +            priv->channel_ever_started |= 1 << i;

					     BIT(i) ?
If the bootloader starts a PWM channel for some reason, it will not be referenced by the PM usage counter, I added this line in the if statement to counter this problem :
		pm_runtime_get(&pdev->dev);

> +    }
> +
> +    ret = devm_pwmchip_add(&pdev->dev, &priv->chip);
> +    if (ret)
> +        return ret;
> +
> +    devm_pm_runtime_enable(&pdev->dev);
> +
> +    return 0;
> +}


Thank you for your work. With the above comments addressed:

Tested-by: Thomas Bonnefille <thomas.bonnefille@xxxxxxxxxxx>

Do you plan to send out a new iteration of this patch soon ?

Best regards,
Thomas Bonnefille




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux