From: "Kim, Milo" <milo.kim@ti.com>
To: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: <devicetree@vger.kernel.org>, <lee.jones@linaro.org>,
<linux-kernel@vger.kernel.org>, <linux-leds@vger.kernel.org>
Subject: Re: [PATCH RESEND 15/16] leds: add LM3633 driver
Date: Wed, 11 Nov 2015 11:16:01 +0900 [thread overview]
Message-ID: <5642A4E1.8060000@ti.com> (raw)
In-Reply-To: <5641F4D3.7000800@samsung.com>
Hi Jacek,
On 11/10/2015 10:44 PM, Jacek Anaszewski wrote:
>>>> +static ssize_t lm3633_led_store_pattern_levels(struct device *dev,
>>>> >>>+ struct device_attribute *attr,
>>>> >>>+ const char *buf, size_t len)
>>>> >>>+{
>>>> >>>+ struct ti_lmu_led *lmu_led = to_ti_lmu_led(dev);
>>>> >>>+ struct ti_lmu_led_chip *chip = lmu_led->chip;
>>>> >>>+ unsigned int low, high;
>>>> >>>+ u8 reg, offset, val;
>>>> >>>+ int ret;
>>>> >>>+
>>>> >>>+ /*
>>>> >>>+ * Sequence
>>>> >>>+ *
>>>> >>>+ * 1) Read pattern level data
>>>> >>>+ * 2) Disable a bank before programming a pattern
>>>> >>>+ * 3) Update LOW BRIGHTNESS register
>>>> >>>+ * 4) Update HIGH BRIGHTNESS register
>>>> >>>+ *
>>>> >>>+ * Level register addresses have offset number based on the LED
>>>> >>>bank.
>>>> >>>+ */
>>>> >>>+
>>>> >>>+ ret = sscanf(buf, "%u %u", &low, &high);
>>>> >>>+ if (ret != 2)
>>>> >>>+ return -EINVAL;
>>>> >>>+
>>>> >>>+ low = min_t(unsigned int, low, LM3633_LED_MAX_BRIGHTNESS);
>>> >>
>>> >>Why don't you take into account the value defined by led-max-microamp
>>> >>DT property here?
>> >
>> >'low' and 'high' are brightness value. The range is from 0 to 255. It is
>> >mostly related with LED sysfs -/sys/class/led/<led>/brightness.
>> >On the other hand, led-max-microamp is current limit. It is from 5mA to
>> >30mA. It's different configuration in this device.
> Doesn't the current has direct influence on the LED brightness?
> Are there other means for adjusting brightness than current setting?
> I see in your enum ti_lmu_max_current, that there are 26 possible
> current levels. I think that they should reflect 26 possible
> brightness levels, so max_brightness can be at most 26.
Let me describe LM3633 in more details. I'd like to have your opinion
about led-max-microamp and max_brightness usages. Datasheet would be
better to figure out characteristics.
http://www.ti.com/lit/ds/symlink/lm3633.pdf
Max current level is not same as brightness level in LM3633.
LM3633 device has two parameters for output brightness control.
One is brightness code(base register address is 0x44). The other is
current limit(base register address is 0x22). It also provides hardware
protection like excessive current.
0 <= brightness_code <= 0xff
0 <= current_limit_code <= 0x1f, it means
5mA <= current_limit <= 30mA.
LM3633 device calculates the output current below.
(1) Linear brightness mode
Iout = current_limit * brightness_code/255
(2) Exponential brightness mode
Iout = current_limit * 0.85 ^ (44 - (brightness_code + 1)/5.18)
So output current(Iout) can not be in excess of current_limit.
>
> led-max-microamp was designed for defining max brightness limit.
> It should be converted into max brightness level in the driver and
> assigned to max_brightness property of struct led_classdev.
> This attribute overrides legacy 0-255 brightness scale.
>
It could be applied when brightness is determined by only one parameter
- current level. Flash/torch device would be a good example. In this
device, current setting is directly scaled to the output brightness.
However, LM3633 has two parameters for the brightness control - current
limit and brightness level. Max current setting is one of brightness
control parameters. In this patch, 'led-max-microamp' from DT is
converted to 'current_limit_code'. Then, this value is written once when
the driver is initialized. On the other hand, 'brightness_code' can be
changed at run time. And 'max_brightness' of led_classdev is set to max
brightness register value, 0xff.
It sounds 'led-max-microamp' property might not be a general usage in
LM3633. Do you have some idea?
Best regards,
Milo
next prev parent reply other threads:[~2015-11-11 2:16 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-02 5:24 [PATCH RESEND 00/16] Support TI LMU devices Milo Kim
2015-11-02 5:24 ` [PATCH RESEND 01/16] Documentation: dt-bindings: mfd: add TI LMU device binding information Milo Kim
2015-11-06 2:00 ` Rob Herring
2015-11-11 9:49 ` Lee Jones
2015-11-12 0:05 ` Kim, Milo
2015-11-02 5:24 ` [PATCH RESEND 02/16] Documentation: dt-bindings: backlight: add TI LMU backlight " Milo Kim
2015-11-02 15:02 ` Rob Herring
2015-11-03 7:13 ` Kim, Milo
2015-11-03 15:32 ` Rob Herring
2015-11-02 5:24 ` [PATCH RESEND 03/16] Documentation: dt-bindings: hwmon: add TI LMU HWMON " Milo Kim
2015-11-06 1:57 ` Rob Herring
2015-11-06 3:48 ` Kim, Milo
2015-11-02 5:24 ` [PATCH RESEND 04/16] Documentation: dt-bindings: leds: add LM3633 LED " Milo Kim
2015-11-03 16:15 ` Jacek Anaszewski
2015-11-10 7:01 ` Kim, Milo
2015-11-02 5:24 ` [PATCH RESEND 05/16] Documentation: dt-bindings: regulator: add LM363x regulator " Milo Kim
2015-11-02 5:24 ` [PATCH RESEND 06/16] mfd: add TI LMU driver Milo Kim
2015-11-23 10:30 ` Lee Jones
2015-11-24 2:35 ` Kim, Milo
2015-11-24 6:39 ` Kim, Milo
2015-11-24 8:18 ` Lee Jones
2015-11-25 8:10 ` Kim, Milo
2015-11-25 8:15 ` Lee Jones
2015-11-02 5:24 ` [PATCH RESEND 07/16] backlight: add TI LMU backlight common driver Milo Kim
2015-11-02 5:24 ` [PATCH RESEND 08/16] backlight: ti-lmu-backlight: add LM3532 driver Milo Kim
2015-11-02 5:37 ` kbuild test robot
2015-11-02 7:33 ` Kim, Milo
2015-11-02 5:24 ` [PATCH RESEND 09/16] backlight: ti-lmu-backlight: add LM3631 driver Milo Kim
2015-11-02 5:24 ` [PATCH RESEND 10/16] backlight: ti-lmu-backlight: add LM3632 driver Milo Kim
2015-11-02 5:24 ` [PATCH RESEND 11/16] backlight: ti-lmu-backlight: add LM3633 driver Milo Kim
2015-11-02 5:24 ` [PATCH RESEND 12/16] backlight: ti-lmu-backlight: add LM3695 driver Milo Kim
2015-11-02 5:24 ` [PATCH RESEND 13/16] backlight: ti-lmu-backlight: add LM3697 driver Milo Kim
2015-11-02 5:24 ` [PATCH RESEND 14/16] hwmon: add TI LMU hardware fault monitoring driver Milo Kim
2015-11-02 14:27 ` Guenter Roeck
2015-11-03 7:01 ` Kim, Milo
2015-11-02 5:24 ` [PATCH RESEND 15/16] leds: add LM3633 driver Milo Kim
2015-11-03 16:15 ` Jacek Anaszewski
2015-11-10 7:38 ` Kim, Milo
2015-11-10 13:44 ` Jacek Anaszewski
2015-11-11 2:16 ` Kim, Milo [this message]
2015-11-12 9:04 ` Jacek Anaszewski
2015-11-20 9:22 ` Jacek Anaszewski
2015-11-22 23:40 ` Kim, Milo
2015-11-23 11:17 ` Jacek Anaszewski
2015-11-02 5:24 ` [PATCH RESEND 16/16] regulator: add LM363X driver Milo Kim
2015-11-02 12:26 ` Mark Brown
2015-11-03 6:59 ` Kim, Milo
2015-11-04 13:59 ` Mark Brown
2015-11-10 7:54 ` Kim, Milo
2015-11-02 8:59 ` [PATCH RESEND 00/16] Support TI LMU devices Lee Jones
2015-11-03 6:52 ` Kim, Milo
2015-11-03 8:33 ` Lee Jones
2015-11-03 9:08 ` Kim, Milo
2015-11-25 8:51 ` Kim, Milo
2015-11-25 9:05 ` Lee Jones
2015-11-02 9:00 ` Lee Jones
2015-11-03 6:56 ` Kim, Milo
2015-11-03 8:35 ` Lee Jones
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=5642A4E1.8060000@ti.com \
--to=milo.kim@ti.com \
--cc=devicetree@vger.kernel.org \
--cc=j.anaszewski@samsung.com \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.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).