Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp2574818imi; Mon, 25 Jul 2022 02:18:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tzmeUpbqUyF2fwTJ17rNucHoUlKk0hafHhLf4DCHycEQXoopIEVwLjA/kytejaEIfCABr9 X-Received: by 2002:a63:d646:0:b0:41a:6c24:d829 with SMTP id d6-20020a63d646000000b0041a6c24d829mr10110477pgj.470.1658740728987; Mon, 25 Jul 2022 02:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658740728; cv=none; d=google.com; s=arc-20160816; b=a4Z9uN1KNCNQAgllBFYo05iCEXyB6pN4IHhScWGAh3J66FkyM9eu2amrd9v8CBDDqp 8G+UQs9DEeK4vaV+4EWMNGN4DXgXqxXH1wejb4HFOOM4tOq2+lrfT+8mbRPFbwCVrqnT 3ACEdXV8h5neHsC78zZNzmGPBPYST6xcG8N+B2fmVIEM8Vnho7E/z2QfPG6MUq7jXwZg QHlP24003pBH1S0n7Bx3642EvMjeYsRH85EKDNe3UlxtA+KRND2pIVYPyHicSSK4vyUb iDrKOx4Mhfeyq8of0BtPfauudRTnxloTzXH0yMOV6JS5gz8HUb6eaCEXwZsWxh9kbTts 2wFw== 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=SKEZcZKyJPxnUIHg9vM+IkXxZdZ8ejobr3a6ltkwgqg=; b=vqSlqArNl3vovzDnD5AO5RDulbswdtXSBV1HS0mKu/x4SijybgvhjeorgQnGJFfKSu ED7t25otNl+ribqWAl4+7elNPdA7rAFaM/6V99dTv+raE8xL2JhTSWFBLa5YoW9c+tKq YNGA3wFK4uwHW3maRA4gNrmoetP8VC7yq2pr2Cinw/+TGocAcym9PdN2BYKFThgYI0YH nFfWOPtvuHfm+Z6yMyQqkqAY6wKA4uNStJ5+5umtZsOtvysfKfU7DF2QjfwIxIf9Zx2x WZIngNi60ci/DR3FauURrxOY2HqaEe5ewMgH/SQtPNBElVF3JuPDvPhfWgTbxgpvYB4u JiGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SF+aqs+E; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a63454a000000b00415aacfd392si13281252pgk.576.2022.07.25.02.18.33; Mon, 25 Jul 2022 02:18:48 -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=@gmail.com header.s=20210112 header.b=SF+aqs+E; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234515AbiGYJIR (ORCPT + 99 others); Mon, 25 Jul 2022 05:08:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234169AbiGYJIP (ORCPT ); Mon, 25 Jul 2022 05:08:15 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FAB310555; Mon, 25 Jul 2022 02:08:14 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id z22so13034036edd.6; Mon, 25 Jul 2022 02:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SKEZcZKyJPxnUIHg9vM+IkXxZdZ8ejobr3a6ltkwgqg=; b=SF+aqs+EVnbsbKQkA/8xNH4ehlnunss9fmN5U1pnRWAD2EMIQ+vnoZbzG36K5peZlX CXhER1ViMJa80xFPZtY843nWQs5F1BNT454kUiXwBosjz4IYFjnLaJailn/bPKEmOYYj OQZu//AWglB0ze0HUO1SQYsIXOFhVkCy9Y+HPByleJg8LXsl2myXUq38a43P555UG4Bx W4w40So2uuPYw5I5cWqSTLAX8vR149Ik4ff+qJQus9SdkPcCLkZ3D5xoOpeLQVKUQZ8Y zppNE2E5jRpSRhv5vq/EJEOVqtSyTp9xfxGx+C2GzeLpQ8Hqwv5+/dQLpC89uzdBr14a kbDg== 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=SKEZcZKyJPxnUIHg9vM+IkXxZdZ8ejobr3a6ltkwgqg=; b=WMP0r+Teh2HRAGcBZqzf9+ZXiWOTXBwm4NQZLWVE/qZNeqLyBOMCWslXcLHqQgjG7/ UYvUr5X0LE+IYvOlM74OSmJiPwCqzJiEUEybDBZlRCmJm8pN1uvWyzZABrYrRxq72GJd nqyifhDDvTZJA/aBy4bAVnLS4/GzviEh5ImuG6oOh7Rl25vZm9c76T9h6juw9CqE74Fl s6Ze30Wwgwp0Bwr30LaA/wTAy9JkgtChBqEY04VJMxupeb+DDOQkikZimfho2d0giW4N wzEYPG3KWCFrREVI/4QSH9Jv6hYQ9jiP+Wat2B7DesHKKdoDSfqGxR/Mx7W3H27LHQJr 8SVg== X-Gm-Message-State: AJIora/LO3rc3m1iZ8cuNX07+tV846xIITdFMWo11PwhtbavJrStdhUL RVnzydnp8AC0eBmvnAN8/hg3bX8HS0G9Iei7Hag= X-Received: by 2002:a05:6402:50c9:b0:43c:163a:4d5f with SMTP id h9-20020a05640250c900b0043c163a4d5fmr1821081edb.386.1658740092120; Mon, 25 Jul 2022 02:08:12 -0700 (PDT) MIME-Version: 1.0 References: <20220722102407.2205-1-peterwu.pub@gmail.com> <20220722102407.2205-14-peterwu.pub@gmail.com> In-Reply-To: <20220722102407.2205-14-peterwu.pub@gmail.com> From: Andy Shevchenko Date: Mon, 25 Jul 2022 11:07:35 +0200 Message-ID: Subject: Re: [PATCH v6 13/13] video: backlight: mt6370: Add MediaTek MT6370 support To: ChiaEn Wu Cc: Lee Jones , Daniel Thompson , Jingoo Han , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , Sebastian Reichel , Chunfeng Yun , Greg Kroah-Hartman , Jonathan Cameron , Lars-Peter Clausen , Liam Girdwood , Mark Brown , Guenter Roeck , "Krogerus, Heikki" , Helge Deller , ChiaEn Wu , Alice Chen , cy_huang , dri-devel , Linux LED Subsystem , devicetree , linux-arm Mailing List , "moderated list:ARM/Mediatek SoC support" , Linux Kernel Mailing List , Linux PM , USB , linux-iio , "open list:FRAMEBUFFER LAYER" , szuni chen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Fri, Jul 22, 2022 at 12:25 PM ChiaEn Wu wrote: > > From: ChiaEn Wu > > MediaTek MT6370 is a SubPMIC consisting of a single cell battery charger > with ADC monitoring, RGB LEDs, dual channel flashlight, WLED backlight > driver, display bias voltage supply, one general purpose LDO, and the > USB Type-C & PD controller complies with the latest USB Type-C and PD > standards. > > This adds support for MediaTek MT6370 Backlight driver. It's commonly used Read Submitting Patches, please! (In this case, find "This patch" in the above mentioned document, read and act accordingly) > to drive the display WLED. There are 4 channels inside, and each channel > supports up to 30mA of current capability with 2048 current steps in > exponential or linear mapping curves. ... > + brightness_val[1] = (brightness - 1) >> fls(MT6370_BL_DIM2_MASK); (see below) ... > + /* > + * To make MT6372 using 14 bits to control the brightness > + * backward compatible with 11 bits brightness control > + * (like MT6370 and MT6371 do), we left shift the value > + * and pad with 1 to remaining bits. Hence, the MT6372's to the remaining > + * backlight brightness will be almost the same as MT6370's > + * and MT6371's. > + */ > + if (priv->vid_type == MT6370_VID_6372) { > + brightness_val[0] <<= MT6370_BL_DIM2_6372_SHIFT; > + brightness_val[0] |= MT6370_BL_DUMMY_6372_MASK; > + } Nice! Why not... ... > + gpiod_set_value(priv->enable_gpio, brightness ? 1 : 0); !!brightness will do as well. ... > + brightness = brightness_val[1] << fls(MT6370_BL_DIM2_MASK); > + val |= prop_val << (ffs(MT6370_BL_PWM_HYS_SEL_MASK) - 1); > + val |= ovp_uV << (ffs(MT6370_BL_OVP_SEL_MASK) - 1); > + val |= ocp_uA << (ffs(MT6370_BL_OC_SEL_MASK) - 1); > + val = prop_val << (ffs(MT6370_BL_CH_MASK) - 1); ...to use respective _SHIFTs in all these? ... > + priv->enable_gpio = devm_gpiod_get_optional(dev, "enable", > + GPIOD_OUT_HIGH); > + if (IS_ERR(priv->enable_gpio)) > + dev_err(dev, "Failed to get 'enable' gpio\n"); What does this mean? Shouldn't be return dev_err_probe()? -- With Best Regards, Andy Shevchenko