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) From patchwork Wed Apr 17 09:05:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13633060 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 797A5C4345F for ; Wed, 17 Apr 2024 09:06:20 +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=kvFLHid+DmYjnkpvqyc1vUkzA2fIW1vH1BZtmpn2MiA=; b=1vazPhjoCLy/DQ 7eBPmXmN+bUHbiO+e4cAYhM+TBMnObOv9+la3Rb6UFAenha+ynyY4dllq7k7LItacN6OBpbTFE4/B QBLJmAH4bxuxi1xHkgFvXFXSi4LXoo/fton9epxUecDLFWWNUjSBlUAzLl4q84WHPJoYXIcbq/Hzu jBaWLcrMC6PTVL46zYETnxy9ndGes1s2XFJYGYSdiVxuTmRZdFYdcal6vTXrEgJX1BJD0X1U5rAkY 7WRNOj+goUDRuzlFKhBUigIW9u4lWM4kzRdTyh5CTueQQ6XWMLnAR2YuWJR0viTkYiTXQtZwsedrs TlJ+kqG/zzAdcSwJaPkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx1Ev-0000000FKtC-3h8S; Wed, 17 Apr 2024 09:06:01 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx1Eq-0000000FKnx-0YLu for linux-arm-kernel@lists.infradead.org; Wed, 17 Apr 2024 09:06:01 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-570441bc23bso1900255a12.0 for ; Wed, 17 Apr 2024 02:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713344750; x=1713949550; 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=nVO7Y9spxZltLz0ZKBeWkeuDpaj3ufTmIIyjVVsXg/Y=; b=GilNOSjeqM5zPpHU9eyc0a3VKykzKkJrBESCpqj9CV6BoIlyvgpfpdrrHeV7MTJgy2 D+lZ/wecf8yAnlBA/lggpRPEZRUdsjJYBleoXb0m75Z0bjX0xWlfUL0GBfuxtwp+HuhV DT8J38EMEjjB/CwC0NiKsoUX8/7Mkqouyj1u683OGskms1XBFUSUkowrLNa37B3nC7CH hSBO8epB/vr9Oze/T3AJVrSd98Iy5Nbvo9cNwSLNT1YgXK7R+hM/yTZ5PUmmx4qmTgVo 1ctJQPwq3h+geo2f1lv58ZF5NDmVVxvnqMLuq6TZf9dILwXJGirC9yTobOAJZZBEFCnF QmTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713344750; x=1713949550; 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=nVO7Y9spxZltLz0ZKBeWkeuDpaj3ufTmIIyjVVsXg/Y=; b=lDTdtdewrHWbcQQ6TcvyC11nD5FAd/xkY38bm3Ev1EmZu73BxwTh8TIYc8v/hAlvb8 sEHkjZzbiuW8vaD9A3fOhI4bFqANH46ZReP/lEaqagtti7glmLHqzXFGpuLWHM0cpggx 7QE/YScG3T3qFdzXEkHahcBl/quQ7NpQRLtnPOmSVh938WfrPMKTjvSTaGqn6gfRjule nBWabEl5iDERrtzOh9hFWfAepgOc0lE7py4uWEkjPhiksPEd4Pm8HlgAO8K/3V/q4UQi SjHknGuPjBxYsIgmzymOGjtOVnqLHvWuNqg8IAwDYdo+lyW9eMj4L/FRTfNTAWcFwgiu NzBA== X-Forwarded-Encrypted: i=1; AJvYcCWTLNvKvqIH9rOtv4mqC6fykHnqvLjccT52Kajg22h50IRDlq49E8mVTOFN2lIQ56DlJy9SZMANwGfj/ML4tsqRy1wNRKkPLUI6Bs7GhC8TYG6X/HU= X-Gm-Message-State: AOJu0Yxoieau+JlNDQbQzHsKdX/BUhVFsiW8d5+1EvYpyn9B4t3w1ohc 3g2mz0v/N7juOmsSU1n8l1mdtwGPDWxrybEGixyVRiupoD8VU5jm X-Google-Smtp-Source: AGHT+IFUkdwpp7ObVakVGgFeNDSzMlYh9htOtwrKqqjylFoa9WsalF+lNzqRVN5BL6pX0/M8DBZwjA== X-Received: by 2002:a17:907:6e87:b0:a52:3d07:de62 with SMTP id sh7-20020a1709076e8700b00a523d07de62mr11939733ejc.58.1713344749669; Wed, 17 Apr 2024 02:05:49 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:05:49 -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 2/4] Input: atmel_mxt_ts - move calls to register the input device to separate function Date: Wed, 17 Apr 2024 11:05:25 +0200 Message-Id: <20240417090527.15357-3-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_226809_DC65ACD5 X-CRM114-Status: GOOD ( 17.07 ) 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 The calls to register the input device are moved to a separate function so that we can call it without having to confiugre the device. This is necessary if we want to power on the device only when it is opened. Signed-off-by: Stefan Eichenberger --- drivers/input/touchscreen/atmel_mxt_ts.c | 34 +++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 52867ce3b9b6..7c807d1f1f9b 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -2277,6 +2277,28 @@ static void mxt_config_cb(const struct firmware *cfg, void *ctx) release_firmware(cfg); } +static void mxt_debug_init(struct mxt_data *data); + +static int mxt_device_register(struct mxt_data *data) +{ + int error; + + /* If input device is not already registered */ + if (!data->input_dev) { + if (data->multitouch) { + error = mxt_initialize_input_device(data); + if (error) + return error; + } else { + dev_warn(&data->client->dev, "No touch object detected\n"); + } + + mxt_debug_init(data); + } + + return 0; +} + static int mxt_initialize(struct mxt_data *data) { struct i2c_client *client = data->client; @@ -2831,15 +2853,9 @@ static int mxt_configure_objects(struct mxt_data *data, dev_warn(dev, "Error %d updating config\n", error); } - if (data->multitouch) { - error = mxt_initialize_input_device(data); - if (error) - return error; - } else { - dev_warn(dev, "No touch object detected\n"); - } - - mxt_debug_init(data); + error = mxt_device_register(data); + if (error) + return error; return 0; } From patchwork Wed Apr 17 09:05:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13633063 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 4E069C001CC for ; Wed, 17 Apr 2024 09:06:25 +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=B9p11KBxMSbj9qZmjAqhAWcvNO944su6I/hIS4/5ELI=; b=rK5ifbX3VR+W1a 4PVVqzGjHjQppn1Rsi1RSf7gYfobrEAE0heOCx8UIiI+o62EcW6cW3PMtlR0iuA24UtLoV+E20oPI MQr2EHJ/YqFY+1AYy456Y9PqCdrgr0WGaZ+qN+yw/lIwaye3IXy4C0ejHe8fUq4gfsDZjsAN+A6qK iGCpg/72wZhGppwJwmAyc64fGohouZluJBCztsiDloipDgrP7M4t+zqFFMbqe6Sl45uM213PERsBq 1Hh0Gn3n6NJJzoJoeo85L+dadQ7Noq0VgqJ4zt9cx+oWwQFVpa6nlgRDHZEBjzLuLGQqFbCEutw7K MfzZIMTPDeMoVxKNy0Yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx1F3-0000000FKwP-272I; Wed, 17 Apr 2024 09:06:09 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx1Eq-0000000FKoY-0ZqM for linux-arm-kernel@lists.infradead.org; Wed, 17 Apr 2024 09:06:02 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a51f9ad7684so356186566b.2 for ; Wed, 17 Apr 2024 02:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713344751; x=1713949551; 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=SZwRK1DevWHs7TSy/8l1VCGmE7RT9MSmuvvOPNO04ZE=; b=mMnvaOXbgkDcB26uI9fShkb2ZGo9wZM4ei6S1oKsSSgW9C2SMEvZmZ79HKqojJuNia II7Z99Tfu1jG1Q5ELKa79Rv8IZoyatPkqEBvjgPqaWLvTsEvuXh4OajB2YT+rhzvSNsC 3+ZUDOuQPWos+7skyrAnsaKu0VC2/c1kmVMhzWkfib+aa5ejH6Celcw9NTd43R/uSxC6 uu5ujlj/SzHUPjdeeytxViRC/rdfCIZpj5VKCds0kAXlVbhXHIQ25jdWqIymsj9oJ7eq zyX1lZ+DE0uFMjBRgNbdIbKpCFHWqPx+BiqmKpXhbAke2i2eiEe4Wt1Yq9EJ4HkfJ+uS 57xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713344751; x=1713949551; 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=SZwRK1DevWHs7TSy/8l1VCGmE7RT9MSmuvvOPNO04ZE=; b=GXDfH9eDZnRs/NGHSDmhM3TSE+oYbbetbfwhAJ3gh6P/+1EheDS/ghP7mikCV7WK6d oNh25aJV2FbFvPN+0RVMRtWV+bbJHBK8wvNIfCBjhkFDPKMgZtZKtBnnSDjyn7Qwd6x8 0i5+1VDdsI0I+4Qdxk429rXbMjlOn68xsu+OkKYHuntt2RVDBPFieQhNuUDFgwfYw8Hc PN7sm9+KZULFwaElN6PU/8shQnIH/ai1Uv3TRmg9T2nE0Q9ngUDwLKcKvd9C6ILtUK9/ sejExCbU2UmFqKd51xBAaOySqMCzzzFYz8DKi1k7S3yvQuton19TTH2pYPbqF7KurOry mHzw== X-Forwarded-Encrypted: i=1; AJvYcCW6Phgs113xbM4NbZMo/mKMD8OQW/oX54bbfGe/oghda2S7IuS/WMZWVakJLSqONcvF8xjck8XYxbYbfkhxYlAqu/mi8MA9WHpHpF1SLAoDkzizE/E= X-Gm-Message-State: AOJu0Ywck3O+JsxKPnDNv1/nJsKThq3mIagwJuCgTCvJekZ5b3x45QCk q7f4O5GyduVgBRGCXn+R9vlP3O/PfwnI7mM19KP7QivM3wwDfuAR X-Google-Smtp-Source: AGHT+IGE2DnDV3rpp3b8Ce/rnKgMZfX7uxAsyjA9iUq+P1/TDU14340g92GIgBrYF0+l9pSZ9cbGAQ== X-Received: by 2002:a50:a68f:0:b0:56c:18b4:d2ab with SMTP id e15-20020a50a68f000000b0056c18b4d2abmr11801276edc.42.1713344751147; Wed, 17 Apr 2024 02:05:51 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:05:50 -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 , Krzysztof Kozlowski Subject: [PATCH v4 3/4] dt-bindings: input: atmel,maxtouch: add poweroff-sleep property Date: Wed, 17 Apr 2024 11:05:26 +0200 Message-Id: <20240417090527.15357-4-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_250775_E0EC5D45 X-CRM114-Status: GOOD ( 12.21 ) 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 new property to indicate that the device should power off rather than use deep sleep. Deep sleep is a feature of the controller that expects the controller to remain powered in suspend. However, if a display shares its regulator with the touch controller, we may want to do a power off so that the display and touch controller do not use any power. Signed-off-by: Stefan Eichenberger Reviewed-by: Linus Walleij Reviewed-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/input/atmel,maxtouch.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml b/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml index c40799355ed7..8de5f539b30e 100644 --- a/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml +++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.yaml @@ -87,6 +87,12 @@ properties: - 2 # ATMEL_MXT_WAKEUP_GPIO default: 0 + atmel,poweroff-sleep: + description: | + Instead of using the deep sleep feature of the maXTouch controller, + poweroff the regulators. + type: boolean + wakeup-source: type: boolean From patchwork Wed Apr 17 09:05:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13633061 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 AE9E5C04FF9 for ; Wed, 17 Apr 2024 09:06:24 +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=WmC9NOcxtBFh25Oa0EEqyOhl7d4nZLtGbrTxcczMlV8=; b=a4wUrh3XpZMN56 uIcO8oXeE1p21XSZLVEZ5jj7pLZhmMjoAtPQ5/xXo6O4Kl+qwUX2p0hH5NmLstg5xW6CRMcgnOnvI RAoINwweKllaoiMTmICnO2fxN4NoHiWylKcO2OVPdzGbEgRgZj6JGqGaC8e86+zooOR6Wz3QoBnIe 7HOqhDmDepSLm4KiveKPVKOy3fyMuzKW5xPlx2NMbXSiKJFcIeQwjUL6DOUqNsTGI7CEIcXyCBUfo j3c11CwYmXcLkb0W0VibwelOITrgmVsRIfadrIyjbRcB+iimYbioU89xdzg6INdSdwfuFbFA/7ZDi qjLnUmj+pA6c6rtG0wgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx1F1-0000000FKvt-42VX; Wed, 17 Apr 2024 09:06:08 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx1Ep-0000000FKoz-3Yi1 for linux-arm-kernel@lists.infradead.org; Wed, 17 Apr 2024 09:06:01 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-518e2283bd3so5295989e87.1 for ; Wed, 17 Apr 2024 02:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713344752; x=1713949552; 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=RapgrZErc/ITlKzcSUQIzooYAlK8fdOO3y65E56afes=; b=bgvaqXlc8DFqOvS/0+YnGXdOk2ZLeiUrYx/wkNYa8EiraJ77Z1uQU4yhOpnFpAMXjq vv+dsRvLZYmZmBAH+OeLIVXht95fOIqiuFN1E7ExlJl/dOWGN3ODmsUiOKk577COWwAz kROlndaEzbWKzZDzJiWqYIfn4HcZAITMqPZMkubIb16zcAexiQ4Mo+ZTSRxofNlmIxNQ nDoFY7WT+3ZyxLIyWwGuPMHEaQf+nyYG3ok7/8233THHuIRE3ynIr0hNvkwSzDzy1hjh FvSk3/uoHmZgjs+6b/U1jUFpwHsj/50oVi8ucAvwF9epbxgbxId979yDe0Y11OzNF8H5 /PrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713344752; x=1713949552; 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=RapgrZErc/ITlKzcSUQIzooYAlK8fdOO3y65E56afes=; b=jYMDNMsEidhUwE0fQTpCrE90NwarRnX5CPhL3mljcMnNaImdW0mQgVMPlGAHiMCzus xdr/SOmc/Jn8okKdw1bynxSGFhnCDYAdvkZKPuBAv/9jp78fHYgCO7eEhwVUjy59B2Al CKO3Y+AQ4FeFLgBYvM8HzZvPdhYkez+5xpMw1Bl9ZzyHcnFyJbtfaCtfDUQbIHLdNYL9 SCyu+kg9YIIDyQWgNY/hpnFy2hqXyfmf1h28NbVfwFz4SJFX7rcH2wo+A/U0H70CkDSe SZkZv1QbOI6uJvGE9fBoXVCj2yYyjgURkSH7HLomMVbjN2nK2mkCYQRrQguZ9aOj8BQO Vx+w== X-Forwarded-Encrypted: i=1; AJvYcCXsQSS9TapmHa7Bu0vhqz7Ui6Dcfa9hDCG6bhlMaTkslyg4lkUQ3nVsVbKCftZudKsZ6Ywkhz/uIAk7B3tAMzqo+zoqOUjmaMzbLZl2QMnng6XwaZ0= X-Gm-Message-State: AOJu0YwXE8JKBPYG/JzU1+lw8R8aO+Pd1GcXZD2K3jdpx6iJbTZ28jdj bfOZtEhcWJMfWhj6cq5JZYq9Q41xVSs/zajnoheGNAC4mUieKxLa X-Google-Smtp-Source: AGHT+IGb9+72n5V0xsJVA67N8YPnU7MziiZfTlYdiLX0d1cdd/KwyS2M0kpZ/IL4HChGoZxSrp+hmw== X-Received: by 2002:a19:6a07:0:b0:513:c61c:7331 with SMTP id u7-20020a196a07000000b00513c61c7331mr11302672lfu.3.1713344752318; Wed, 17 Apr 2024 02:05:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:05:51 -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 4/4] Input: atmel_mxt_ts - add support for poweroff-sleep Date: Wed, 17 Apr 2024 11:05:27 +0200 Message-Id: <20240417090527.15357-5-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_020555_922836_CFAAF795 X-CRM114-Status: GOOD ( 19.16 ) 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 support for poweroff-sleep to the Atmel maXTouch driver. This allows us to power off the input device entirely and only power it on when it is opened. This will also automatically power it off when we suspend the system. Signed-off-by: Stefan Eichenberger --- drivers/input/touchscreen/atmel_mxt_ts.c | 71 +++++++++++++++++++----- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 7c807d1f1f9b..f92808be3f5b 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -317,6 +317,7 @@ struct mxt_data { struct gpio_desc *reset_gpio; struct gpio_desc *wake_gpio; bool use_retrigen_workaround; + bool poweroff_sleep; /* Cached parameters from object table */ u16 T5_address; @@ -2277,6 +2278,19 @@ static void mxt_config_cb(const struct firmware *cfg, void *ctx) release_firmware(cfg); } +static int mxt_initialize_after_resume(struct mxt_data *data) +{ + const struct firmware *fw; + + mxt_acquire_irq(data); + + firmware_request_nowarn(&fw, MXT_CFG_NAME, &data->client->dev); + + mxt_config_cb(fw, data); + + return 0; +} + static void mxt_debug_init(struct mxt_data *data); static int mxt_device_register(struct mxt_data *data) @@ -2341,17 +2355,23 @@ static int mxt_initialize(struct mxt_data *data) if (error) return error; - error = mxt_acquire_irq(data); - if (error) - return error; + if (data->poweroff_sleep) { + error = mxt_device_register(data); + if (error) + return error; + } else { + error = mxt_acquire_irq(data); + if (error) + return error; - error = request_firmware_nowait(THIS_MODULE, true, MXT_CFG_NAME, - &client->dev, GFP_KERNEL, data, - mxt_config_cb); - if (error) { - dev_err(&client->dev, "Failed to invoke firmware loader: %d\n", - error); - return error; + error = request_firmware_nowait(THIS_MODULE, true, MXT_CFG_NAME, + &client->dev, GFP_KERNEL, data, + mxt_config_cb); + if (error) { + dev_err(&client->dev, "Failed to invoke firmware loader: %d\n", + error); + return error; + } } return 0; @@ -3089,6 +3109,9 @@ static ssize_t mxt_update_fw_store(struct device *dev, struct mxt_data *data = dev_get_drvdata(dev); int error; + if (data->poweroff_sleep && !data->in_bootloader) + mxt_power_on(data); + error = mxt_load_fw(dev, MXT_FW_NAME); if (error) { dev_err(dev, "The firmware update failed(%d)\n", error); @@ -3101,6 +3124,9 @@ static ssize_t mxt_update_fw_store(struct device *dev, return error; } + if (data->poweroff_sleep && !data->in_bootloader) + mxt_power_off(data); + return count; } @@ -3123,7 +3149,12 @@ static const struct attribute_group mxt_attr_group = { static void mxt_start(struct mxt_data *data) { - mxt_wakeup_toggle(data->client, true, false); + if (data->poweroff_sleep) { + mxt_power_on(data); + mxt_initialize_after_resume(data); + } else { + mxt_wakeup_toggle(data->client, true, false); + } switch (data->suspend_mode) { case MXT_SUSPEND_T9_CTRL: @@ -3160,7 +3191,12 @@ static void mxt_stop(struct mxt_data *data) break; } - mxt_wakeup_toggle(data->client, false, false); + if (data->poweroff_sleep) { + disable_irq(data->irq); + mxt_power_off(data); + } else { + mxt_wakeup_toggle(data->client, false, false); + } } static int mxt_input_open(struct input_dev *dev) @@ -3357,6 +3393,8 @@ static int mxt_probe(struct i2c_client *client) if (error) return error; + data->poweroff_sleep = device_property_read_bool(&client->dev, + "atmel,poweroff-sleep"); /* * Controllers like mXT1386 have a dedicated WAKE line that could be * connected to a GPIO or to I2C SCL pin, or permanently asserted low. @@ -3387,6 +3425,9 @@ static int mxt_probe(struct i2c_client *client) goto err_free_object; } + if (data->poweroff_sleep && !data->in_bootloader) + mxt_power_off(data); + return 0; err_free_object: @@ -3406,7 +3447,8 @@ 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); - mxt_power_off(data); + if (!data->poweroff_sleep) + mxt_power_off(data); } static int mxt_suspend(struct device *dev) @@ -3439,7 +3481,8 @@ static int mxt_resume(struct device *dev) if (!input_dev) return 0; - enable_irq(data->irq); + if (!data->poweroff_sleep) + enable_irq(data->irq); mutex_lock(&input_dev->mutex);