From patchwork Mon Jul 8 07:15:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13726242 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 C7402C3DA42 for ; Mon, 8 Jul 2024 07:16: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=mfZNK8ph0Z0kRXxMHVT8gSKe9yd3fBGYFdN7lqgFzvQ=; b=3lbihnwb39iRj7BmYPLGYl+L/8 K4QC+2SpXg2CbXlqc8vvlG7akxAVr2gxq+vi/CP1ZQcYyziCEhUU2+Byp3JLSEArbEIBkJFWYgkTw lAVgxJE5zt47Txk7hZ1EnxqWR6eU3a/5t01z7wLpOuYOyBQNyqRku9zgVgodSEOvLYq5lYzvcefoi GYskXEbd6WOC/Q/ZeSfDUhxjvvEocYeWRP5f7kmdpmnMoQMB8+k1KjMXNNmG0tT41aokpq9vsyHlH pReKUK0CCB0hGpUPBMfM6kR2CYmQoEq605lbHcRNzI2i1e7dVxTlTN51xWFr/Crua0eP4fmd2izEF KqAqhEHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQibw-000000030HI-0dk6; Mon, 08 Jul 2024 07:16:32 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQibY-000000030Ad-46iD for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2024 07:16:10 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-367ac08f80fso1368121f8f.1 for ; Mon, 08 Jul 2024 00:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720422967; x=1721027767; 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=mfZNK8ph0Z0kRXxMHVT8gSKe9yd3fBGYFdN7lqgFzvQ=; b=Kmv8tyqGi4P2MPFqDOvxZ1VxF1poNCauZ4iXtYdWOOH5Vo1gVB7ApiTrPcpmZSGqHa aEIh43GKzmirHJaoz2zqdI6rYbibk+mO2yLrqsuk+j+bZrNXKvVZUzqt/55s/0ASlf8e xSecbVmb136LvDYnfZ04V4Gnmx27PKALcZoTrBOzdOvPMCPg1IaAdgKGMWhZpFDLTFFk 8r3DLL8NgRFVUV4AcgYNdDrb/MzaXxMywsAJ3bOXUBQp/phXsU+G8+vQ5mrojSNz8xO1 Z8HBr1oJhgPGVJrMzIoKVEdMQOgwNgruKdTDoYbanVxKAF2zJKPnZmaW6O26hW3Spovn bupQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720422967; x=1721027767; 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=mfZNK8ph0Z0kRXxMHVT8gSKe9yd3fBGYFdN7lqgFzvQ=; b=ssqFIjYew1hEJ3/q1qtPQJBLhgMX9BDKTEdhI9TAhakYeFtjXFBRDJ7mtQYJuWlV9c UxRzUmL471nLcKY/hDNmlikHfxqbjHM6AW1nppL5QThtBUbupHsyza1AYk2h8+tTfC5G RP8kP771iXkDekuOQj3pOQfslSHcoEUp2P9j8XL9D7h8PxmD2Xq09cnDwagfqSMsI+oY RI0tb8bT4M1Q0Pi/P1bis/TusVE0uyPClk9ePMwxXCujEWuCVccUVJnI923UvxS4ucRl qBOQpu99bmosJVOS91LBr6qtcUTVvPy+R447eQa2EahGdk4BbWHM08cSZbGSB/sOnqlQ S43Q== X-Forwarded-Encrypted: i=1; AJvYcCWJjixO6NYJKuPU10DXuWOcXWIxsh5awJHhoeqoGi2MVltibop70W0WycOsLQKddoPOpGmxy9LUx7B7z0ZVS+596tRzPqVhKXzvCLT2nI7IGQ9YHsk= X-Gm-Message-State: AOJu0YzMjX+tdmYXKC1XJ39j85e8JysUJqYqWqkHwXLX/rfdFQk1p+xS YkiwPlq3WijszQIduyCTj8fZotG+6ehlJ9aN/ZVuN/uJp9IY3KcF X-Google-Smtp-Source: AGHT+IEfXpYJIxjWfYoWwblocqz4NtB/iP3ACED3Sw9nHHRXtj08ueId6szvEj11L3N2y52np3X2sw== X-Received: by 2002:adf:a1da:0:b0:367:4dd7:288b with SMTP id ffacd0b85a97d-3679dd34fe1mr8019816f8f.29.1720422967317; Mon, 08 Jul 2024 00:16:07 -0700 (PDT) Received: from eichest-laptop.toradex.int ([2a02:168:af72:0:a786:d603:1c55:ced1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3679dd5ea09sm9994564f8f.65.2024.07.08.00.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 00:16:07 -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 v5 1/4] Input: atmel_mxt_ts - add power off and power on functions Date: Mon, 8 Jul 2024 09:15:48 +0200 Message-ID: <20240708071601.7571-2-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240708071601.7571-1-eichest@gmail.com> References: <20240708071601.7571-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240708_001609_046525_B0FC276F X-CRM114-Status: GOOD ( 17.22 ) 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 | 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 8a606bd441ae6..4fc83a4cabd9b 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 Mon Jul 8 07:15:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13726243 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 3BA19C3DA42 for ; Mon, 8 Jul 2024 07:16:55 +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=NSr6W9+kIBrExV7rAUXxvmIpCII4LVhMfKMFiF1UZnE=; b=qnzRw3naMJt9/4iLe2Ctx7XPXd TXguv8g03kDytDAIk21aPCjA3MwAyHAfCSP9DQvdsPe+0s1Vw3hFy7TSe3iKcJ+RN0GlAnKNwskg8 SNPFyr//rVDKYRaAYoEUOvkg61iss5+QuNDWKzLPawmBLT8pVrEu7OxFvwcNgU/A+3/mHEmvFWhfa zwKEGf50UySR/nzDbwf5DIzAKGZb/1jSicWZYdl580R0uHwljDQA6GtxLmGVauHPgOcIRPsfe+MJj uhqXNlSDZF/QR1pjxa07iBxChxlqgHnaV3traYrmFQ+82R29Vr6mis3w0+2OLXJ/5QwRqRFiG/pk2 huPtE3xw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQic8-000000030MB-0ty6; Mon, 08 Jul 2024 07:16:44 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQibZ-000000030Ae-47Mh for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2024 07:16:11 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-367ab50a07aso1704956f8f.0 for ; Mon, 08 Jul 2024 00:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720422968; x=1721027768; 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=NSr6W9+kIBrExV7rAUXxvmIpCII4LVhMfKMFiF1UZnE=; b=F70ylvaCQrtY9CzXnGu22GTj+rzti9QeSJkXSWHuMiiNBvN1N1frmjZfO9pz0h/+zB UFSqkhB7JLck94PWixRj0QW0p+2Lb/IWHrWcHlV+BMWoR+m/DPAzYWLrFnTVrptM/J8M zxbcaD73n05CtImJa0Sr3KaVwlZdsLNPAWPR5OGHZ9F8opS4fTKd9DOL1kEaqtVeiqtu X2c7q0/6f7+NFaaJTmcZly5gJkjCfkpihhuMZVNhMtHdExSWlkNlwOmDy9dtXR7KuNRn wt1m1MjaIoMNyOwfv6zl5NfbJsXb/2viVqSKRp7puBsWPZaI45OmhbNXqYcJA1c1mQqT RcvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720422968; x=1721027768; 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=NSr6W9+kIBrExV7rAUXxvmIpCII4LVhMfKMFiF1UZnE=; b=ovLLWvu8Tftet5R+O+kLrxj311XepKqIlEIqSP0agzeTF4qZYDlGn90qz3Dv1gENQh 7pHLI3xidsvylCE5gOfDmDql9uWvNn/zezYTHVNxOWJUNKFgYC/K0P57vlcaMPIMOhN0 q5ltmlD5BWbOKod8C7GoOFZEwtkQdTleQG4G0DxVaijCBluRfZqX5bdRK8MBhI8LTMeN 4vP1AkvI51AafBe29WIQi0WQIz19YxNKJjOmMX2vprwWB1N9TvGIsYF5r6D5UU79iyKS PnvgjlCaJ+US9EhTt0IK9IOCEllM+pMdSzBYe7SHLPaMzth9HqAEcvuxZs0l+ieD1VUh MD8A== X-Forwarded-Encrypted: i=1; AJvYcCWwM7d/DqgLZkYA2/iuaap49m0CwGTM+ahNXjNFTqJ8/cXqYW41XVGs6EewQ3YjIFAVi0yRcgfv7jRF746qOO0i7bxXElULyL7eP+nAUNRgmhCZDrg= X-Gm-Message-State: AOJu0YxaKC7W7hXm2SxdRydRmiVSvyCTGK9og4rEaaAaUYFmzwE1O8sg ri8LSOVdI/eht1RvXiCGhURN/6rGJ2yUqJx4ILY+TE8bfmyXVzNN X-Google-Smtp-Source: AGHT+IHrzhQu0plLHQSnW6EQAbhlLdpaa6G8qkl7Pllj+JcKaF9nRXS7gqQjM6Ofo0NmYv4Ov37Elw== X-Received: by 2002:adf:ecd2:0:b0:35f:1dce:8671 with SMTP id ffacd0b85a97d-3679dd29926mr7019361f8f.25.1720422968305; Mon, 08 Jul 2024 00:16:08 -0700 (PDT) Received: from eichest-laptop.toradex.int ([2a02:168:af72:0:a786:d603:1c55:ced1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3679dd5ea09sm9994564f8f.65.2024.07.08.00.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 00:16:07 -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 v5 2/4] Input: atmel_mxt_ts - move calls to register the input device to separate function Date: Mon, 8 Jul 2024 09:15:49 +0200 Message-ID: <20240708071601.7571-3-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240708071601.7571-1-eichest@gmail.com> References: <20240708071601.7571-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240708_001610_045926_4E70DF90 X-CRM114-Status: GOOD ( 17.83 ) 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 Reviewed-by: Joao Paulo Goncalves --- 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 4fc83a4cabd9b..85f3c685bf526 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 Mon Jul 8 07:15:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13726244 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 99668C3271E for ; Mon, 8 Jul 2024 07:17:05 +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=aNlE4txqJZOsU+41LbXggCHU5j P5jE5eNhH0qWSYkw47ZSGKHDxwA8VJFNKgKNRVHcrf7c4kCkuC2dtwmaium+kcyRZAPdloYxX1vsm ZOme4qB+AcRBXvyBkUjA0N0IqVjRHmYXvYRmUCz3qujCAqJCgEiub6vB3KNsBquylFFvGqK+zo5UN BSdeRT8FGyaMk1jfubVAl90tIwi5/sdEVZMsl27oqabo4Wuz9oRJmvFE4t7DKqGPPYBncEMyvTyd5 LqNWqaCO5lZnvtGMuyhsk1Q7B8Z1Itd6UeNx2QrJZaVT0BefpqbbEA/ua/UNw+yBSs7vXCpREuutP Fqsom5/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQicK-000000030Rb-2OWe; Mon, 08 Jul 2024 07:16:56 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQibb-000000030BC-3Iz4 for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2024 07:16:12 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-52ea7d2a039so2546877e87.3 for ; Mon, 08 Jul 2024 00:16:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720422970; x=1721027770; 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=Gbay2GlnFayBdTL6kYzzFDrgMlxfuNkcDk4cPfLLGyeA4F6KyofL3yBOUyn9SzdI3+ L9KfUJlKF8ufNs+GasKu5AhggaGZs6914jLhed45IWQ/ETWyOBv8BAdmDnfsatTNcZQM vV8FWVcrlWThOvWV6mgidi1JnlZwu5btEUBvMaHln45aWw/RiTtYGW7lp3rxKbh9bOmj pJUWIrHnHUhfyuOpPGQA+6ancsOSIkQfePWbrPLDFeepffUMbTORWknlOViQpClyi6Pm r5QaxXKMpeq1BZWTHcwo4hqJD3uGY0v5wLdJWoh2eVCH9nXx8i6mCx2k3JzLPePk44qt dwdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720422970; x=1721027770; 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=YYNG2srBoQGIG23fcJsTSjNP7mjLcRzCEX4lka3mLYZsDIcXszqGuyeEwGF/SmsW4H KHDlENToxcyg0Ywl0UMZDd7/v++gXSFYRBAmqhfq8UICVJ8m3Tw/7pQ07+eSr3g4i3aD 8sekXu8vorpVyf6+BSk6OSqc+g0YTKE3PwHgHXrRIlKd58wEU3MfDvNX8HlHmgGuUDZU mhUbhtRxaSBAj+tTcPkdwoYKdPXGVoEHeZJ8u+IlnJUW+xRDatLW0hfUmrsIdIa7XG// RDhTfFtpG8wYp+O/+OrB4TXCjmjL1EUNI8IP/6BXyNq5m11y5MlvCbKJVH0iL3iG9u13 duYg== X-Forwarded-Encrypted: i=1; AJvYcCWPcioGNvGVvrkRJUjtKCJvhwnHeA3W4KZBpk07fH49pZdnWcjGPve4EQ/e+kTHqzmZsXIaA3gQ6nGucqd1WmKENqIEIF3TfeSK9LO7YWp0SuPqXDU= X-Gm-Message-State: AOJu0YwEhg4UbPmOHQrnjXmaV4lcsVYOo1aYF8boFzsri2WXk+1FRJKC fLuiLIK/MHcrRrnJBD6xb5EU9+p+Wql2ks8vMe9oMohxz2wuDymA X-Google-Smtp-Source: AGHT+IHcUMix5VO0zk46X4Nnwk0P0vgPnVPmSZzcgZqI6KRivT5tw5aOfPyuvEsFnIqmFpIZxb0+Ug== X-Received: by 2002:ac2:5a50:0:b0:52c:dbc6:8eb0 with SMTP id 2adb3069b0e04-52ea0632ac0mr8398974e87.21.1720422969742; Mon, 08 Jul 2024 00:16:09 -0700 (PDT) Received: from eichest-laptop.toradex.int ([2a02:168:af72:0:a786:d603:1c55:ced1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3679dd5ea09sm9994564f8f.65.2024.07.08.00.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 00:16:09 -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 v5 3/4] dt-bindings: input: atmel,maxtouch: add poweroff-sleep property Date: Mon, 8 Jul 2024 09:15:50 +0200 Message-ID: <20240708071601.7571-4-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240708071601.7571-1-eichest@gmail.com> References: <20240708071601.7571-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240708_001611_850904_C6819B9D X-CRM114-Status: GOOD ( 13.27 ) 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 8 07:15:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13726245 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 6C5FAC3DA42 for ; Mon, 8 Jul 2024 07:17:19 +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=FvhvTdVpDZ79yvlH1+XJiOzGxkpYhrLPBWh5+/JeQbw=; b=uMt5LkJRz2NY9gpwp100jj85c8 ztTz3c83R7en8E7I/wQJgUyMOL7Z2zzKG0bB6QNJx0h9L178iqE773eUkAPDBqaENy1fR0pnzpVlJ 3BTo2UAMoQEzrFD7K2YcatPXa0zCaEdVXREoKgyB+LxNtULl+ZspBMFjgrZU56BcHR5JKYhU4wbLL 6n14EBCzRB+PgtIlAdcxCoTdk13JVW4EU2Gxny145/VVWy0KITyPKsWkeBrK9tSRoWDw6HHZSmBbY 0Cjwa2G3ibqFnAQ+3VNnuzFrcBBdswBXcxl8TOF3YQIheipYv1++dzJpX3vr73HuCAVhYkwShBm9C EcGapVYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQicW-000000030Wf-2bWn; Mon, 08 Jul 2024 07:17:08 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQibc-000000030BF-1MMH for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2024 07:16:13 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4255fa23f7bso23839935e9.2 for ; Mon, 08 Jul 2024 00:16:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720422971; x=1721027771; 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=FvhvTdVpDZ79yvlH1+XJiOzGxkpYhrLPBWh5+/JeQbw=; b=DIy/JlswqS6TfQ77RMOSnfRagAJjoSNYJsyi8WA+47s/rXGDIgt4MZ3zHT2MBjO60l O0akq2psKnGlUbLyNAsUha35FOYBk5JDBs0BgCGQ7tfxCMXD0kMe8yNVo1Fi7EL0x++m OdsPZmDQym3DMS7HTPoMTW5mvZcULrOKD9l7ia4+kier7oms5Id0oXrvmVDeZWSnJvR6 1VDqW08qFgIr924sz0GspKo7+dhvy22MKBj0UuF/aR59KWs/CryNFmezbbbGZDTB6GlG sGHOUyRaOxMyKONbBbQS6T9dXEMa3voY7rdpxz1XE7wMu3GnLYHjrPSTTL6UCOc2kzvZ 7bKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720422971; x=1721027771; 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=FvhvTdVpDZ79yvlH1+XJiOzGxkpYhrLPBWh5+/JeQbw=; b=noiYN6AS+HIHN93kv3HIzwRFVhNYO2OECLWUH8uiB0jCH7BIKvI1bfZp0uGjOi/L6M 4MCnJJT5hvBIWFsyGnLPUpZfRqLm88iq8xNS+zWy1EWIuWQmE+ic05xRoj6DqFvund7u h5+Xl4DphxFjX6W2Nac5RmBwYdU3qvr6G33djDrgNCxEJQTdL0sYG9zV6LgyY8Jykwfr QqCQdvoU/5dszrUaEq8gqO6bNwiW0po/wvaTRZbfos4blVhaaKqSNA6+oP2ILzyyHmUT Qsdr0aq57XnDix8h9G72+3phDOCn8n+r1J51k29avZ/nxb+JoDIikqprM+DvlE0XRo95 UMbA== X-Forwarded-Encrypted: i=1; AJvYcCWVtKFXzuq4bTabEg/qeOyUrv/G0z/AI11qnUPmzQpJ2D8qq0tpv6DCFZXa9VyIDQ5+814Pw/68Oy/FImOBwMgF7eJVZgMD/l1HzC9ehXYbKVSnvso= X-Gm-Message-State: AOJu0YyF5PPl+B3v+A8guexaWXSiJFx1WalcqLFx81rLzH5fTdB6sMZx V1xBqPPAj2ME+86zsVk03LoeEeBpNeIxv057vLKusSflfOQW2avg X-Google-Smtp-Source: AGHT+IENCKvfCZxO2Rt6KDsB7M0kjjFGMdi6MvfCYZJU7eP3x5K0nZi26KF8OMrrBBbNgihafqwRFw== X-Received: by 2002:a05:600c:4f0f:b0:425:5ec3:570b with SMTP id 5b1f17b1804b1-4264a428ec4mr69226885e9.35.1720422970695; Mon, 08 Jul 2024 00:16:10 -0700 (PDT) Received: from eichest-laptop.toradex.int ([2a02:168:af72:0:a786:d603:1c55:ced1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3679dd5ea09sm9994564f8f.65.2024.07.08.00.16.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 00:16:10 -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 v5 4/4] Input: atmel_mxt_ts - add support for poweroff-sleep Date: Mon, 8 Jul 2024 09:15:51 +0200 Message-ID: <20240708071601.7571-5-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240708071601.7571-1-eichest@gmail.com> References: <20240708071601.7571-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240708_001612_390122_A006387D X-CRM114-Status: GOOD ( 20.63 ) 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 | 59 ++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 85f3c685bf526..3bcdbb58a24e6 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 */ @@ -2273,8 +2274,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 void mxt_debug_init(struct mxt_data *data); @@ -3089,6 +3120,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); @@ -3123,7 +3160,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: @@ -3135,6 +3175,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); @@ -3160,7 +3201,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) @@ -3357,6 +3403,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. @@ -3406,7 +3455,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) @@ -3439,7 +3489,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);