Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1167985pxb; Wed, 6 Apr 2022 10:19:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIF137z6Nps6ERvTjbuv4S2W1P4wCmlNcOVp17ILqfAJe1PmpjdEUBuXZ1NPuQ/SKmjAkM X-Received: by 2002:a17:903:120c:b0:154:c135:60d3 with SMTP id l12-20020a170903120c00b00154c13560d3mr9689599plh.48.1649265551967; Wed, 06 Apr 2022 10:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649265551; cv=none; d=google.com; s=arc-20160816; b=GMMkrltLQwGZmAjOT7r38pjjjfYpAAIUTthn7czBlNxU2VlL4wMeAg+UQ22WAyeMZA UQNICBt47Q2sLONmfgoHX9Rt9YwbOZRKTetkfPPdIhC1CZcjpCPkphpA+6KPAhvuM7Iw J03V/4Vhkv8mQuSZIWuwslZLYUhZjO72kPpkmdY7K2gWMOfFw2odAd08P/rDowcMeTlb jVEwaGlwU5SsvpqPKWDuVu4zWIudk+7iofw2JH3QtgbOLVZSPipGDpIhUsql2NSoj8y0 tw++5z16IOQrZx9kS+xKcYZgnTt4QichlbTPKGD8rhGw+mzsAvZPD2x+VH6SdPcCWGSl jHUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nKwkK10Z219eaNtTvbaclsEiamXSVs+FNo2ty5mHsKo=; b=NpJ+L2IlnPOrGgIKpfFBxQ0GeHc8U0G4PgT+ypADuQGu4UWTz/2cT5BP8jo8/Y5lj6 bVAn90gsBIE+/Fs1SD4W1R9l5Vw1PvmQuG7U0hhpvTij64CyRbPFr0PuyqY/G4hu6tIT eyKXOsHJPZ7aP/s0Psy3DxSgP9pGIu03+Xm+RAC1ZwEYtRiVTLhbK0JfqQkVmSs0yiyl WoQx5vEy7j0rkXjOYxuJDI06c9MCh7nU5dh+7svztXvxxhFf2v3uMwT1DNNEuMxObgfl 3enO7iVpQvvmORRlQkkMokkdzVHvanJVGeWzAveNAOMNTmEvLVwHNXIZZ5SbC4TWgCsL 93MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=S1op2j+c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k15-20020a63d84f000000b003816043f048si16332088pgj.573.2022.04.06.10.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 10:19:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=S1op2j+c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1ADC81CCADF; Wed, 6 Apr 2022 10:18:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238814AbiDFRUu (ORCPT + 99 others); Wed, 6 Apr 2022 13:20:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238700AbiDFRUh (ORCPT ); Wed, 6 Apr 2022 13:20:37 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E86E2CF1CA for ; Wed, 6 Apr 2022 08:18:33 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id w18so2991335edi.13 for ; Wed, 06 Apr 2022 08:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nKwkK10Z219eaNtTvbaclsEiamXSVs+FNo2ty5mHsKo=; b=S1op2j+cyW9lQWw00SOcofbFHdT3E57y5jJKpzzhgK6+y+jrtuTVbjmUjwbeu6IkUN 78P1TjwAAvLxVD0Ju8UifXumvgVrNqiVvEIVfizpxQryRR07d2Qkk+VBe+3x9DcvNQhl Lox9myyWXfC5I2yQ9jS5VmipsXUMdqstiVlkA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nKwkK10Z219eaNtTvbaclsEiamXSVs+FNo2ty5mHsKo=; b=yHqnAmK/c5i/iY6FNHXcs0rW5Qip6PrRYQyx4ImbV+UIkARMgrDjQB0e71BKRdt8XB 6mdFD60BkF3Zv0mxD1zKid7F66vxgR0SRiluB6apEyK2B/R8oV1fDHZFeQFU289f0C8u o5Rkzr4TgeMhbPBq7rI8mv7fEAdAWRQ6SJ9XBrWAFcOb8UaNjAs9chIS7bk5rS3ohYCt TB5llu6Lt/b9hykfo6UZRJ+XgHtZuc4J2KK5gwawdgQsbdtNRFFut0JvZYedunY9omLq DS5mBLCzgamC0lZtC1+GriZa9cgNOlNtXlJO0wmenKZQZb4fhdjCPqmm5gPrVtBZ7IaH VKKQ== X-Gm-Message-State: AOAM531cfIbEPD5LMF/DiMdF1yF3Wm7A1CM5+7FHpJiKwrbxKsg5Fnnt 8VYUtEC5EKH7ZPf8TkC/L9hnzjJ0d2hG8uhnMfc= X-Received: by 2002:aa7:cfda:0:b0:41c:bd28:a7da with SMTP id r26-20020aa7cfda000000b0041cbd28a7damr9210913edy.129.1649258311831; Wed, 06 Apr 2022 08:18:31 -0700 (PDT) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com. [209.85.221.52]) by smtp.gmail.com with ESMTPSA id f5-20020a17090624c500b006cee6661b6esm6706209ejb.10.2022.04.06.08.18.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Apr 2022 08:18:28 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id q19so3737401wrc.6 for ; Wed, 06 Apr 2022 08:18:26 -0700 (PDT) X-Received: by 2002:a5d:5551:0:b0:203:f916:e319 with SMTP id g17-20020a5d5551000000b00203f916e319mr7123258wrw.422.1649258305814; Wed, 06 Apr 2022 08:18:25 -0700 (PDT) MIME-Version: 1.0 References: <20220303214300.59468-1-bjorn.andersson@linaro.org> <20220303214300.59468-2-bjorn.andersson@linaro.org> In-Reply-To: From: Doug Anderson Date: Wed, 6 Apr 2022 08:18:13 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v14 2/2] leds: Add driver for Qualcomm LPG To: Pavel Machek Cc: Thierry Reding , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Lee Jones , Luca Weiss , Rob Herring , Jonathan Corbet , linux-leds@vger.kernel.org, "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , LKML , Linux Doc Mailing List , linux-pwm , linux-arm-msm , Bjorn Andersson Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Pavel, On Thu, Mar 3, 2022 at 2:10 PM Doug Anderson wrote: > > Hi, > > On Thu, Mar 3, 2022 at 1:41 PM Bjorn Andersson > wrote: > > > > The Light Pulse Generator (LPG) is a PWM-block found in a wide range of > > PMICs from Qualcomm. These PMICs typically comes with 1-8 LPG instances, > > with their output being routed to various other components, such as > > current sinks or GPIOs. > > > > Each LPG instance can operate on fixed parameters or based on a shared > > lookup-table, altering the duty cycle over time. This provides the means > > for hardware assisted transitions of LED brightness. > > > > A typical use case for the fixed parameter mode is to drive a PWM > > backlight control signal, the driver therefor allows each LPG instance > > to be exposed to the kernel either through the LED framework or the PWM > > framework. > > > > A typical use case for the LED configuration is to drive RGB LEDs in > > smartphones etc, for which the driver supports multiple channels to be > > ganged up to a MULTICOLOR LED. In this configuration the pattern > > generators will be synchronized, to allow for multi-color patterns. > > > > The idea of modelling this as a LED driver ontop of a PWM driver was > > considered, but setting the properties related to patterns does not fit > > in the PWM API. Similarly the idea of just duplicating the lower bits in > > a PWM and LED driver separately was considered, but this would not allow > > the PWM channels and LEDs to be configured on a per-board basis. The > > driver implements the more complex LED interface, and provides a PWM > > interface on the side of that, in the same driver. > > > > Signed-off-by: Bjorn Andersson > > --- > > > > Changes since v13: > > - Fixed mixed space/tab indentation in documentation > > - Added 0 as to lpg_clk_rates[] to match the hardware state, to avoid + 1 in > > lpg_apply_freq() and - 1 in lpg_pwm_get_state() > > - Don't divide with 0 if current clock is 0 in lpg_pwm_get_state(), just return > > period = duty = 0 in this case > > - Renamed "clk" in struct lpg_channel to clk_sel > > - Renamed "pre_div" in struct lpg_channel to pre_div_sel > > > > Changes since v12: > > - Initialize ret in lpg_pwm_apply() > > > > Changes since v11: > > - Extended commit message to cover decision to put pwm_chip in the LED driver > > - Added Documentation, in particular for the hw_pattern format > > - Added a lock to synchronize requests from LED and PWM frameworks > > - Turned out that the 9bit selector differs per channel in some PMICs, so > > replaced bitmask in lpg_data with lookup based on QPNP SUBTYPE > > - Fixed kerneldoc for the struct device pointer in struct lpg > > - Rewrote conditional in lut_free() to make it easier to read > > - Corrected and deduplicated max_period expression in lpg_calc_freq() > > - Extended nom/dom to numerator/denominator in lpg_calc_freq() > > - Replaced 1 << 9 with LPG_RESOLUTION in one more place in lpg_calc_freq() > > - Use FIELD_PREP() in lpg_apply_freq() as masks was introduced for reading the > > same in get_state() > > - Cleaned up the pattern format, to allow specifying both low and high pause > > with and without pingpong mode. > > - Only update frequency and pwm_value if PWM channel is enabled in lpg_pwm_apply > > - Make lpg_pwm_get_state() read the hardware state, in order to pick up e.g. > > bootloader backlight configuration > > - Use devm_bitmap_zalloc() to allocate the lut_bitmap > > - Use dev_err_probe() in lpg_probe() > > - Extended Kconfig help text to mention module name and satisfy checkpatch > > > > Documentation/leds/leds-qcom-lpg.rst | 76 ++ > > drivers/leds/Kconfig | 3 + > > drivers/leds/Makefile | 3 + > > drivers/leds/rgb/Kconfig | 18 + > > drivers/leds/rgb/Makefile | 3 + > > drivers/leds/rgb/leds-qcom-lpg.c | 1405 ++++++++++++++++++++++++++ > > 6 files changed, 1508 insertions(+) > > Gets rid of the KASAN error and PWM still works for me, so happy to add back: > > Tested-by: Douglas Anderson > > I haven't done a full review of the driver but I did a once-over of > the changes between v12 and v13 and they look good to me. With v5.18-rc1 released, this seems like it would be an ideal time to land this driver and its bindings in a for-next branch for the leds subsystem. Is there anything blocking it? Are you the right person to land them? Ideally the bindings / driver (patch #1 and #2) from Satya's series [1] could land right atop it since it's ready too? [1] https://lore.kernel.org/r/1645509309-16142-1-git-send-email-quic_c_skakit@quicinc.com/ Thanks! -Doug