Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp437863rdh; Thu, 23 Nov 2023 07:58:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfZXMigfJzM+rSZRAlMTMSCco+rbHdd0w4oR8BSYZhXhbGIg+VRq1+48dJiwsWMPtg03wL X-Received: by 2002:a05:6a00:8c01:b0:6cb:8430:de32 with SMTP id ih1-20020a056a008c0100b006cb8430de32mr6475668pfb.14.1700755081698; Thu, 23 Nov 2023 07:58:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700755081; cv=none; d=google.com; s=arc-20160816; b=F1S26e4fm4OqkRFNHNez2EkPfFiPUmWgKee7AHEf+wCVuj5yWyDXCn2sZV8k4UG/06 bJi0iKlrKmZERCAygGs8XSzP5b7q7J5aL+Gj9Vmk6R3ZeMaUOQJwosmV+cw30rcgthjx fBXuqQdzUNa9kJY/X0SYQRKusXlKGFOfyfiOvlJQq97Q5vFJFhsP9DfAkdpT3EYJzUEQ LffkmCqNCSzTo3mXqzptBQwrEwNXbC/cz5pWagvR0qq1x+gIpQvdnTne3n2KkxvvOmCJ X4+C/AurwKBjkpf47WsE0qpRdG0hORR3Zqoxld6ud+tok8lsZNybsOiGE0GLYFylfGGv BmFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=X+0kQ954raIEwxTsK/csFpM9L2eiwBsmu1euzjsUdfg=; fh=6DJa8GeCffEJ4fPZiIeM4CkEyEI5DE9TxYnmNa/Tkcs=; b=xyYGK0xXrVR/0qcIIMVWc3ftpFEukMTUCsyZSQE/C7yQAYV3P42tNVucnS4BByh53f s9W751bQ0ATDIQzYcYufqNqx07N6WVwyd2/VqWBi3gPKnydKst9vyamwyoHbYABcff92 lU02Bb/kXqkHdROaFQgoojTMI1WolbRiM7+rg0yr8Z8nj83f/4lCOin5VIWyp3ySUYhA tCweNyYyAdDusoEJAVbqwzsT72zzcHDHC3PrcM4kCOv0dQuYObB4gDtKnb5SC7HcS1By +9rpX4PhmA2mLYnnRSFAsz7vGh81BSCvdLuTgMjMYr79c3xagwbXzhqwTYDWz+NkaVMk BMsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OBqS0UYj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id a38-20020a056a001d2600b006cbf1bb0b34si259936pfx.323.2023.11.23.07.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:58:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OBqS0UYj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 31A8880977A5; Thu, 23 Nov 2023 07:57:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjKWP5p (ORCPT + 99 others); Thu, 23 Nov 2023 10:57:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbjKWP5n (ORCPT ); Thu, 23 Nov 2023 10:57:43 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C9D1D4E for ; Thu, 23 Nov 2023 07:57:50 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB4EFC433C8; Thu, 23 Nov 2023 15:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700755070; bh=eG+RrbQFNYApofZ3Dfp5pt4gOAt+nrl6EHgb2YJxdrU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OBqS0UYjbrW4w7H2l0g2mkGHCx71WwN2p9tQjbNCQKf9eTnyrj/d12RzblQGjOWz0 /VKtkI7XjGkI+LEkBvkXOjh7muXuQxtbqdPAYgG/bLn1D+OgXIptn89LIfxG3RRxTX YB3llOi0/VvVkXR9AVRbyTko4j75/5hrnS9K2Z9YZC0NEIp/YgljH4gLYT+i0AFcKX cEV+Na7fe82TeUhX5E2FVTNs5wGPbTmr7UwfmZC6zIbluVTx2BsGeABGym7gM1v5Nw mXHTwvqBbgitR7ISk31u3GxZvy7r4i0Mp/UiIkxZPDf5LwAjCzYCMlZgj6pKSdEa7i WLXxIV8R/MWGg== Date: Thu, 23 Nov 2023 15:57:44 +0000 From: Lee Jones To: Dmitry Rokosov Cc: pavel@ucw.cz, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, andy.shevchenko@gmail.com, kernel@sberdevices.ru, rockosov@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [PATCH v4 02/11] leds: aw200xx: support HWEN hardware control Message-ID: <20231123155744.GE1354538@google.com> References: <20231121202835.28152-1-ddrokosov@salutedevices.com> <20231121202835.28152-3-ddrokosov@salutedevices.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231121202835.28152-3-ddrokosov@salutedevices.com> X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 23 Nov 2023 07:57:59 -0800 (PST) On Tue, 21 Nov 2023, Dmitry Rokosov wrote: > HWEN is hardware control, which is used for enable/disable aw200xx chip. > It's high active, internally pulled down to GND. > > After HWEN pin set high the chip begins to load the OTP information, > which takes 200us to complete. About 200us wait time is needed for > internal oscillator startup and display SRAM initialization. After > display SRAM initialization, the registers in page 1 to page 5 can be > configured via i2c interface. > > Signed-off-by: Dmitry Rokosov > Reviewed-by: Andy Shevchenko > --- > drivers/leds/leds-aw200xx.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/drivers/leds/leds-aw200xx.c b/drivers/leds/leds-aw200xx.c > index 842a22087b16..7762b3a132ac 100644 > --- a/drivers/leds/leds-aw200xx.c > +++ b/drivers/leds/leds-aw200xx.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -116,6 +117,7 @@ struct aw200xx { > struct mutex mutex; > u32 num_leds; > u32 display_rows; > + struct gpio_desc *hwen; > struct aw200xx_led leds[] __counted_by(num_leds); > }; > > @@ -358,6 +360,25 @@ static int aw200xx_chip_check(const struct aw200xx *const chip) > return 0; > } > > +static void aw200xx_enable(const struct aw200xx *const chip) > +{ > + gpiod_set_value_cansleep(chip->hwen, 1); > + > + /* > + * After HWEN pin set high the chip begins to load the OTP information, > + * which takes 200us to complete. About 200us wait time is needed for > + * internal oscillator startup and display SRAM initialization. After > + * display SRAM initialization, the registers in page1 to page5 can be > + * configured via i2c interface. > + */ > + fsleep(400); > +} > + > +static void aw200xx_disable(const struct aw200xx *const chip) > +{ > + return gpiod_set_value_cansleep(chip->hwen, 0); > +} > + > static int aw200xx_probe_fw(struct device *dev, struct aw200xx *chip) > { > struct fwnode_handle *child; > @@ -517,6 +538,14 @@ static int aw200xx_probe(struct i2c_client *client) > if (IS_ERR(chip->regmap)) > return PTR_ERR(chip->regmap); > > + chip->hwen = devm_gpiod_get_optional(&client->dev, "enable", > + GPIOD_OUT_HIGH); > + if (IS_ERR(chip->hwen)) > + return dev_err_probe(&client->dev, PTR_ERR(chip->hwen), > + "Cannot get enable gpio"); Nit: "GPIO" > + > + aw200xx_enable(chip); > + > ret = aw200xx_chip_check(chip); > if (ret) > return ret; > @@ -537,6 +566,9 @@ static int aw200xx_probe(struct i2c_client *client) > ret = aw200xx_chip_init(chip); > > out_unlock: > + if (ret) > + aw200xx_disable(chip); > + > mutex_unlock(&chip->mutex); > return ret; > } > @@ -546,6 +578,7 @@ static void aw200xx_remove(struct i2c_client *client) > struct aw200xx *chip = i2c_get_clientdata(client); > > aw200xx_chip_reset(chip); > + aw200xx_disable(chip); > mutex_destroy(&chip->mutex); > } > > -- > 2.36.0 > -- Lee Jones [李琼斯]