All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacek Anaszewski <jacek.anaszewski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Milo Kim <milo.kim-l0cyMroinI0@public.gmane.org>
Cc: Jacek Anaszewski
	<j.anaszewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-leds-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 8/9] leds: add LM3633 driver
Date: Sat, 28 Nov 2015 09:28:40 +0100	[thread overview]
Message-ID: <565965B8.9020507@gmail.com> (raw)
In-Reply-To: <56583C37.1050307-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

On 11/27/2015 12:19 PM, Jacek Anaszewski wrote:
> Hi Milo,
>
> Thanks for the update. I have few comments below.
>
[...]
>> +static u8 lm3633_led_scale_max_brightness(struct ti_lmu_led *lmu_led,
>> u32 imax)
>> +{
>> +    u8 max_current = lm3633_led_convert_current_to_index(imax);
>> +    const u8 max_brightness_table[] = {
>> +        [LMU_IMAX_5mA]  = 191,
>> +        [LMU_IMAX_6mA]  = 197,
>> +        [LMU_IMAX_7mA]  = 203,
>> +        [LMU_IMAX_8mA]  = 208,
>> +        [LMU_IMAX_9mA]  = 212,
>> +        [LMU_IMAX_10mA] = 216,
>> +        [LMU_IMAX_11mA] = 219,
>> +        [LMU_IMAX_12mA] = 222,
>> +        [LMU_IMAX_13mA] = 225,
>> +        [LMU_IMAX_14mA] = 228,
>> +        [LMU_IMAX_15mA] = 230,
>> +        [LMU_IMAX_16mA] = 233,
>> +        [LMU_IMAX_17mA] = 235,
>> +        [LMU_IMAX_18mA] = 237,
>> +        [LMU_IMAX_19mA] = 239,
>> +        [LMU_IMAX_20mA] = 241,
>> +        [LMU_IMAX_21mA] = 242,
>> +        [LMU_IMAX_22mA] = 244,
>> +        [LMU_IMAX_23mA] = 246,
>> +        [LMU_IMAX_24mA] = 247,
>> +        [LMU_IMAX_25mA] = 249,
>> +        [LMU_IMAX_26mA] = 250,
>> +        [LMU_IMAX_27mA] = 251,
>> +        [LMU_IMAX_28mA] = 253,
>> +        [LMU_IMAX_29mA] = 254,
>> +        [LMU_IMAX_30mA] = 255,
>> +    };
>
> After analyzing the subject one more time I think that we need to
> change the approach regarding max brightness issue.
>
> At first - we shouldn't fix max current to max possible register value.
> Instead we should take led-max-microamp property and write its value
> to the [0x22 + bank offset] registers.

It was of course a mental shortcut. The value to write should be
calculated by transforming the formula given next to the register
documentation:

11111 = 29.8 mA
0.8mA steps, FS = 5mA + code * 0.8 mA

code is here the [0x22 + bank_offset] register value.

Effectively, the formula to calculate the register value basing
on led-max-microamp value should be:

FS = led-max-microamp - 5000 / 800

E.g. for 20.2 mA:

FS = (20200 - 5000) / 800 = 19

for 29.8 mA:

FS = (29800 - 5000) / 800 = 31

for 5 mA:

FS = (5000 - 5000) / 800 = 0

 From the above min, max and step values for led-max-microamp
are 5000, 29800 and 800 respectively. Please correct DT documentation
accordingly.

> With this approach whole 0-255 range of brightness levels will be
> valid for the driver.
>
> In effect all LMU_IMAX* enums seem to be not needed.


-- 
Best Regards,
Jacek Anaszewski
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Milo Kim <milo.kim@ti.com>
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>,
	robh+dt@kernel.org, lee.jones@linaro.org, broonie@kernel.org,
	devicetree@vger.kernel.org, linux-leds@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 8/9] leds: add LM3633 driver
Date: Sat, 28 Nov 2015 09:28:40 +0100	[thread overview]
Message-ID: <565965B8.9020507@gmail.com> (raw)
In-Reply-To: <56583C37.1050307@samsung.com>

On 11/27/2015 12:19 PM, Jacek Anaszewski wrote:
> Hi Milo,
>
> Thanks for the update. I have few comments below.
>
[...]
>> +static u8 lm3633_led_scale_max_brightness(struct ti_lmu_led *lmu_led,
>> u32 imax)
>> +{
>> +    u8 max_current = lm3633_led_convert_current_to_index(imax);
>> +    const u8 max_brightness_table[] = {
>> +        [LMU_IMAX_5mA]  = 191,
>> +        [LMU_IMAX_6mA]  = 197,
>> +        [LMU_IMAX_7mA]  = 203,
>> +        [LMU_IMAX_8mA]  = 208,
>> +        [LMU_IMAX_9mA]  = 212,
>> +        [LMU_IMAX_10mA] = 216,
>> +        [LMU_IMAX_11mA] = 219,
>> +        [LMU_IMAX_12mA] = 222,
>> +        [LMU_IMAX_13mA] = 225,
>> +        [LMU_IMAX_14mA] = 228,
>> +        [LMU_IMAX_15mA] = 230,
>> +        [LMU_IMAX_16mA] = 233,
>> +        [LMU_IMAX_17mA] = 235,
>> +        [LMU_IMAX_18mA] = 237,
>> +        [LMU_IMAX_19mA] = 239,
>> +        [LMU_IMAX_20mA] = 241,
>> +        [LMU_IMAX_21mA] = 242,
>> +        [LMU_IMAX_22mA] = 244,
>> +        [LMU_IMAX_23mA] = 246,
>> +        [LMU_IMAX_24mA] = 247,
>> +        [LMU_IMAX_25mA] = 249,
>> +        [LMU_IMAX_26mA] = 250,
>> +        [LMU_IMAX_27mA] = 251,
>> +        [LMU_IMAX_28mA] = 253,
>> +        [LMU_IMAX_29mA] = 254,
>> +        [LMU_IMAX_30mA] = 255,
>> +    };
>
> After analyzing the subject one more time I think that we need to
> change the approach regarding max brightness issue.
>
> At first - we shouldn't fix max current to max possible register value.
> Instead we should take led-max-microamp property and write its value
> to the [0x22 + bank offset] registers.

It was of course a mental shortcut. The value to write should be
calculated by transforming the formula given next to the register
documentation:

11111 = 29.8 mA
0.8mA steps, FS = 5mA + code * 0.8 mA

code is here the [0x22 + bank_offset] register value.

Effectively, the formula to calculate the register value basing
on led-max-microamp value should be:

FS = led-max-microamp - 5000 / 800

E.g. for 20.2 mA:

FS = (20200 - 5000) / 800 = 19

for 29.8 mA:

FS = (29800 - 5000) / 800 = 31

for 5 mA:

FS = (5000 - 5000) / 800 = 0

 From the above min, max and step values for led-max-microamp
are 5000, 29800 and 800 respectively. Please correct DT documentation
accordingly.

> With this approach whole 0-255 range of brightness levels will be
> valid for the driver.
>
> In effect all LMU_IMAX* enums seem to be not needed.


-- 
Best Regards,
Jacek Anaszewski

  parent reply	other threads:[~2015-11-28  8:28 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-26  6:56 [PATCH v2 0/9] Support TI LMU devices Milo Kim
2015-11-26  6:56 ` Milo Kim
2015-11-26  6:56 ` [PATCH v2 1/9] Documentation: dt-bindings: mfd: add TI LMU device binding information Milo Kim
2015-11-26  6:56   ` Milo Kim
2015-11-27 20:55   ` Rob Herring
2016-01-11  9:46   ` Lee Jones
2015-11-26  6:56 ` [PATCH v2 2/9] Documentation: dt-bindings: leds: backlight: add TI LMU backlight " Milo Kim
2015-11-26  6:56   ` Milo Kim
2016-01-11  9:53   ` Lee Jones
2015-11-26  6:56 ` [PATCH v2 3/9] Documentation: dt-bindings: leds: add LM3633 LED " Milo Kim
2015-11-26  6:56   ` Milo Kim
2015-11-27 11:19   ` Jacek Anaszewski
2015-11-30  8:19     ` Kim, Milo
2015-11-30  8:19       ` Kim, Milo
2015-11-30 12:26       ` Jacek Anaszewski
     [not found]         ` <565C408B.9070703-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-12-07  8:46           ` Kim, Milo
2015-12-07  8:46             ` Kim, Milo
2015-12-07 10:50             ` Jacek Anaszewski
2015-11-26  6:57 ` [PATCH v2 4/9] Documentation: dt-bindings: regulator: add LM363x regulator " Milo Kim
2015-11-26  6:57   ` Milo Kim
2015-11-27 12:37   ` Mark Brown
2015-11-27 20:44     ` Rob Herring
2015-11-27 22:07       ` Mark Brown
2015-11-27 12:55   ` Applied "regulator: lm363x: add LM363x regulator binding information" to the regulator tree Mark Brown
2015-11-27 20:57   ` [PATCH v2 4/9] Documentation: dt-bindings: regulator: add LM363x regulator binding information Rob Herring
2015-11-26  6:57 ` [PATCH v2 5/9] mfd: add TI LMU driver Milo Kim
2015-11-26  6:57   ` Milo Kim
2016-01-11 10:17   ` Lee Jones
2015-11-26  6:57 ` [PATCH v2 6/9] mfd: add TI LMU hardware fault monitoring driver Milo Kim
2015-11-26  6:57   ` Milo Kim
2016-01-11 10:21   ` Lee Jones
2016-01-12  3:36     ` Milo Kim
2016-01-12  3:36       ` Milo Kim
2016-01-12  7:37       ` Lee Jones
2015-11-26  6:57 ` [PATCH v2 7/9] backlight: add TI LMU backlight driver Milo Kim
2015-11-26  6:57   ` Milo Kim
2016-01-11  9:57   ` Lee Jones
2016-01-11 23:32     ` Milo Kim
2016-01-11 23:32       ` Milo Kim
2015-11-26  6:57 ` [PATCH v2 8/9] leds: add LM3633 driver Milo Kim
2015-11-26  6:57   ` Milo Kim
2015-11-27 11:19   ` Jacek Anaszewski
     [not found]     ` <56583C37.1050307-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-11-28  8:28       ` Jacek Anaszewski [this message]
2015-11-28  8:28         ` Jacek Anaszewski
2015-11-30  8:48     ` Kim, Milo
2015-11-30  8:48       ` Kim, Milo
2015-11-30 12:26       ` Jacek Anaszewski
2015-11-26  6:57 ` [PATCH v2 9/9] regulator: add LM363X driver Milo Kim
2015-11-26  6:57   ` Milo Kim
2015-11-27 12:55   ` Applied "regulator: add LM363X driver" to the regulator tree Mark Brown
2016-01-14  7:56   ` [PATCH v2 9/9] regulator: add LM363X driver Milo Kim
2016-01-14  7:56     ` Milo Kim
     [not found]     ` <56975493.7050900-l0cyMroinI0@public.gmane.org>
2016-01-14 10:27       ` Mark Brown
2016-01-14 10:27         ` Mark Brown
2016-01-14 23:41         ` Kim, Milo
2016-01-14 23:41           ` Kim, Milo
2016-01-06  7:20 ` [PATCH v2 0/9] Support TI LMU devices Milo Kim
2016-01-06  7:20   ` Milo Kim

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=565965B8.9020507@gmail.com \
    --to=jacek.anaszewski-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=j.anaszewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-leds-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=milo.kim-l0cyMroinI0@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.