Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1839108imn; Mon, 1 Aug 2022 01:55:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1toyv6iBmB1uE2nGnR7PbvGkAkT1ZkpM1Db9BmMX6P7bUicF3cIqs30BA+m+lWIvp2Q1Y52 X-Received: by 2002:a17:906:4fc5:b0:72b:9943:6f10 with SMTP id i5-20020a1709064fc500b0072b99436f10mr11789941ejw.722.1659344148908; Mon, 01 Aug 2022 01:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659344148; cv=none; d=google.com; s=arc-20160816; b=ms8/U3lNSpwLZL8ny+QC1Fb8YsHC9ydFB45T1HlTa/Ya98lJcUZtJv2QqMzd5ZWA74 Mu3+18TVkZ6eCONfpLJWYbYcBIoEq2EYWZi7X99ZY4yr9zItW/YDX0PWSlasXUaYr4xc iCjjuQ8Y5GiDP4jXj9aMEJlV2KUIhKUxyMhjCqst3xWGm51L+kpQOP7mhh3V3mHdRR0R KK+QZqiGASEvZkV6BTZuPRbmF2nGDWnkwLkmOPZmK9xDJZIbQ/vPCfmmf8u6LiIu8rHD 9iXMlYQib2HlTDj+huHO55Et6GkCnZ5hMLU6tB7jAB074RQcMdYBy7/LuLrbCNvn4d99 YArQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=uetOwY75YdSkRkOmZ7kqjcqe6M7pgBJrux4C6ueh2dc=; b=f3L/RkXktCWqtTBlWLxwsWBG5PQnfFqIJqpuxlBPyMzcxZ3YyglzX/wRqx2VkOEbxQ 2KFiRRsXoAqjco9mnLa178IYrnPWWcy/2e6Dn45iBuYv/qb+oDwESQHYeYl6F8AiBoil 88sqbfg0Hv8OqLOgXI5mve/xEeWiiSxBCmVsM0TW3YmY6H5T7DpleXJ6oVHyOIPagbHc Q6sCt4QveOEeauO18vUowGu1KYMerBTHm35s86nW/NQNOK6ANAkfjklKLXMG1q0v0CsS CDRBeWE4uXteRQn5sHTTp+cuDWJ9grKT5CdaKol32XIVQvS6XF0SaRsS47vkDUkzOmte WwiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C29sey2y; 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 vl10-20020a170907b60a00b0072b3b1c0a90si8782743ejc.339.2022.08.01.01.55.24; Mon, 01 Aug 2022 01:55: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=C29sey2y; 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 S229878AbiHAHzV (ORCPT + 99 others); Mon, 1 Aug 2022 03:55:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbiHAHzR (ORCPT ); Mon, 1 Aug 2022 03:55:17 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 324CD25F9; Mon, 1 Aug 2022 00:55:16 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id s5-20020a17090a13c500b001f4da9ffe5fso4246095pjf.5; Mon, 01 Aug 2022 00:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=uetOwY75YdSkRkOmZ7kqjcqe6M7pgBJrux4C6ueh2dc=; b=C29sey2y0GPIrbCS1cC5P88q5AOwiJEWMKfpOhoEpoq5K3kncC1gldVs6rhVi8BtcE iIQ52S3NH1H9vx44xLKhIMn1zCf9/ERISI8EIe0uuXI9Bv5KEN2v3T+2uqHoSvRA7V+s N5npdgHtX8URJO/y2DQLFrGOLkeWM50IovV1QYdz956TMqBImdgZPZ3A1oddKDyAgGl9 FpCdWKV2uTsx/p/2x+ELaBcaGwMlhSymB13qKmhc/2GmHv36G1ysuEqdZ2C3hx304DCU 8gHdyrbT7OU85bAHV5I5dca7/J6R+PTZh/LjYR5AA0gfe1y5qlI3gvj5sPLJ7oshUIzv QLmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=uetOwY75YdSkRkOmZ7kqjcqe6M7pgBJrux4C6ueh2dc=; b=KdFJ0ArsGigTnUpmo9zD5uFCX/m4e08U7iF4VZRDENKAH8TphB70mO6bJXug7F9+ss Drq21v0UajQE8u0MTs+ViK3s0Fh5XAu9GhPm+hqBeYsGfM8MBjGPytEJQFvFUIARIUDp 7CcBtpogncqUbA1rDf9aQR+koRXDsIxawcPlCwLHnIEiivhZPcg3GAkXloKDzxgBrasc 3OQ+Hp7UeI/qu0BXv5lI5s2Hye7ht3OwA6NXLrR1BqOdKXoC7o1ysqy4GkO34Cq9Bn66 6Etx3BgbditDSLpPwkl6lnOzCZcqqT1Tc5D90gVR4AFpLr//OcE3BIOKbvFvHWSGA9HO ByAg== X-Gm-Message-State: ACgBeo06AME7zE5f1L01NVH14HQptjlJwyvQEQCNOhjzUhULKJCXXs6a 5Sm6xrrNs5rWS8JLfHLju0x+JlxKuNFPl2mzZk8= X-Received: by 2002:a17:903:268f:b0:16d:d62c:5b8b with SMTP id jf15-20020a170903268f00b0016dd62c5b8bmr13763583plb.107.1659340515630; Mon, 01 Aug 2022 00:55:15 -0700 (PDT) MIME-Version: 1.0 References: <20220722102407.2205-1-peterwu.pub@gmail.com> <20220722102407.2205-12-peterwu.pub@gmail.com> <20220730213913.GJ23307@duo.ucw.cz> In-Reply-To: <20220730213913.GJ23307@duo.ucw.cz> From: szuni chen Date: Mon, 1 Aug 2022 15:55:04 +0800 Message-ID: Subject: Re: [PATCH v6 11/13] leds: rgb: mt6370: Add MediaTek MT6370 current sink type LED Indicator support To: Pavel Machek Cc: ChiaEn Wu , Lee Jones , Daniel Thompson , Jingoo Han , 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 , Andy Shevchenko , ChiaEn Wu , Alice Chen , ChiYuan 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" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Hi Pavel, Sorry for resending the mail, I add all reviewers this time. Pavel Machek =E6=96=BC 2022=E5=B9=B47=E6=9C=8831=E6=97=A5 = =E9=80=B1=E6=97=A5 =E6=B8=85=E6=99=A85:39=E5=AF=AB=E9=81=93=EF=BC=9A > > Hi! > ... > > > +config LEDS_MT6370_RGB > > + tristate "LED Support for MediaTek MT6370 PMIC" > > + depends on MFD_MT6370 > > + select LINEAR_RANGE > > + help > > + Say Y here to enable support for MT6370_RGB LED device. > > + In MT6370, there are four channel current-sink LED drivers that > > + support hardware pattern for constant current, PWM, and breath = mode. > > > > + Isink4 channel can also be used as a CHG_VIN power good indica= tor. > > That does not really belong here. > Should we just remove it, or describe Isink4 in another position? > > +struct mt6370_priv { > > + /* Per LED access lock */ > > + struct mutex lock; > > Do we really need per-led locking? > Sorry, maybe the comment is not precise. The lock is used to prevent LEDs from accessing the HW at the same time. If I use /* LED access lock, only one LED can access the HW at the same time */ will it look better? No, we aren't. There are six steps tr1, tr2, tf1, tf2, ton, and toff in MT6370 led breath = mode. We parse duration settings from node "hw_pattern" and set them to the regis= ters. This function is used to generate duration settings from hw_pattern. The brightness of the six steps mentioned above in breath mode is limited to the node "brightness". The target brightness of tr1 and tf1 is 25% of node "brightness", and they are automatically set by HW. > > +static int mt6370_init_led_properties(struct mt6370_led *led, > > + struct led_init_data *init_data) > > +{ > > + struct mt6370_priv *priv =3D led->priv; > > + struct device *dev =3D priv->dev; > > + struct led_classdev *lcdev; > > + struct fwnode_handle *child; > > + enum mt6370_led_ranges sel_range; > > + u32 max_uA, max_level; > > + const char * const states[] =3D { "off", "keep", "on" }; > > We'd really preffer not to add "keep" / "on" support unless you need > it. > Forgive me, but I would like to know why "keep" / "on" is not preferred. We think the users might have some conditions that need them. Best Regards, Alice Pavel Machek =E6=96=BC 2022=E5=B9=B47=E6=9C=8831=E6=97=A5 = =E9=80=B1=E6=97=A5 =E6=B8=85=E6=99=A85:39=E5=AF=AB=E9=81=93=EF=BC=9A > > Hi! > > > From: ChiYuan Huang > > > > The MediaTek MT6370 is a highly-integrated smart power management IC, > > which includes a single cell Li-Ion/Li-Polymer switching battery > > charger, a USB Type-C & Power Delivery (PD) controller, dual > > Flash LED current sources, a RGB LED driver, a backlight WLED driver, > > a display bias driver and a general LDO for portable devices. > > > > In MediaTek MT6370, there are four channel current-sink RGB LEDs that > > support hardware pattern for constant current, PWM, and breath mode. > > Isink4 channel can also be used as a CHG_VIN power good indicator. > > > > > +config LEDS_MT6370_RGB > > + tristate "LED Support for MediaTek MT6370 PMIC" > > + depends on MFD_MT6370 > > + select LINEAR_RANGE > > + help > > + Say Y here to enable support for MT6370_RGB LED device. > > + In MT6370, there are four channel current-sink LED drivers that > > + support hardware pattern for constant current, PWM, and breath = mode. > > > > + Isink4 channel can also be used as a CHG_VIN power good indica= tor. > > That does not really belong here. > > > +struct mt6370_priv { > > + /* Per LED access lock */ > > + struct mutex lock; > > Do we really need per-led locking? > > > +static int mt6370_gen_breath_pattern(struct mt6370_priv *priv, > > + struct led_pattern *pattern, u32 len= , > > + u8 *pattern_val, u32 val_len) > > +{ > > + enum mt6370_led_ranges sel_range; > > + struct led_pattern *curr; > > + unsigned int sel; > > + u8 val[P_MAX_PATTERNS / 2] =3D {}; > > + int i; > > + > > + if (len < P_MAX_PATTERNS && val_len < P_MAX_PATTERNS / 2) > > + return -EINVAL; > > + > > + /* > > + * Pattern list > > + * tr1: byte 0, b'[7: 4] > > + * tr2: byte 0, b'[3: 0] > > + * tf1: byte 1, b'[7: 4] > > + * tf2: byte 1, b'[3: 0] > > + * ton: byte 2, b'[7: 4] > > + * toff: byte 2, b'[3: 0] > > + */ > > + for (i =3D 0; i < P_MAX_PATTERNS; i++) { > > + curr =3D pattern + i; > > + > > + sel_range =3D i =3D=3D P_LED_TOFF ? R_LED_TOFF : R_LED_TR= FON; > > + > > + linear_range_get_selector_within(priv->ranges + sel_range= , > > + curr->delta_t, &sel); > > + > > + val[i / 2] |=3D sel << (4 * ((i + 1) % 2)); > > + } > > + > > + memcpy(pattern_val, val, 3); > > + > > + return 0; > > +} > > I wonder how this works... you are not creating private sysfs > interface, are you? > > > +static int mt6370_init_led_properties(struct mt6370_led *led, > > + struct led_init_data *init_data) > > +{ > > + struct mt6370_priv *priv =3D led->priv; > > + struct device *dev =3D priv->dev; > > + struct led_classdev *lcdev; > > + struct fwnode_handle *child; > > + enum mt6370_led_ranges sel_range; > > + u32 max_uA, max_level; > > + const char * const states[] =3D { "off", "keep", "on" }; > > We'd really preffer not to add "keep" / "on" support unless you need > it. > > > + if (ret) > > + return dev_err_probe(dev, ret, > > + "led %d, no color sp= ecified\n", > > + led->index); > > led->LED. > > > + if (num_color < 2) > > + return dev_err_probe(dev, -EINVAL, > > + "Multicolor must include > > 2 or more led channel\n"); > > "LED channels". > > > +static int mt6370_isnk_init_default_state(struct mt6370_led *led) > > +{ > > + struct mt6370_priv *priv =3D led->priv; > > + unsigned int enable, level; > > + int ret; > > + > > + ret =3D mt6370_get_led_brightness(priv, led->index, &level); > > + if (ret) > > + return ret; > > + > > + ret =3D regmap_field_read(priv->fields[F_RGB_EN], &enable); > > + if (ret) > > + return ret; > > + > > + if (!(enable & MT6370_CHEN_BIT(led->index))) > > + level =3D LED_OFF; > > Just use 0 instead of LED_OFF. > > Best regards, > Pavel > > -- > People of Russia, stop Putin before his war on Ukraine escalates.