From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E7DACC2BA1A for ; Thu, 20 Jun 2024 15:38:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To :Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=s+h387lf4ounMi+iVhkJYXBLUErzSRJimx+T0EIiAWQ=; b=CA7BQu4Oszo8RWuLcRT4BRwEwx yUK7XRpMze3xeJoBXaOoPOonsErCjoWSNnmUqG2icEKO2KMKoVtQ2wTHueb+w0MJT56fCH7fc4h1D vKkyLjo6JfJPkPYGW0BsNpAEMUSkNmDfKsh9UPOy7+4QexUWDmFyTOI78+e8hSI+BOoJqTswj56ME ZMh58jiGaR2lmY/Dep1n8G3UEaQ36u5UwbK73vQewHjGMUq5WBpCkeTvIM4tkF7SJZr7cx9tw4Ha6 m+RVTYHlgareyakCpWHhvC07SoyRSq4qHEgvwaX6o1ZeEGe2DdhOpcpgJK97PfLBaDsqZ69FlZYJS LMvGdErA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKJrA-00000005f5M-1C56; Thu, 20 Jun 2024 15:37:48 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKJr6-00000005f4L-38UC for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2024 15:37:46 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7064afd7011so331917b3a.1 for ; Thu, 20 Jun 2024 08:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718897864; x=1719502664; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=s+h387lf4ounMi+iVhkJYXBLUErzSRJimx+T0EIiAWQ=; b=FkpldwX75zWQiNpL2VIYHjx56MCBnMkBfbicMDSpNMN/ktiQ3CHGPfojwXowS6FVUg tk2sVpWUYYaiYOgpuyAPl5pwIPnSC68rn4TiKsY6Va3rVIlkcCA82pf/6HoH78CBKH4z FnUlo6vHW+hCXJo2Ige47N8TcxyqJns41LWYp64lD/P4waRpegJNABWdnmZxJ0MUp5eP YeO3GQrre0zkYqfMRj3U5f6U+Q/JFBIiLh5Gf0+iqG8qIvgGQMFhh/+eTeT9falyr+Vk OSd2/2gb/L6pM7RrH9CSjhaeowLo00N36PntDg5Ljdcdtz6kK5Fe4Ba2/tfBiMxWW071 32hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718897864; x=1719502664; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=s+h387lf4ounMi+iVhkJYXBLUErzSRJimx+T0EIiAWQ=; b=SXXxv8l6ukstxfxdDQq4wTWEc8HxJpDK4qEl1MiokdY0efV7/CfDz9sqTFUNb3f5BX 2A/xPclZAgqcG5doyMk+B0s8VbN4YMeKGUI8TrsyHTacwsiqeM5EjqEff5dHewPXnGEw /1A1W1S7Rkjcw8Wj9mCGOHFc0d884nkcW39CzKY8WV41Dyiqd4GKP50IFOjw5zCs4Tcn W8kSf92I0b+g/46K1+n2ks+EZwVoLglyikkj49pQahIzqX/pbHz1lYC0KnefxBPhiX0t 6jYsgXyDbybHDEa/H+kEOw3HBzvOKTYov9i39Cpxn255JvLR4tF8h1cCwk3mHV4xmAak vchg== X-Forwarded-Encrypted: i=1; AJvYcCW/ISo2hg8ph2sMsTR4GOkBYw1k47o7rbmFGpTUQcaXgC2S87StwHSbSALgaSYz7msIg13aj26HvVzxVNiFM/zLkCHl1I/9FCc3F+fPw7ZLWoVTgnw= X-Gm-Message-State: AOJu0YwXdnzyuIdRdrHrlU4HNjM/WZIa2USf8QyJ986V8fxbaxZpfgAw +OQ9EC02AtLuidyokBFR/4r0GWhcw6W/HN6kyYnunFRmBDnrDMQq X-Google-Smtp-Source: AGHT+IEdhGZIHUC59cCIO/mixYH72/cV9kIvYVpyNXHNqjJuo4SpZGFWObBqJtoJBrKvWs1VeIZvuQ== X-Received: by 2002:a05:6a00:189b:b0:705:cade:1f50 with SMTP id d2e1a72fcca58-70629d012c0mr7919791b3a.34.1718897863773; Thu, 20 Jun 2024 08:37:43 -0700 (PDT) Received: from google.com ([2620:15c:9d:2:36d9:2b1f:59f:8e9e]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705cc91e133sm12441315b3a.24.2024.06.20.08.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:37:43 -0700 (PDT) Date: Thu, 20 Jun 2024 08:37:40 -0700 From: Dmitry Torokhov To: Stefan Eichenberger Subject: Re: [PATCH v4 1/4] Input: atmel_mxt_ts - add power off and power on functions Message-ID: References: <20240417090527.15357-1-eichest@gmail.com> <20240417090527.15357-2-eichest@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240417090527.15357-2-eichest@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240620_083744_811925_26A95451 X-CRM114-Status: GOOD ( 25.05 ) 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: , Cc: robh@kernel.org, conor+dt@kernel.org, nick@shmanahar.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, linux-input@vger.kernel.org, alexandre.belloni@bootlin.com, Stefan Eichenberger , krzysztof.kozlowski+dt@linaro.org, claudiu.beznea@tuxon.dev, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Stefan, On Wed, Apr 17, 2024 at 11:05:24AM +0200, Stefan Eichenberger wrote: > From: Stefan Eichenberger > > Add a separate function for power off and power on instead of calling > regulator_bulk_enable and regulator_bulk_disable directly. > > Signed-off-by: Stefan Eichenberger > --- > drivers/input/touchscreen/atmel_mxt_ts.c | 59 +++++++++++++++--------- > 1 file changed, 37 insertions(+), 22 deletions(-) > > diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c > index 542a31448c8f..52867ce3b9b6 100644 > --- a/drivers/input/touchscreen/atmel_mxt_ts.c > +++ b/drivers/input/touchscreen/atmel_mxt_ts.c > @@ -1307,6 +1307,38 @@ static int mxt_soft_reset(struct mxt_data *data) > return 0; > } > > +static int mxt_power_on(struct mxt_data *data) > +{ > + int error; > + > + error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), > + data->regulators); > + if (error) { > + dev_err(&data->client->dev, "failed to enable regulators: %d\n", > + error); > + return error; > + } > + > + msleep(MXT_BACKUP_TIME); > + > + if (data->reset_gpio) { > + /* Wait a while and then de-assert the RESET GPIO line */ > + msleep(MXT_RESET_GPIO_TIME); > + gpiod_set_value(data->reset_gpio, 0); > + msleep(MXT_RESET_INVALID_CHG); > + } > + > + return 0; > +} > + > +static void mxt_power_off(struct mxt_data *data) > +{ > + if (data->reset_gpio) > + gpiod_set_value(data->reset_gpio, 1); > + > + regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); > +} > + > static void mxt_update_crc(struct mxt_data *data, u8 cmd, u8 value) > { > /* > @@ -3305,25 +3337,9 @@ static int mxt_probe(struct i2c_client *client) > return error; > } > > - error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), > - data->regulators); > - if (error) { > - dev_err(&client->dev, "failed to enable regulators: %d\n", > - error); > + error = mxt_power_on(data); > + if (error) > return error; > - } > - /* > - * The device takes 40ms to come up after power-on according > - * to the mXT224 datasheet, page 13. > - */ > - msleep(MXT_BACKUP_TIME); > - > - if (data->reset_gpio) { > - /* Wait a while and then de-assert the RESET GPIO line */ > - msleep(MXT_RESET_GPIO_TIME); > - gpiod_set_value(data->reset_gpio, 0); > - msleep(MXT_RESET_INVALID_CHG); > - } > > /* > * Controllers like mXT1386 have a dedicated WAKE line that could be > @@ -3361,8 +3377,8 @@ static int mxt_probe(struct i2c_client *client) > mxt_free_input_device(data); > mxt_free_object_table(data); > err_disable_regulators: > - regulator_bulk_disable(ARRAY_SIZE(data->regulators), > - data->regulators); > + mxt_power_off(data); > + > return error; > } > > @@ -3374,8 +3390,7 @@ static void mxt_remove(struct i2c_client *client) > sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); > mxt_free_input_device(data); > mxt_free_object_table(data); > - regulator_bulk_disable(ARRAY_SIZE(data->regulators), > - data->regulators); > + mxt_power_off(data); This change means that on unbind we will leave with GPIO line asserted. Won't this potentially cause some current leakage? Why do we need to have reset asserted here? Thanks. -- Dmitry