From patchwork Mon Jul 15 15:31:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13733612 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 C87A0C3DA4A for ; Mon, 15 Jul 2024 15:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XrCU6G9DnnMkxpZ0nGUhFrVcFHRKc9c76P/tMQAhH00=; b=PMeXhUQENnJUL8ZAvWGT6hi+ET E6artOBJADPHruW8Qb1nswTj/QXA7EscIKGjCezmvNsYRTfP/5uCrQQRryvKH6PnXVXXM9mifut0W NQ7bvsOg6HmcfTsKuMa3G7i4rkAdHxIMEILfdYlL8AZB8xQESgGyz/L3fqrEQjlRohrnqabh6vZcZ RQ1kQ2NoApfRsr1qfkrwZUBy++Jb/6ZRGo1QmJu1ZOJ+HPpyGXKZLHLKSOIuUU8sIlldGKIRbKHJm C9jguNccJrE+X5iusGcm5eJqZxPcFmM97aTDtiOBqYGZL6Ba4OtSAFQDGFYcFT923Sedr/5325h63 V09TjJKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTNiN-00000007aSY-3c39; Mon, 15 Jul 2024 15:34:11 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTNhr-00000007aFG-3YnP for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 15:33:41 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-367975543a8so2738955f8f.3 for ; Mon, 15 Jul 2024 08:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721057618; x=1721662418; 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=XrCU6G9DnnMkxpZ0nGUhFrVcFHRKc9c76P/tMQAhH00=; b=UYqQH5HOE+yqg/nApK3QyitP2QdEh2jxE87PYSJd5qvqa5j1DC1QpfuRqXCJuzwUiD JoqIgJGdw1FJb12k7enc1/5h6cq7j8hNhrATK5WKF8hVW+7ff0AfMRkszKFZrZAdQKnF 8zc47N808GnDYfz/4J/F4XXwxYSbwVEiaWJ5xJvfLqOEc+C8T3FBYDV6VMhpVujjAlL2 QiNhDuaQRtNeO8ayUr+E7CJO1f6C90ghcF6NMPRbBjBRGSCUPoDvY08ZRMDNmi29ka+G pNvpuvVus9MMNFmG0TfH/TJnpzja1tPjGh/LIomYiHIJawNhtXCNsFjRmWOtMqm+TuWG HFZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721057618; x=1721662418; 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=XrCU6G9DnnMkxpZ0nGUhFrVcFHRKc9c76P/tMQAhH00=; b=I8PBj3oUUGu/pTHezMMzz9jjtp+NYl2e5qKAzks/N//l2QeMR8XHazfvdg9saLtWBa omjwN3LM2zBWGdvbebmbtSe/7zqgtcyjcSqXeM1/3f9j/FsmgOmUaKLU6hQqDL9V/6Xj RiTS+ZcBmAKDabz79MzzABnVrHE+hHWxQ+XjDuSnvhf48wLBJ8Zwly8uEfQhjfHm6mxk EgW+OpYQYEb+p5GuU+WsA5v2hv2m9AYPwz7cBsg0SE/Q0mTpwMIm3rNQ1YbeqGXjEbCf o4n9Jt2BpmSk+fXqdecxPAtEAVHK6FeBA+SHD/U3yvSYiSBNO1+65II/MLGUkKIfqXxg Dk+Q== X-Forwarded-Encrypted: i=1; AJvYcCXKLL0y5+xoKJw1yFIv6NbEXAO6osluligvAE4NF7QdfYz+VHL9vsGl9cufNvZX4h+pqP6uHiXRyR2uw5w+r1r7BR0a6iGb2lJEGhB9PtR3VwKDS2c= X-Gm-Message-State: AOJu0Yz3H0yax0jK3r6aeHa2+A41JYl841Tapfai7mCss2VfHuQSAuwQ ewA8ZT00CrjhMMBkrqz2XMm5eO7LmmRa0e9jWNkzifU/7Tw4IfWW X-Google-Smtp-Source: AGHT+IHFu8Io6ztt+geSSFK6mvGbGpy+kC8jppmdsA/0W5RtN9ndSF6+krNBDMfvyv6CFAl9AoiYbg== X-Received: by 2002:a5d:6089:0:b0:367:96c5:ae70 with SMTP id ffacd0b85a97d-368240936c8mr67604f8f.31.1721057618058; Mon, 15 Jul 2024 08:33:38 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:564b:c18:f4fc:19ad]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf4bsm6720866f8f.73.2024.07.15.08.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 08:33:37 -0700 (PDT) From: Stefan Eichenberger To: nick@shmanahar.org, dmitry.torokhov@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, linus.walleij@linaro.org, francesco.dolcini@toradex.com, joao.goncalves@toradex.com 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 v6 1/3] Input: atmel_mxt_ts - add power off and power on functions Date: Mon, 15 Jul 2024 17:31:21 +0200 Message-ID: <20240715153330.91979-2-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240715153330.91979-1-eichest@gmail.com> References: <20240715153330.91979-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_083339_916842_82622E34 X-CRM114-Status: GOOD ( 17.35 ) 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 Reviewed-by: Joao Paulo Goncalves --- drivers/input/touchscreen/atmel_mxt_ts.c | 56 ++++++++++++++---------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 8a606bd441ae6..9416de53bf9af 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -1307,6 +1307,35 @@ 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) +{ + regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); +} + static void mxt_update_crc(struct mxt_data *data, u8 cmd, u8 value) { /* @@ -3305,25 +3334,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 +3374,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 +3387,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 Mon Jul 15 15:31:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13733613 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 2C0F6C3DA4B for ; Mon, 15 Jul 2024 15:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AFhWGLjXxrpIBhuvDdpT6ZAZC88NAS6103pgQHGSnqI=; b=lL8P6vbe0agVTPwdABu+8qLd8S acAnpvrVlSlAiWadMBop5cYt68LgxDaUqx0awydZmGaII1RbXRqcJaqsSSoiVv6cLPVufsIWqt3h2 nrLCoWvkHAJWYKept0cCoHMDQnS7u9e5hVVYi75nMARWuCUFy9VlVfouFDMNGIOphBI98wwk+lMMw 3EVByWWCKcvod+ATwI81MLIWgG2c+dd/btUkv8YsQX8G+wzaQoSrk4GIo9c58FUJ9Yb1sHenYcgLA FM3zN5Fr1sgdmd+faxpZ7hseclGJj9grKjXaGKXkG2+wT2J+Dn9u54dmzwExM0V0jeOCIQZ8nmejU 6Gj2jXmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTNif-00000007aZN-1AcR; Mon, 15 Jul 2024 15:34:29 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTNhs-00000007aFN-3UWw for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 15:33:42 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4266dc7591fso30517355e9.0 for ; Mon, 15 Jul 2024 08:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721057619; x=1721662419; 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=AFhWGLjXxrpIBhuvDdpT6ZAZC88NAS6103pgQHGSnqI=; b=HWoz2JGfA4HBwydB1lz3HFIfuzpdCY+HhxC5zg3GD2aNJrCdT72j3DQlE6z9ozOztS 51YPf1XHKqGoDoVHF3eDwGfzQ9n00iytIc64pKEZA9BOZAUdTcsElIc0z9uUnR/QAIPa nDS93wvbaKj9gAh6bRK9DoOQ6+z8WrQifidG8GC6J9irxrueVmNpBrcjUPVYBT/7Qn6a MsEkirmX0nbzj2wsIyE07xFuqi8qlYatLDp6JThsdjinqeM8Stc4WgkHczi63bAuEFNL +X+g+mZluVZ4qIZJh2WxWfNU6tDeeYXvP6KFpA+VtHiCaI/LGCJtCKAz8n6xTRL9l4kU b6kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721057619; x=1721662419; 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=AFhWGLjXxrpIBhuvDdpT6ZAZC88NAS6103pgQHGSnqI=; b=SjhR+pOHuDAOSJgg9hNl1iVCL8GtMq+DydXNCbbkXEUuL7qDM4Qi8gZoO1UVMGlnCw kFGZ3MLzHBLvF+qnolDfUc9LAdcrzjQPsvq/XI0xxNwsf2cjnUtiJe6+IPYUEln+mW7T n2coW0ESXRyqyMKKWnSrFPaEqJc4Su9CYKNfnlcje8CVH17/RLZJt0MMC+qVUkluKI0p SMvIzIdtMs4iuiV7LMLln/kPetheyCLSSJB1K3iEsr9W3WI/vVIo0NMKfwomuOWe7ZHS B7vXBBmJJj2937k+zissdFnpW/YbA+4TDNpKPFLaEgof1dUlqgudVzwSZMFIQjh0xYaB Ns4w== X-Forwarded-Encrypted: i=1; AJvYcCXdKKE8u9EuzxCMRM4xLB/mPb72nGoe/hVIG1xyKGkynMW+zFy8htVlBel9OZF94EpVGNXI5SYQix0/+U/CXNvzS6NWp91GLoaZZBRYDhqzJjeP7l4= X-Gm-Message-State: AOJu0YzgFHeBDLoxVv7XmFZXuRv2kzuZh5Jn6GudHo6u9iZ42JY/Hhjk IhXisOBVOfTFl5OLo1aYb9/1NT+zYm2vQynuJcghyNuyMzYLAJCz X-Google-Smtp-Source: AGHT+IFiyTZE/+oE0xkUmOA7iwowc7q5KaPBKgyHBKRziOql6qdP2VyoHmCNFAkNIJeEzlryIGaF3w== X-Received: by 2002:adf:e5c9:0:b0:367:9639:66d3 with SMTP id ffacd0b85a97d-36824081d99mr79678f8f.5.1721057619043; Mon, 15 Jul 2024 08:33:39 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:564b:c18:f4fc:19ad]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf4bsm6720866f8f.73.2024.07.15.08.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 08:33:38 -0700 (PDT) From: Stefan Eichenberger To: nick@shmanahar.org, dmitry.torokhov@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, linus.walleij@linaro.org, francesco.dolcini@toradex.com, joao.goncalves@toradex.com 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 v6 2/3] dt-bindings: input: atmel,maxtouch: add poweroff-sleep property Date: Mon, 15 Jul 2024 17:31:22 +0200 Message-ID: <20240715153330.91979-3-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240715153330.91979-1-eichest@gmail.com> References: <20240715153330.91979-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_083340_899376_FC47BA2E X-CRM114-Status: GOOD ( 13.14 ) 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 Reviewed-by: Joao Paulo Goncalves --- 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 c40799355ed75..8de5f539b30e3 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 Mon Jul 15 15:31:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13733614 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 32F58C3DA4B for ; Mon, 15 Jul 2024 15:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wixUMSPfbRUA5ff8Q7KbeB+Bn7dETuvtQK3RDPocxSU=; b=eB3S3WMjRPD37W3k5uSSoX5oo2 pTRMvtrUP/H77oF3yk7FVJ3KV5b+7ShdspHDoeUa6ocHRFnxjJnEj/RaDL7i9hsukxUi9pS7c4yF1 LVuDuYKfxzXTyitWms2CWelj9z5ay+DG6kH6MaVWaBjry2tKd0ZONV8DI04UMYuvrBCvdOQ9AeEoY eVarqdlAGcprGH6nNWbAAkXXxiH2ec+OVbN1OJ+Qkqk5zLBxJs8nruwJy6bAaNuYGWvBR8gZnybb4 +rivSt8kUOTgFloDnTNdxu5uen1rpOD8IGF4vOBw+pu2ezvEek9cR2+cDLb1D3J+YZXzYF33zDLto 3nnBcYRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTNj0-00000007aji-04R2; Mon, 15 Jul 2024 15:34:50 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTNhu-00000007aFp-3jue for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 15:33:44 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-36798779d75so4031220f8f.3 for ; Mon, 15 Jul 2024 08:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721057620; x=1721662420; 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=wixUMSPfbRUA5ff8Q7KbeB+Bn7dETuvtQK3RDPocxSU=; b=edhALm7UzJLEJ8CKuXuSpkCpUy70PGCKIL4uqFyA+dB2LKpx3YpI5aNT+wTeK1od9y WrCBRFbUaMlld2P+3iMfseVEpYV8No3zn3WyeWPorOV8rW0/utcUcsOSEHhgMjJ0CdcH 85YTvB6+K0yFvj8i7hv1azr05lbmeWYV4vS9ghASfTrrV1sA0TdOOts5RjvgVsZ3i9ML PGMuMMsVZCCGjSgLvHRgk0bc0S1lhKSL8PCM8f+9/OJNBLs16709cmf0m7LAAilRnnQT Wiubo26wWGuXWosb8WIKLRLJfLMO/5z0lU8pKUiK66HNicUj4r9Mkesd6rkm4mg3bFpl 3DGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721057620; x=1721662420; 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=wixUMSPfbRUA5ff8Q7KbeB+Bn7dETuvtQK3RDPocxSU=; b=jhtG2pVL0Mf5ho0cnuKzaxO0Y3glmUhWLNO3iR0Nknfu8ZAYIOlQ0ck5YaBHlSG1pV ercwZC+oG2gENjeLQy/BN5bDcPDXKV2VmJo1uacUNKlDeh0XNfPPX+yZfVlAptLAHsjf 5Trvp3iz9hl9+CAhfNO7A+fRLgdq6BlFpuGhp7iX5uFCuzCqkhgZJpjEkAyHeDPyXJTc 7EfzVBEm/+pJG5MwLn45cLGImRWpaKadsIgv3WBSujKqmK5l/dWd9/Q0g/K+cjAB8Gwb 8uc2cfUN2iSB6Fsm95jx16f9yoz3WXf3nS6KLIe3QpmhlFI5l70zTHc8B+hgEzJ2KrnE X02A== X-Forwarded-Encrypted: i=1; AJvYcCX6AL5qQCpTrclIye5Zax0gzCbUhObOO3YxJX9Wa1MOERoHfkYpasrzTZb+97bT6WMKEGTMgPSstQM+ATUzfX+cVfoxOuk6ZbdsaT60iisY9ne14M4= X-Gm-Message-State: AOJu0Yy/AkuvOxNZSqnZG9TWtOtlcTizV6L+UW50NuKh6gIq93FwI9Gm BbdQIaFnp292M32l8SVRSeU8qCmZVCz44XrfD4uO0itp7p6UFD2I X-Google-Smtp-Source: AGHT+IG+p7mUgs29QXGW6vDzpdT1cAhBKDRl4uDUB7qml+2dMbB5omhfCWb8x0y0AAzKovVgBoWVUQ== X-Received: by 2002:adf:e54e:0:b0:366:e986:22ef with SMTP id ffacd0b85a97d-36824078b02mr102969f8f.4.1721057620011; Mon, 15 Jul 2024 08:33:40 -0700 (PDT) Received: from eichest-laptop.lan ([2a02:168:af72:0:564b:c18:f4fc:19ad]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf4bsm6720866f8f.73.2024.07.15.08.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 08:33:39 -0700 (PDT) From: Stefan Eichenberger To: nick@shmanahar.org, dmitry.torokhov@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, linus.walleij@linaro.org, francesco.dolcini@toradex.com, joao.goncalves@toradex.com 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 v6 3/3] Input: atmel_mxt_ts - add support for poweroff-sleep Date: Mon, 15 Jul 2024 17:31:23 +0200 Message-ID: <20240715153330.91979-4-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240715153330.91979-1-eichest@gmail.com> References: <20240715153330.91979-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_083342_969690_1CE8295F X-CRM114-Status: GOOD ( 23.36 ) 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 | 82 ++++++++++++++++++++---- 1 file changed, 70 insertions(+), 12 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 9416de53bf9af..46ed3dbf0c5ed 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -265,6 +265,7 @@ enum v4l_dbg_inputs { enum mxt_suspend_mode { MXT_SUSPEND_DEEP_SLEEP = 0, MXT_SUSPEND_T9_CTRL = 1, + MXT_SUSPEND_POWEROFF = 2, }; /* Config update context */ @@ -1311,6 +1312,10 @@ static int mxt_power_on(struct mxt_data *data) { int error; + /* Make sure the device is in reset before enabling power */ + if (data->reset_gpio) + gpiod_set_value_cansleep(data->reset_gpio, 1); + error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), data->regulators); if (error) { @@ -2270,8 +2275,38 @@ static int mxt_configure_objects(struct mxt_data *data, static void mxt_config_cb(const struct firmware *cfg, void *ctx) { + struct mxt_data *data = ctx; + mxt_configure_objects(ctx, cfg); release_firmware(cfg); + + if ((data->suspend_mode == MXT_SUSPEND_POWEROFF) && !data->in_bootloader) { + disable_irq(data->irq); + mxt_power_off(data); + } +} + +static void mxt_initialize_after_resume(struct mxt_data *data) +{ + int error; + + error = mxt_power_on(data); + if (error) { + dev_err(&data->client->dev, "Failed to power on device\n"); + return; + } + + error = mxt_acquire_irq(data); + if (error) { + dev_err(&data->client->dev, "Failed to acquire IRQ\n"); + return; + } + + error = mxt_configure_objects(data, NULL); + if (error) { + dev_err(&data->client->dev, "Failed to configure objects\n"); + return; + } } static int mxt_initialize(struct mxt_data *data) @@ -2828,15 +2863,18 @@ 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"); - } + /* Do not initialize and register input device twice */ + if (!data->input_dev) { + 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); + mxt_debug_init(data); + } return 0; } @@ -3070,6 +3108,12 @@ static ssize_t mxt_update_fw_store(struct device *dev, struct mxt_data *data = dev_get_drvdata(dev); int error; + if ((data->suspend_mode == MXT_SUSPEND_POWEROFF) && !data->in_bootloader) { + error = mxt_power_on(data); + if (error) + return error; + } + error = mxt_load_fw(dev, MXT_FW_NAME); if (error) { dev_err(dev, "The firmware update failed(%d)\n", error); @@ -3104,7 +3148,10 @@ 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->suspend_mode == MXT_SUSPEND_POWEROFF) + mxt_initialize_after_resume(data); + else + mxt_wakeup_toggle(data->client, true, false); switch (data->suspend_mode) { case MXT_SUSPEND_T9_CTRL: @@ -3116,6 +3163,7 @@ static void mxt_start(struct mxt_data *data) MXT_TOUCH_MULTI_T9, MXT_T9_CTRL, 0x83); break; + case MXT_SUSPEND_POWEROFF: case MXT_SUSPEND_DEEP_SLEEP: default: mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN); @@ -3141,7 +3189,12 @@ static void mxt_stop(struct mxt_data *data) break; } - mxt_wakeup_toggle(data->client, false, false); + if (data->suspend_mode == MXT_SUSPEND_POWEROFF) { + 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) @@ -3338,6 +3391,9 @@ static int mxt_probe(struct i2c_client *client) if (error) return error; + if (device_property_read_bool(&client->dev, "atmel,poweroff-sleep")) + data->suspend_mode = MXT_SUSPEND_POWEROFF; + /* * 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,7 +3443,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->suspend_mode == MXT_SUSPEND_POWEROFF)) + mxt_power_off(data); } static int mxt_suspend(struct device *dev) @@ -3420,7 +3477,8 @@ static int mxt_resume(struct device *dev) if (!input_dev) return 0; - enable_irq(data->irq); + if (!(data->suspend_mode == MXT_SUSPEND_POWEROFF)) + enable_irq(data->irq); mutex_lock(&input_dev->mutex);