From patchwork Tue Aug 3 16:26:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Patchwork-Id: 12416731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34F29C4338F for ; Tue, 3 Aug 2021 16:29:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3A8260243 for ; Tue, 3 Aug 2021 16:29:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F3A8260243 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=DAdGvsD91CrEJoqzAu9R7do7kB+sPMkjpnyWUtHPlGI=; b=1Sw9wTjl3TS8ZG Km6gVniMRKfWiGk7uyor4hEW9aTyY8swtvIHsu7WpuDEKE1Lypvj4r8uR8NybEEQElNF2fn9auOf5 wEFg1gQDYCwlpA/jFpP32gyTTJZKxEv645DI+oeXJsJdvB33IExEHmRTZSJZednv+dy+8L+sEQ3T/ FtYSI47YL8pAKcjaqf/yj1x0ngsi/+OtVR77GqxNVzOFfdRMMC8PFV6tL1QXPaWTDkSfR0JvP9wPf OqNvg692LgnXqEMBLb90AJoTJZRNikYyVbwxMc/x7ek2vLVWwT8OviQqN+DcrSqx6/bf2tXPqgz7p Wh9Tor+xchSsP2FvnwfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAxG3-003bl2-Oh; Tue, 03 Aug 2021 16:27:11 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAxFz-003bjI-0D for linux-arm-kernel@lists.infradead.org; Tue, 03 Aug 2021 16:27:09 +0000 Received: from localhost.localdomain (unknown [IPv6:2804:14c:1a9:2434:b693:c9:5cb6:b688]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: nfraprado) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id E52D11F423A5; Tue, 3 Aug 2021 17:26:57 +0100 (BST) From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= To: Pavel Machek , Dan Murphy , Bjorn Andersson , Andy Gross , Rob Herring , Jacek Anaszewski Cc: linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Brian Masney , Luca Weiss , Russell King , Georgi Djakov , linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, ~lkcamp/patches@lists.sr.ht, =?utf-8?q?Andr=C3=A9_Almeida?= , kernel@collabora.com Subject: [PATCH v3 0/5] Add support for QCOM SPMI Flash LEDs Date: Tue, 3 Aug 2021 13:26:36 -0300 Message-Id: <20210803162641.1525980-1-nfraprado@collabora.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210803_092707_303561_5D65D072 X-CRM114-Status: GOOD ( 20.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, this patch series adds support for Qualcomm's SPMI Flash LEDs present in the PM8941 PMIC. It is used as part of MSM8974 based devices, like the Nexus 5 (hammerhead), as a camera flash or as a lantern when in torch mode. The driver code is based on the parts of the QPNP LEDs driver from downstream [1] that handled the flash LED. This hardware doesn't have any publicly available documentation, so all my knowledge about its behavior came from reading the downstream driver code and from inspecting the SPMI registers used for the LED operations. I have collected my findings at [2]. Bjorn, Jacek and Pavel, big thanks for your review in v2. I didn't answer the emails but I believe I addressed all of the feedback you gave me. Sorry for the long delay, I'll try to actually answer the feedback this time, and in a timely manner too. The changes in this v3 are too many to list, but the biggest ones were: - The two LEDs can now be operated independently even when in torch mode - The flashes can now strobe consecutive times without needing to manually disable them between strobes - Implemented strobe_get() - Moved dt parsing to a separate function - Split multiplexed torch/flash on/off and torch/flash regulator on/off functions - Removed configurations from the dt-binding that didn't have any visible impact, instead hardcoding them inside the driver - Moved LED dt nodes configuration to hammerhead dts - Set current on brightness callback and timeout on timeout callback, instead of setting everything every time when strobing/turning torch on Fault detection and V4L2 flash wrapper support are still missing but, as others have pointed out before, they can be implemented later if desired. Thanks, NĂ­colas v2: https://lore.kernel.org/linux-arm-msm/20210126140240.1517044-1-nfraprado@protonmail.com/ v1 RFC: https://lore.kernel.org/linux-arm-msm/20201106165737.1029106-1-nfraprado@protonmail.com/ [1] https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/drivers/leds/leds-qpnp.c [2] https://gitlab.collabora.com/nfraprado/linux/-/wikis/PM8941-Flash-LEDs NĂ­colas F. R. A. Prado (5): dt-bindings: leds: Add binding for qcom-spmi-flash leds: Add driver for QCOM SPMI Flash LEDs ARM: qcom_defconfig: Enable QCOM SPMI Flash LEDs ARM: dts: qcom: pm8941: Add nodes for QCOM SPMI Flash LEDs ARM: dts: qcom: msm8974-hammerhead: Enable and configure flash LED node .../bindings/leds/leds-qcom-spmi-flash.yaml | 93 ++ .../qcom-msm8974-lge-nexus5-hammerhead.dts | 20 + arch/arm/boot/dts/qcom-pm8941.dtsi | 25 + arch/arm/configs/qcom_defconfig | 2 + drivers/leds/flash/Kconfig | 8 + drivers/leds/flash/Makefile | 1 + drivers/leds/flash/leds-qcom-spmi-flash.c | 1251 +++++++++++++++++ 7 files changed, 1400 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-qcom-spmi-flash.yaml create mode 100644 drivers/leds/flash/leds-qcom-spmi-flash.c