From patchwork Wed Apr 17 09:05:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13633062 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 38AC5C04FFE for ; Wed, 17 Apr 2024 09:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=t9lyacESBADOzbIsyMUotXbcElu78ZHqF6EUsvc1Xio=; b=zj3E+t0cz6UHqj hLa/l0Wbwqtdvd9UnehWCof6ug60sVJwVLX1HAnakINkFUiTSW+sOHZ9JAl2QE2aPYeGl0jBbQUta go8BllgQYRYjadw6Y2IF2MUTSPSboy5QFkFX+mKCVJyYFhgIYkdqrmrVxApkCxelJuhpfSfai4TSy QAlvrGjqGHXEosz7g9OnPWGYeaIm6RRULMeiPWgseCXHnqAjZ/4IKS3CZBNSorxKuinLfWcMPWfY0 YTVBAloU3AkQE16zslNZnQtSGqACzpz/AkLvPmWfTpoN7IC72kPFHS4wz+2kG8kpItK+dxw8r1f3o CihRbVf+Iiuf8XkRm+6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx1F4-0000000FKx1-1a7R; Wed, 17 Apr 2024 09:06:10 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx1Eq-0000000FKnp-0XoZ for linux-arm-kernel@lists.infradead.org; Wed, 17 Apr 2024 09:06:03 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a5557e3ebcaso60079366b.1 for ; Wed, 17 Apr 2024 02:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713344749; x=1713949549; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a4Vk3Q7FWCEz42m30ao7B+UDk+tJ78nsGVh0gV/OBQY=; b=Imu70wQ62qsbKPadJ+11Gtu2qETtoaXPqebqGWn/JdNH+Rjim8sqkLhnV5YmEu2TPm OxzBqR7Qwea+A9e81ReiF/NMsdlizgK4qhvgZuUhtek445ESwHQcsFQil3fQFS+ofvew FAiJC19QAXrYJLUFpmnjoNvMuArajZfSgMWLs3S2y/bNnOTsKsfNaK7LyqVFqW8mv5tM QCShTdgYmdWYD01jFcE6QLRlGijvz+TZSsuSDsgf5k69U0BdQ4w1hRjs4vZA0qLRopfK fNGjReE6AHKsHNiVrwsUZ43za0IpKaDHeT3OKZv7nl5qsU68qpWg63dK6VK9Rr4dyT94 0GGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713344749; x=1713949549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a4Vk3Q7FWCEz42m30ao7B+UDk+tJ78nsGVh0gV/OBQY=; b=nBrgxhzHn9Bzac+0SejGDJeNtVgxTpd97jZzcWzvS83xtG8mDW/tyk9v9Gyx/iXY4k HaU8IdgDrh5kJ1xSnF4fEqM8GqFXVFBXxjl5neEsdwOTXl2awI8WdWTc6OE7CmevrJCY zIpMlQdpoPvVQFtRoIZMRDWyQNsaAJjQuj1C0VaCjd+tocVP2XJClk0WL/BK2SddXS79 DcF8LXIFLCcyOkvnxQzeD/x8q+REdtJvTrpwXlfq01ESbKDuSGpScnMqAC2WUcjUgT0x W3XCchDsT89AIFAGNGq+h7I8W8qb0cTlktNsNaO44/Gr4rexpxn/2JwxxDH9i64B6Ecn VwkQ== X-Forwarded-Encrypted: i=1; AJvYcCXIqiMoHKDpQ6PJ+vGt8sog+6qveHujlIM2FibJqvRv1b1Rs/sI0+HBfhxOmFxOB7Lb/fmwnkeCGXoFZMmVtu0aAg0r391q5gibozSQANEAlDu2Eq4= X-Gm-Message-State: AOJu0YwX0jaj03tBQGbufWvsk9uBNXguIDx5Xab3ovuo8pW/GxGgWVdf kO9Bd/DsVsok8nqnV/tmjN47mAzzsme4OxRMvOdzLCJg3EMjfA3r X-Google-Smtp-Source: AGHT+IHszUefnI9sBtUBi7rkPViwITCu7QxSkQRsMDdVIQ+r+3QMTYvwC4NJZBnUvZqMC+iDCdPbjA== X-Received: by 2002:a17:906:554:b0:a52:30d4:20e6 with SMTP id k20-20020a170906055400b00a5230d420e6mr3592032eja.10.1713344748920; Wed, 17 Apr 2024 02:05:48 -0700 (PDT) Received: from eichest-laptop.corp.toradex.com (31-10-206-125.static.upc.ch. [31.10.206.125]) by smtp.gmail.com with ESMTPSA id x16-20020a170906135000b00a51a7832a7asm7897814ejb.199.2024.04.17.02.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:05:48 -0700 (PDT) From: Stefan Eichenberger To: nick@shmanahar.org, dmitry.torokhov@gmail.com, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, linus.walleij@linaro.org Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stefan Eichenberger Subject: [PATCH v4 1/4] Input: atmel_mxt_ts - add power off and power on functions Date: Wed, 17 Apr 2024 11:05:24 +0200 Message-Id: <20240417090527.15357-2-eichest@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240417090527.15357-1-eichest@gmail.com> References: <20240417090527.15357-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240417_020556_247704_CF92FD3E X-CRM114-Status: GOOD ( 16.46 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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); } static int mxt_suspend(struct device *dev)