From patchwork Fri Dec 22 09:52:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13503128 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 94B6DC41535 for ; Fri, 22 Dec 2023 09:53:41 +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=togNmaA4okHFFWghJ8sHKeVFQdiKcYFfxhamX0irA6I=; b=T0Xpfxz+XMXfCn McN4NF6Vx67B3HR2+a0DhT3W4Bu5IqmsS7B0v1AYTvOo5Rtpi6he61HIcejpW57+u5B4BwktBCEPX nYBjyNt344nZt3xPA+1ytO0za/DzWsb9aJjF33i/5G2ZT2mRWSVfBi8fV16Nb1WSyU2rYoghHBPXF xVLEfirteDtWKZN061VfI2Bkz+AmUEEZrbOfJwb3RZenRUiyI0c+COWBfc3Mh6XLHv48dj2RGJSN+ mbPBnzw9/BrlCzbU3Ve4R25zB2GqvRenqf7zOceoPmpr6BdaeDoafdoJdGuRJL4abtMSVgAuIZ5zn J6KG0qIdoceFDILCFRyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGcDS-005Tn2-1p; Fri, 22 Dec 2023 09:53:14 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rGcDP-005Tm0-0b for linux-arm-kernel@lists.infradead.org; Fri, 22 Dec 2023 09:53:12 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a268dd99597so198823866b.3 for ; Fri, 22 Dec 2023 01:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703238787; x=1703843587; 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=pv5du8nTtlBmNN8G6GAX4FSGesWSwqNtRVmismLP6Po=; b=mbGi3F3BmUPM63Dom79kD0OLWfKE0EL80jXrnOOOASfuPdRZ6rWSPloUybvyz/0Dnw b6iBtiSkTF3ya175fe4yiiTQwoZfdOcE0pwrG6EwpnFyHv4O3wOEy6fgQch1UCGSuyfv nC/ZUf1VtGErV46ONWscEj5MS1ONYw/eFB7xRZMK6POxkqY6Yz6rTHv9pM2hnhstmmYI Hduh3DmVsfVo+hQ/FVmmRX2MaZpOx3qeDAgy41nDvPpWCG1H8Cj9CbDUOt71WB4OPZ5T 04qkHC67Up/qwf/SeNqUcV4AS3qbpfKjnh41PgkVPvaNj+PV4vxz4TXUDvt4QUbHrXK+ yfQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703238787; x=1703843587; 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=pv5du8nTtlBmNN8G6GAX4FSGesWSwqNtRVmismLP6Po=; b=J6DU9N0ta9wYzgthmH2YXa67czWd4aVv/nW7OF41LK/zx/qEOVBewMHZHIcQU4mDU8 7yUTf5Yz91/iCgeOofMRWcIZ+rMTjZwn3Qce+ZN1GzbklZxTkeyU+5opPCTvVPbYhdRw oeoAebFESSvHH3GYHba+E0HjMkLTKFKcKFM+cDeeCLFFzBC9KSIYNF6GMK4OtDex7eVX FYPG8eXZNlHkMPv3fKvknDfP5G4PKaWi099oWTD3PqrR2bb1pw0LUlCHkUt2HlgeAxTH hpxvC98U19JvpS4UkCi20XiaFb3iF8dKjj7BvoINS7SE+IsRdFta6e/NSLGWjynHm5Di VK2w== X-Gm-Message-State: AOJu0Yz+/2xhYumUkxdFU4WVadzJhpyXpB1LB/PgP3y5rQUdcnEvRIx6 4iJPQNJ2FNH1bVgTC5F2EFI= X-Google-Smtp-Source: AGHT+IF4XVGQoCCX24Fe46dZLkremdlMqaE9o0+oyenbWtT/gNJ7oMEVag9MCqloaEfxy96Mbg9UeQ== X-Received: by 2002:a17:907:9842:b0:a26:97a1:48f1 with SMTP id jj2-20020a170907984200b00a2697a148f1mr267161ejc.81.1703238787003; Fri, 22 Dec 2023 01:53:07 -0800 (PST) Received: from eichest-laptop.lan ([2a02:168:af72:0:f05b:3f84:67d1:580]) by smtp.gmail.com with ESMTPSA id su24-20020a17090703d800b00a26ab41d0f7sm1311838ejb.26.2023.12.22.01.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 01:53:06 -0800 (PST) From: Stefan Eichenberger To: nick@shmanahar.org, dmitry.torokhov@gmail.com, robh+dt@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, francesco.dolcini@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 v2 1/2] dt-bindings: input: atmel,maxtouch: add poweroff-sleep property Date: Fri, 22 Dec 2023 10:52:57 +0100 Message-Id: <20231222095258.33369-2-eichest@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231222095258.33369-1-eichest@gmail.com> References: <20231222095258.33369-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231222_015311_224454_E3F68583 X-CRM114-Status: GOOD ( 12.37 ) 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 Fri Dec 22 09:52:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13503130 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 A970CC41535 for ; Fri, 22 Dec 2023 09:53:52 +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=Dd7M/Dwgu+m2Roz6WsLGOoDWLshZ9SAcLZeE9e3SSVw=; b=kRvibPRackHnGi iAD1IMBkpjF69ZKhwBWZwrkXI9hIdc+s6uSi2cr937CYWERSo1rG7FfPMocDqMRlgs0ZDA6Odalxb nhfkSvOkZ4BTMu8p/C97yWenlRJnfNW21dBdeWabP7+uND9MRyIZovaYwrSPdN7pbeL20A8O7mwKU eGiMfDCuoTcR4KV/X9cpUSomOOKXeRbq7JJnLUjBd/tjTnRpNJ/oyR0DW+V8ne77WQsNkbCmzHERn nIKHxEHPltqUEe1tiEt02CcRQ9F7rgc6NbVsYmzLCgK1PcHFGXK/zcbC246M4R5AjsTGRit1x/MFG MN3Mf2H7cvuoK/ps9SgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGcDe-005Tpk-1O; Fri, 22 Dec 2023 09:53:26 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rGcDQ-005Tm1-0B for linux-arm-kernel@lists.infradead.org; Fri, 22 Dec 2023 09:53:13 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5545139bed4so560213a12.2 for ; Fri, 22 Dec 2023 01:53:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703238788; x=1703843588; 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=/MJR/JY0wBte1fc/3m6wZPMOWo6cUDvO9p3vgn75NkA=; b=AD+2jOh9lt7XTYSo3wbXwA8iUskc7AGMDx9L3hCnWe8IosuJTo41NIYx5W1O/T/G7I SbtD9dYvnQMtATf9dKYqE2PTPzuLXVQPMCNf05wyKxDhNu+2fv64sJcgdvjAAJGP/+2J RECe235CekBtvplLIJ8nJ23TcyCVsDHfTI/uqb/V5LPgWgqIpSj/oh9rwRCbBISOKChk /32X7+AcYiB6WyXtGjp1J2buXdx/yXmNFJawoZ9GhpM+dK1xdoYWWRqTrn7F6X/D9pmR 5Zas9kRC1kDECGUouqdPRNBQcIHWOPyuJfBAiGdFPOx2MZO5ssekp4jW/ti7TQNZSvGO jSVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703238788; x=1703843588; 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=/MJR/JY0wBte1fc/3m6wZPMOWo6cUDvO9p3vgn75NkA=; b=uiYpsucGF7lze5yulofge69EWF6AAa6FhH+wEgDOH7h/0iPVNzdUL0Z3R+piE+bN2R FLDx5ayTivu3PcHT1BS10qp1ozz4xZwu0iY9l1iQNE1NXnbY0C06fS11ls7OwyQg4yPv Ao2cZ7CplXe4fg70BkgzlHZ/8IAX7ucACS4IEqMpuZZj0vmT5hA80uuNd+sxPy4jHTwg y3WQJiI8vWC7YWZNFSExih4U1EDAKNWAg56K+yFBKaKndtpvQPJEoltDMwiO0zT9oNkV 3ZWfQcnxsGVY4klUNoViEYdkKEmWpiYwyV1cfrvEaG7hUoeHjS3dKMFAwR7WMT+t6Dg8 KNIQ== X-Gm-Message-State: AOJu0YyL753kfn0CEnlocHQTYJAkhBlUQsqilAM9hXESUG6cywXryMdv Y7v6u6ikgOBvkWrbf8QLGrU= X-Google-Smtp-Source: AGHT+IGNZG6q+jBr/NjK3sVAaow4C1vwD4Ug2rmqwznnIuzhETk+TQFxXyO6gVVqYzj4smJwcg3xCQ== X-Received: by 2002:a17:906:7397:b0:a26:c595:62c7 with SMTP id f23-20020a170906739700b00a26c59562c7mr91716ejl.122.1703238788266; Fri, 22 Dec 2023 01:53:08 -0800 (PST) Received: from eichest-laptop.lan ([2a02:168:af72:0:f05b:3f84:67d1:580]) by smtp.gmail.com with ESMTPSA id su24-20020a17090703d800b00a26ab41d0f7sm1311838ejb.26.2023.12.22.01.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 01:53:07 -0800 (PST) From: Stefan Eichenberger To: nick@shmanahar.org, dmitry.torokhov@gmail.com, robh+dt@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, francesco.dolcini@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 v2 2/2] Input: atmel_mxt_ts - support poweroff in suspend Date: Fri, 22 Dec 2023 10:52:58 +0100 Message-Id: <20231222095258.33369-3-eichest@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231222095258.33369-1-eichest@gmail.com> References: <20231222095258.33369-1-eichest@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231222_015312_092996_9F0EDDC2 X-CRM114-Status: GOOD ( 21.87 ) 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 device tree property to indicate that the device should be powered off in suspend mode. We have a shared regulator that powers the display, a USB hub and some other peripherals. The maXTouch controller doesn't normally disable the regulator in suspend mode, so our extra peripherals stay powered on. This is not desirable as it consumes more power. With this patch we add the option to disable the regulator in suspend mode for the maXTouch and accept the longer initialisation time. Signed-off-by: Stefan Eichenberger --- drivers/input/touchscreen/atmel_mxt_ts.c | 72 ++++++++++++++++++------ 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 20094b9899f0..3f7f58f1c930 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; @@ -2799,15 +2800,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"); - } + /* 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(dev, "No touch object detected\n"); + } - mxt_debug_init(data); + mxt_debug_init(data); + } return 0; } @@ -3328,6 +3332,8 @@ static int mxt_probe(struct i2c_client *client) msleep(MXT_RESET_INVALID_CHG); } + 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. @@ -3390,12 +3396,21 @@ static int mxt_suspend(struct device *dev) if (!input_dev) return 0; - mutex_lock(&input_dev->mutex); + if (!device_may_wakeup(dev) && data->poweroff_sleep) { + if (data->reset_gpio) + gpiod_set_value(data->reset_gpio, 1); - if (input_device_enabled(input_dev)) - mxt_stop(data); + regulator_bulk_disable(ARRAY_SIZE(data->regulators), + data->regulators); + data->T44_address = 0; + } else { + mutex_lock(&input_dev->mutex); + + if (input_device_enabled(input_dev)) + mxt_stop(data); - mutex_unlock(&input_dev->mutex); + mutex_unlock(&input_dev->mutex); + } disable_irq(data->irq); @@ -3411,14 +3426,37 @@ static int mxt_resume(struct device *dev) if (!input_dev) return 0; - enable_irq(data->irq); + if (!device_may_wakeup(dev) && data->poweroff_sleep) { + int ret; - mutex_lock(&input_dev->mutex); + ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators), + data->regulators); + if (ret) { + dev_err(dev, "failed to enable regulators: %d\n", + ret); + return ret; + } + msleep(MXT_BACKUP_TIME); - if (input_device_enabled(input_dev)) - mxt_start(data); + 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); + } - mutex_unlock(&input_dev->mutex); + /* This also enables the irq again */ + mxt_initialize(data); + } else { + enable_irq(data->irq); + + mutex_lock(&input_dev->mutex); + + if (input_device_enabled(input_dev)) + mxt_start(data); + + mutex_unlock(&input_dev->mutex); + } return 0; }