public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: swarren@wwwdotorg•org (Stephen Warren)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v4 10/10] pwm-backlight: Add rudimentary device tree support
Date: Mon, 19 Mar 2012 20:59:59 -0600	[thread overview]
Message-ID: <4F67F2AF.3020404@wwwdotorg.org> (raw)
In-Reply-To: <1331740593-10807-11-git-send-email-thierry.reding@avionic-design.de>

On 03/14/2012 09:56 AM, Thierry Reding wrote:
> This commit adds very basic support for device tree probing. Currently,
> only a PWM and a list of distinct brightness levels can be specified.
> Enabling or disabling backlight power via GPIOs is not yet supported.
> 
> A pointer to the exit() callback is stored in the driver data to keep it
> around until the driver is unloaded.

> +++ b/Documentation/devicetree/bindings/video/backlight/pwm-backlight

> +pwm-backlight bindings
> +
> +Required properties:
> +  - compatible: "pwm-backlight"
> +  - pwm: OF device-tree PWM specification
> +  - num-brightness-levels: number of distinct brightness levels
> +  - brightness-levels: array of distinct brightness levels

I assume the values in this array are 0 (darkest/off) to 255 (max
brightness)? The doc should probably specify this.

> +  - default-brightness-level: the default brightness level

Likewise, this is an index into the default-brightness-level? Again,
it'd be best to explicitly state this.

...
> +		brightness-levels = <0 4 8 16 32 64 128 255>;
> +		default-brightness-level = <6>;


> +static int pwm_backlight_parse_dt(struct device *dev,
> +				  struct platform_pwm_backlight_data *data)
...
> +		ret = of_property_read_u32(node, "default-brightness-level",
> +					   &value);
> +		if (ret < 0)
> +			goto free;

Range-check that against max_brightness?

>  static int pwm_backlight_probe(struct platform_device *pdev)
...
> -	pb->pwm = pwm_request(data->pwm_id, "backlight");
> -	if (IS_ERR(pb->pwm)) {
> -		dev_err(&pdev->dev, "unable to request PWM for backlight\n");
> -		ret = PTR_ERR(pb->pwm);
> -		goto err_alloc;
> -	} else
> -		dev_dbg(&pdev->dev, "got pwm for backlight\n");
> +	if (!pb->pwm) {
> +		pb->pwm = pwm_request(data->pwm_id, "backlight");
> +		if (IS_ERR(pb->pwm)) {
> +			dev_err(&pdev->dev, "unable to request PWM for backlight\n");
> +			ret = PTR_ERR(pb->pwm);
> +			goto err_alloc;
> +		} else
> +			dev_dbg(&pdev->dev, "got pwm for backlight\n");
> +	}

Hmmm. It'd be more consistent if pwm_backlight_parse_dt() called
something like of_pwm_get() instead of of_pwm_request(), so that this
code could always call pwm_request() on the PWM and hence operate the
same irrespective of DT vs non-DT. GPIOs work that way at least.

  parent reply	other threads:[~2012-03-20  2:59 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-14 15:56 [PATCH v4 00/10] Add PWM framework and device tree support Thierry Reding
2012-03-14 15:56 ` [PATCH v4 01/10] PWM: add pwm framework support Thierry Reding
2012-03-14 20:52   ` Lars-Peter Clausen
2012-03-14 20:57     ` Thierry Reding
2012-03-16  7:19   ` Shawn Guo
2012-03-16  7:28     ` Thierry Reding
2012-03-20  1:55   ` Stephen Warren
2012-03-20  5:59     ` Thierry Reding
2012-03-14 15:56 ` [PATCH v4 02/10] pwm: Allow chips to support multiple PWMs Thierry Reding
2012-03-14 20:42   ` H Hartley Sweeten
2012-03-14 20:49     ` Thierry Reding
2012-03-15  0:42       ` H Hartley Sweeten
2012-03-14 15:56 ` [PATCH v4 03/10] pwm: Add device tree support Thierry Reding
2012-03-14 20:11   ` Sascha Hauer
2012-03-14 20:46     ` Thierry Reding
2012-03-15  8:40   ` Arnd Bergmann
2012-03-15 10:29     ` Mark Brown
2012-03-15 12:44       ` Arnd Bergmann
2012-03-20  2:12   ` Stephen Warren
2012-03-20  5:51     ` Thierry Reding
2012-03-14 15:56 ` [PATCH v4 04/10] ARM: tegra: Fix PWM clock programming Thierry Reding
2012-03-20  2:15   ` Stephen Warren
2012-03-14 15:56 ` [PATCH v4 05/10] ARM: tegra: Provide clock for only one PWM controller Thierry Reding
2012-03-20  2:18   ` Stephen Warren
2012-03-20  8:44     ` Thierry Reding
2012-03-20 15:27       ` Stephen Warren
2012-03-14 15:56 ` [PATCH v4 06/10] pwm: Add NVIDIA Tegra SoC support Thierry Reding
2012-03-16  8:00   ` Shawn Guo
2012-03-16  8:21     ` Thierry Reding
2012-03-20  2:35   ` Stephen Warren
2012-03-14 15:56 ` [PATCH v4 07/10] pwm: tegra: Add device tree support Thierry Reding
2012-03-20  2:42   ` Stephen Warren
2012-03-20  8:48     ` Thierry Reding
2012-03-20 15:33       ` Stephen Warren
2012-03-20 15:44         ` Thierry Reding
2012-04-04  7:04     ` Shawn Guo
2012-04-04 18:33       ` Stephen Warren
2012-03-14 15:56 ` [PATCH v4 08/10] pwm: Add Blackfin support Thierry Reding
2012-03-14 15:56 ` [PATCH v4 09/10] pwm: Add PXA support Thierry Reding
2012-03-15  0:13   ` Ryan Mallon
2012-03-15  6:56     ` Thierry Reding
2012-03-15  9:05       ` Sascha Hauer
2012-03-15  9:21         ` Thierry Reding
2012-03-15  9:45           ` Sascha Hauer
2012-03-16  8:12   ` Shawn Guo
2012-03-16  8:29     ` Thierry Reding
2012-03-14 15:56 ` [PATCH v4 10/10] pwm-backlight: Add rudimentary device tree support Thierry Reding
2012-03-15  8:48   ` Arnd Bergmann
2012-03-20  2:59   ` Stephen Warren [this message]
2012-03-20  8:39     ` Thierry Reding
2012-03-20 15:27       ` Stephen Warren
2012-03-20 15:43         ` Thierry Reding
2012-03-20 15:56           ` Stephen Warren
2012-03-20 16:08             ` Mark Brown
2012-03-14 23:19 ` [PATCH v4 00/10] Add PWM framework and " H Hartley Sweeten
2012-03-15  6:41   ` Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F67F2AF.3020404@wwwdotorg.org \
    --to=swarren@wwwdotorg$(echo .)org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox