From patchwork Sun May 7 17:29:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Van Assche X-Patchwork-Id: 90861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1683152vqo; Sun, 7 May 2023 10:34:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EzK+fcPZsZPq4hvcVCFacNCZ2ZkXMyuiPfO/bKumm5FdxFSBK1FY/3gXW1jheACeUX4tA X-Received: by 2002:a05:6a00:234a:b0:643:bae4:38cb with SMTP id j10-20020a056a00234a00b00643bae438cbmr6601438pfj.0.1683480840887; Sun, 07 May 2023 10:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683480840; cv=none; d=google.com; s=arc-20160816; b=a38BBtGWPidMwsOGyT95949jMsyQwZxD9DTI6c86AEJ+Zs/8q802HztO8rn5WAlyAP v7FlF/WycXWiHDCMbBrXQpVgSVBEe2l7kb4q2YltZY3crzsOeC3/7MMhktZkxLKhK5rL qmGBwWpC1oJ4aJ6tLAxAHkGjPkhEnnsNsgbR2UKk+LuoQtwXNCYu2jJuykcJrnL3Kcr6 0DwQPwsvXWuWBBJVkZ7SoAkFT4NpSp3OU/oyS1y64f5CP5I/bXAK6JviXNIhzwPa5hBM MSYTcEXC61ZE2CpferHupeSbIPPFC+xas1zgV9sp0+b7VKjtbO5pbeG1zGOkI2Z+jzjB bo7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aUNWYjPvRY3lglH0hDFmfodPM+n7chzcxW6kg3/6LfI=; b=YV2Eq9WMo7Wo8n+wgg2rQSks3YzbKgKKiAd8F2o5hgmYYT6xKf4LG2TqaOyQKHRdre 59dHq8wMVmss/5PPMTEiEIUhQX1/u3YdLYWYNFV1hYsBktE/5EDfy6IVLSLUBpygZAFR HkBLmoAWHksm1biouDACirQlsfNzVCH2llyXHb2hIaMm/SHiqtiWgb9ycxwgRswuRgpw ygijq5//ZfoKteuDPgX4eNrm1zo0OFTJjg8EntXPXdRf2OnDfZoAyorvMEuUOVZIplko 9rNe+CRtcdtx735op//drPr+ZClqcdrojG4LwPF3Uj6HmXiHOT2vpZERKm10a3rQaLQZ +b9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=KTFFxryD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a63380c000000b005034a5a0a58si6477811pga.434.2023.05.07.10.33.48; Sun, 07 May 2023 10:34:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=KTFFxryD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229533AbjEGRcG (ORCPT + 99 others); Sun, 7 May 2023 13:32:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231684AbjEGRcE (ORCPT ); Sun, 7 May 2023 13:32:04 -0400 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FF1593E5; Sun, 7 May 2023 10:31:59 -0700 (PDT) Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4QDs183w6jz9snM; Sun, 7 May 2023 19:31:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dylanvanassche.be; s=MBO0001; t=1683480716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aUNWYjPvRY3lglH0hDFmfodPM+n7chzcxW6kg3/6LfI=; b=KTFFxryD5VQyhohjZxWvZwi1w/B0DoIXUkkKbJ6vjc9uwiEh979A+SLyMJngN+kKVTE+ua axtNj5xpOKbtSMczys/eoYxbKDKmkuRl+0ICqL0MKM6zKZPMmenYd7+GMu/4WXUfHamNxX bgq5WgIl0n3MqjTsNua5qIxBEkbALNkK24QA2a3DlWPsZ1Fi7+qg3Aog1MqdaTd/S13Cdv HL5JRXO1F5a3fU/OtCTOwaNXngJhfG6oRs9GcjSiN213iThAHMrqMRZhDIHIpRrlYJxJKI G9e/BqJb25xn2hIjtvT6ua8WTTfAFU3IvCkyHD9r6+2QcAoxDcsCg77eGdbccA== From: Dylan Van Assche To: pavel@ucw.cz, quic_fenglinw@quicinc.com, lee@kernel.org Cc: trix@redhat.com, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Dylan Van Assche Subject: [PATCH 1/2] leds: flash: leds-qcom-flash: add PMI8998 support Date: Sun, 7 May 2023 19:29:40 +0200 Message-Id: <20230507172941.364852-2-me@dylanvanassche.be> In-Reply-To: <20230507172941.364852-1-me@dylanvanassche.be> References: <20230507172941.364852-1-me@dylanvanassche.be> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765257568475684518?= X-GMAIL-MSGID: =?utf-8?q?1765257606158050562?= Add subtype for the Qualcomm PMI8998 PMIC to support it besides the PM8150 PMIC which has the same registers. Adjust the driver to recognize both PMIC subtypes as a 3 channel LED driver. Signed-off-by: Dylan Van Assche --- drivers/leds/flash/leds-qcom-flash.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/leds/flash/leds-qcom-flash.c b/drivers/leds/flash/leds-qcom-flash.c index 90a24fa25a49..16045b5d89b1 100644 --- a/drivers/leds/flash/leds-qcom-flash.c +++ b/drivers/leds/flash/leds-qcom-flash.c @@ -18,7 +18,8 @@ #define FLASH_TYPE_VAL 0x18 #define FLASH_SUBTYPE_REG 0x05 -#define FLASH_SUBTYPE_3CH_VAL 0x04 +#define FLASH_SUBTYPE_3CH_PM8150_VAL 0x04 +#define FLASH_SUBTYPE_3CH_PMI8998_VAL 0x03 #define FLASH_SUBTYPE_4CH_VAL 0x07 #define FLASH_STS_3CH_OTST1 BIT(0) @@ -682,7 +683,7 @@ static int qcom_flash_led_probe(struct platform_device *pdev) return rc; } - if (val == FLASH_SUBTYPE_3CH_VAL) { + if (val == FLASH_SUBTYPE_3CH_PM8150_VAL || val == FLASH_SUBTYPE_3CH_PMI8998_VAL) { flash_data->hw_type = QCOM_MVFLASH_3CH; flash_data->max_channels = 3; regs = mvflash_3ch_regs; From patchwork Sun May 7 17:29:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Van Assche X-Patchwork-Id: 90862 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1683298vqo; Sun, 7 May 2023 10:34:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4rBNJbrA0UA4jes1gi4l7b72/dG/ZwdHAhx6UDw9TGTZd6ZDQoMqnmEkf5sfiP2sdhbE+l X-Received: by 2002:a17:90b:4a84:b0:24d:dcbb:6307 with SMTP id lp4-20020a17090b4a8400b0024ddcbb6307mr9344088pjb.6.1683480867703; Sun, 07 May 2023 10:34:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683480867; cv=none; d=google.com; s=arc-20160816; b=Eos3R0vGFIjlOdvgP4VRunlN6m2WfMa0vYilF0jLiYBbQbsAi2TrobghFpKQGAq+oD s3Vx7SDrih+Mgt9UbYwNuKWXd/SufU+P80eV8puRIh2n/U3G5+7WVxek36oPy7q4x+ZM lZSLwM2LDEyh7A9x6h2jbgB9gcxZ/lx5u1/QsYJ9Pmm1RgB/wXaV8/RpQSLNnxRYfaJT oHcrhPRv6X8eNim7itY2gCe+mlttc6XFemFtuqreAt+uuINNwS0GIGtLtSKSgGfJrsXp 7IhSjhdH9bd3IkP8fnqkO1py3aXPD7OSjB2+2wt5KPeoC2mu4eFDys9sRn7fLSiBJLX5 8oug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SQHQgsnbPJTgsXPCqG4AqQGuAPuZsFrH5o3VxE1rTc4=; b=1J8y3ZkNS/z+GBDBJsl4LoE2xogsnWCCrojkhx+wfbmIEdUAqFuy2U4E7+/8aWOBdy HTRBs+OEz3CT9p/Rxwbvrpp62wGK8WF5W9fkGOsvEE3vsN7JxtqWCCwWu3zMpXBO4S8b iPj+Abp8ZweD3tt4CQ0EiDS+23VcH0h6JvIC2XHX+KkmkigsUqtnF3l0crihcePUIwab s4ktZPITA/eHoYilFQwwZmu3r/ZLQdQ40UL8OwfzMIleLQpOBuv6GVY3jqBunOdeKxso jpkj+EqpFhP5+UE2vwmSvR5hpx479MhMXnA8w+BqVU2wOx52eFex2kv/OwyTwe7AjFFJ PJ/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=L8DHt6oq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn16-20020a17090b38d000b00246a5991cc6si24998319pjb.162.2023.05.07.10.34.15; Sun, 07 May 2023 10:34:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=L8DHt6oq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231787AbjEGRcJ (ORCPT + 99 others); Sun, 7 May 2023 13:32:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231686AbjEGRcF (ORCPT ); Sun, 7 May 2023 13:32:05 -0400 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FF1A1BD1; Sun, 7 May 2023 10:32:01 -0700 (PDT) Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4QDs1B61f7z9skr; Sun, 7 May 2023 19:31:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dylanvanassche.be; s=MBO0001; t=1683480718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SQHQgsnbPJTgsXPCqG4AqQGuAPuZsFrH5o3VxE1rTc4=; b=L8DHt6oqMQ8+MSjhjgvR8ROjEp/xzp//i4ahR1oot9wJb9ksy9p4mq7TVNSDmY2bjQffzU 6PyzNP/QvBRbBiXG2THMOqGShi6WG5B7bTACe2E3Ew4b+GTYPzawtWWKe41tQBA1qZn33/ P2kW/icoEIwE3GyDua1Hmep0/3lRWUZ9c8qNlgMbDP/CdAMNjUEzo2IfBR3VWmAs3lZXZV 5pg6FsY0mGznF5gKGBvmXpDavzgcnwGuadaCdgRwvn5Dw6EBo51DyiibPGjxq6WgAe9Z3T LpWi0Sh1FM7IdQBqjL6FwrOI2wMAAOnzxSiKNGPl3qjEwyibISoTU/mobYdAqQ== From: Dylan Van Assche To: pavel@ucw.cz, quic_fenglinw@quicinc.com, lee@kernel.org Cc: trix@redhat.com, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Dylan Van Assche Subject: [PATCH 2/2] leds: flash: leds-qcom-flash: disable LED when changing brightness Date: Sun, 7 May 2023 19:29:41 +0200 Message-Id: <20230507172941.364852-3-me@dylanvanassche.be> In-Reply-To: <20230507172941.364852-1-me@dylanvanassche.be> References: <20230507172941.364852-1-me@dylanvanassche.be> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765257634410492627?= X-GMAIL-MSGID: =?utf-8?q?1765257634410492627?= The Qualcomm PMI8998 PMIC requires the LED to be disabled when configuring the brightness. Always disable the LED when setting the brightness and re-enable it afterwards. Signed-off-by: Dylan Van Assche --- drivers/leds/flash/leds-qcom-flash.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/leds/flash/leds-qcom-flash.c b/drivers/leds/flash/leds-qcom-flash.c index 16045b5d89b1..c8d41a3caf38 100644 --- a/drivers/leds/flash/leds-qcom-flash.c +++ b/drivers/leds/flash/leds-qcom-flash.c @@ -417,6 +417,14 @@ static int qcom_flash_led_brightness_set(struct led_classdev *led_cdev, bool enable = !!brightness; int rc; + rc = set_flash_strobe(led, SW_STROBE, false); + if (rc) + return rc; + + rc = set_flash_module_en(led, false); + if (rc) + return rc; + rc = set_flash_current(led, current_ma, TORCH_MODE); if (rc) return rc;