mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
To: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
	kernel@oss.qualcomm.com, Lee Jones <lee@kernel.org>,
	Pavel Machek <pavel@kernel.org>,
	Fenglin Wu <quic_fenglinw@quicinc.com>
Cc: Subbaraman Narayanamurthy
	<subbaraman.narayanamurthy@oss.qualcomm.com>,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] leds: flash: leds-qcom-flash: update torch current clamp setting
Date: Mon, 28 Jul 2025 10:27:07 +0800	[thread overview]
Message-ID: <f4f46e92-3d49-4bcf-a23e-223c758f56e9@oss.qualcomm.com> (raw)
In-Reply-To: <fb79df7b-1c7b-4085-9f12-35b7cd56bb87@oss.qualcomm.com>


On 7/25/2025 8:37 PM, Konrad Dybcio wrote:
> On 7/25/25 12:04 PM, 'Fenglin Wu via B4 Relay' via kernel wrote:
>> From: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
>>
>> There is a register to clamp the flash current per LED channel when
>> safety timer is disabled. It needs to be updated according to the
>> maximum torch LED current setting to ensure the torch current won't
>> be clamped unexpectedly.
>>
>> Fixes: 96a2e242a5dc ("leds: flash: Add driver to support flash LED module in QCOM PMICs")
>> Signed-off-by: Fenglin Wu <fenglin.wu@oss.qualcomm.com>
>> ---
>>   drivers/leds/flash/leds-qcom-flash.c | 16 +++++++++++++---
>>   1 file changed, 13 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/leds/flash/leds-qcom-flash.c b/drivers/leds/flash/leds-qcom-flash.c
>> index 89cf5120f5d55bbb7e24faa8c3a946416f8fed46..9c2e41cfddcf2d50d5a633cb157084371a631d74 100644
>> --- a/drivers/leds/flash/leds-qcom-flash.c
>> +++ b/drivers/leds/flash/leds-qcom-flash.c
>> @@ -1,6 +1,6 @@
>>   // SPDX-License-Identifier: GPL-2.0-only
>>   /*
>> - * Copyright (c) 2022, 2024 Qualcomm Innovation Center, Inc. All rights reserved.
>> + * Copyright (c) 2022, 2024-2025 Qualcomm Innovation Center, Inc. All rights reserved.
>>    */
>>   
>>   #include <linux/bitfield.h>
>> @@ -111,6 +111,7 @@ enum {
>>   	REG_IRESOLUTION,
>>   	REG_CHAN_STROBE,
>>   	REG_CHAN_EN,
>> +	REG_TORCH_CLAMP,
> This is not the name of this register on at least PM8150L
The register is referred to as 'TIMER_DISA_MITIGATION_CLAMP' in the 
documentation. 'TIMER_DISA' indicates the flash module operating in 
torch mode. We can remove 'MITIGATION' to create a shorter name for the 
enum.
>
>>   	REG_THERM_THRSH1,
>>   	REG_THERM_THRSH2,
>>   	REG_THERM_THRSH3,
>> @@ -127,6 +128,7 @@ static const struct reg_field mvflash_3ch_regs[REG_MAX_COUNT] = {
>>   	REG_FIELD(0x47, 0, 5),                  /* iresolution	*/
>>   	REG_FIELD_ID(0x49, 0, 2, 3, 1),         /* chan_strobe	*/
>>   	REG_FIELD(0x4c, 0, 2),                  /* chan_en	*/
>> +	REG_FIELD(0xec, 0, 6),			/* torch_clamp	*/
> Please keep it sorted by address
I need to keep the 'therm_thrsh1/2/3' register fields at the end of this 
array because 'mvflash_4ch_regs' doesn't include a 'therm_thrsh3' 
register. Placing the 'therm_thrshx' registers in the middle would 
require creating a placeholder, which I couldn't figure out how to do 
effectively. Do you have any suggestions?
>
>
>>   	REG_FIELD(0x56, 0, 2),			/* therm_thrsh1 */
>>   	REG_FIELD(0x57, 0, 2),			/* therm_thrsh2 */
>>   	REG_FIELD(0x58, 0, 2),			/* therm_thrsh3 */
>> @@ -142,6 +144,7 @@ static const struct reg_field mvflash_4ch_regs[REG_MAX_COUNT] = {
>>   	REG_FIELD(0x49, 0, 3),			/* iresolution	*/
>>   	REG_FIELD_ID(0x4a, 0, 6, 4, 1),		/* chan_strobe	*/
>>   	REG_FIELD(0x4e, 0, 3),			/* chan_en	*/
>> +	REG_FIELD(0xed, 0, 6),			/* torch_clamp	*/
>>   	REG_FIELD(0x7a, 0, 2),			/* therm_thrsh1 */
>>   	REG_FIELD(0x78, 0, 2),			/* therm_thrsh2 */
>>   };
>> @@ -156,6 +159,7 @@ struct qcom_flash_data {
>>   	u8			max_channels;
>>   	u8			chan_en_bits;
>>   	u8			revision;
>> +	u8			torch_clamp;
>>   };
>>   
>>   struct qcom_flash_led {
>> @@ -702,6 +706,7 @@ static int qcom_flash_register_led_device(struct device *dev,
>>   	u32 current_ua, timeout_us;
>>   	u32 channels[4];
>>   	int i, rc, count;
>> +	u8 torch_clamp;
>>   
>>   	count = fwnode_property_count_u32(node, "led-sources");
>>   	if (count <= 0) {
>> @@ -751,6 +756,12 @@ static int qcom_flash_register_led_device(struct device *dev,
>>   	current_ua = min_t(u32, current_ua, TORCH_CURRENT_MAX_UA * led->chan_count);
>>   	led->max_torch_current_ma = current_ua / UA_PER_MA;
>>   
>> +	torch_clamp = (current_ua / led->chan_count) / TORCH_IRES_UA;
>> +	if (torch_clamp != 0)
>> +		torch_clamp--;
> In case anyone's wondering, ((1<<6) + 1) 4 * 5000 == 1280000 which we set
> on some (all?) devices
>
> Konrad

  parent reply	other threads:[~2025-07-28  2:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-25 10:04 [PATCH 0/2] " Fenglin Wu via B4 Relay
2025-07-25 10:04 ` [PATCH 1/2] " Fenglin Wu via B4 Relay
2025-07-25 12:37   ` Konrad Dybcio
2025-07-25 12:45     ` Konrad Dybcio
2025-07-28  2:27     ` Fenglin Wu [this message]
2025-07-28  9:18       ` Konrad Dybcio
2025-07-25 10:04 ` [PATCH 2/2] leds: flash: leds-qcom-flash: add a separate register map for PMI8998 Fenglin Wu via B4 Relay
2025-07-25 12:42   ` Konrad Dybcio

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=f4f46e92-3d49-4bcf-a23e-223c758f56e9@oss.qualcomm.com \
    --to=fenglin.wu@oss.qualcomm.com \
    --cc=kernel@oss.qualcomm.com \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=quic_fenglinw@quicinc.com \
    --cc=subbaraman.narayanamurthy@oss.qualcomm.com \
    /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

all inboxes | Powered by JetHome®