From: Alexandre Courbot <acourbot@nvidia.com>
To: Thierry Reding
<thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org>,
Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: "linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-fbdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-fbdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] pwm-backlight: add regulator and GPIO support
Date: Mon, 02 Jul 2012 03:35:12 +0000 [thread overview]
Message-ID: <4FF116F0.5070602@nvidia.com> (raw)
In-Reply-To: <20120630183742.GE23990-RM9K5IK7kjIyiCvfTdI0JKcOhU4Rzj621B7CTYaBSLdn68oJJulU0Q@public.gmane.org>
On 07/01/2012 03:37 AM, Thierry Reding wrote:>> + ret =
of_get_named_gpio(node, "enable-gpios", 0);
>> + if (ret >= 0) {
>> + data->enable_gpio = of_get_named_gpio(node, "enable-gpios", 0);
>
> Can't you just reuse the value of ret here?
Yes, definitely.
>> + pb->enable_gpio = -EINVAL;
>
> Perhaps initialize this to -1? Assigning standard error codes to a GPIO
> doesn't make much sense.
Documentation/gpio.txt states the following:
"If you want to initialize a structure with an invalid GPIO number, use
some negative number (perhaps "-EINVAL"); that will never be valid."
gpio_is_valid() seems to be happy with any negative value, but -EINVAL
seems to be a convention here.
>> + /* optional GPIO that enables/disables the backlight */
>> + int enable_gpio;
>> + /* 0 (default initialization value) is a valid GPIO number. Make
use of
>> + * control gpio explicit to avoid bad surprises. */
>> + bool use_enable_gpio;
>
> It's a shame we have to add workarounds like this...
Yeah, I hate that too. :/ I see nothing better to do unfortunately.
Other remarks from Stephen made me realize that this patch has two major
flaws:
1) The GPIO and regulator are fixed, optional entites ; this should
cover most cases but is not very flexible.
2) Some (most?) backlight specify timings between turning power
on/enabling PWM/enabling backlight. Even the order of things may be
different. This patch totally ignores that.
So instead of having fixed "power-supply" and "enable-gpio" properties,
how about having properties describing the power-on and power-off
sequences which odd cells alternate between phandles to
regulators/gpios/pwm and delays in microseconds before continuing the
sequence. For example:
power-on = <&pwm 2 5000000
10000
&backlight_reg
0
&gpio 28 0>;
power-off = <&gpio 28 0
0
&backlight_reg
10000
&pwm 2 0>;
Here the power-on sequence would translate to, power on the second PWM
with a duty-cycle of 5ms, wait 10ms, then enable the backlight regulator
and GPIO 28 without delay. Power-off is the exact opposite. The nice
thing with this scheme is that you can reorder the sequence at will and
support the weirdest setups.
What I don't know (device tree newbie here!) is:
1) Is it legal to refer the same phandle several times in the same node?
2) Is it ok to mix phandles of different types with integer values? The
DT above compiled, but can you e.g. resolve a regulator phandle in the
middle of a property?
3) Can you "guess" the type of a phandle before parsing it? Here the
first phandle is a GPIO, but it could as well be the regulator. Do we
have means to know that in the driver code?
Sorry for the long explanation, but I really wonder if doing this is
possible at all. If it is, then I think that's the way to do for
backlight initialization.
Alex.
next prev parent reply other threads:[~2012-07-02 3:35 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-29 13:22 [PATCH] pwm-backlight: add regulator and GPIO support Alexandre Courbot
[not found] ` <1340976167-27298-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-06-29 16:04 ` Stephen Warren
[not found] ` <4FEDD222.7050905-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-06-30 3:54 ` Alex Courbot
2012-06-30 18:37 ` Thierry Reding
[not found] ` <20120630183742.GE23990-RM9K5IK7kjIyiCvfTdI0JKcOhU4Rzj621B7CTYaBSLdn68oJJulU0Q@public.gmane.org>
2012-07-02 3:35 ` Alexandre Courbot [this message]
[not found] ` <4FF116F0.5070602-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-07-02 6:46 ` Thierry Reding
[not found] ` <20120702064624.GA8683-RM9K5IK7kjIQXX3q8xo1gnVAuStQJXxyR5q1nwbD4aMs9pC9oP6+/A@public.gmane.org>
2012-07-02 7:18 ` Alexandre Courbot
2012-07-04 10:48 ` Sascha Hauer
[not found] ` <20120704104840.GJ24458-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-07-04 12:26 ` Alex Courbot
[not found] ` <4FF43692.2040805-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-07-04 12:27 ` Mark Brown
2012-07-04 13:00 ` Sascha Hauer
[not found] ` <20120704130056.GC30009-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-07-04 15:14 ` Alex Courbot
[not found] ` <4FF45DDF.9000306-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-07-04 15:24 ` Mark Brown
[not found] ` <20120704152451.GA7333-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-07-05 2:36 ` Alex Courbot
[not found] ` <4FF4FDC0.8020405-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-07-05 6:20 ` Sascha Hauer
[not found] ` <20120705062011.GI30009-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-07-05 6:25 ` Alex Courbot
[not found] ` <4FF53368.6090805-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-07-05 6:47 ` Sascha Hauer
[not found] ` <20120705064742.GL30009-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-07-05 7:43 ` Alex Courbot
[not found] ` <4FF5459F.5090201-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-07-05 7:57 ` Thierry Reding
2012-07-05 8:12 ` Alex Courbot
2012-07-05 16:03 ` Stephen Warren
2012-07-09 5:19 ` Jingoo Han
[not found] ` <00ae01cd5d92$70d1f9f0$5275edd0$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-07-09 6:12 ` Alex Courbot
2012-07-05 8:02 ` Sascha Hauer
2012-07-05 10:41 ` Mark Brown
2012-07-05 10:39 ` Mark Brown
2012-07-05 10:37 ` Mark Brown
2012-07-04 20:26 ` Sascha Hauer
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=4FF116F0.5070602@nvidia.com \
--to=acourbot@nvidia.com \
--cc=linux-fbdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=thierry.reding-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).