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: 13633056 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E23E312B145; Wed, 17 Apr 2024 09:05:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344754; cv=none; b=OYB6gbRmRvmWCLwBJA2V0lkjzJcePwB3l0yVvotM65qRHT7wpeO3BTa63VlAeV+gPHiq2CGxl/HAHM3w8MCxQ4VSXXfiWD0CHD4OrDqohYiMslpYygfmjZaUHfF2flyzghlTwcqte/5N6F5B9lu+DI6DI5x24pL+jv+uPgmqEzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344754; c=relaxed/simple; bh=I2uzRv1fio39fOCk7iD3y3r9+exYUtMKFcdwVctH4vc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WIdjWmSHZbzmPVI47c/frkFnGDtSeEt/eVA+XSXI0cdd5DJLyhn1UdtvwhlvN6mfIfV3TBYoC1kXk1D/S83JxBuwJiqEJ8RcAASdnOrQN4ZLcy3f6g91eFMngcfmxHuaXrgeWLtmQpkVPsLUCVccL0y054NGiT2zT6heXpgVe60= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=m+Xz1SM2; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m+Xz1SM2" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a5224dfa9adso104398266b.0; 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=vger.kernel.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=m+Xz1SM2oTTFMb+vo8EA3ktxlxkNqXE4hlxDezVl5Unqev4EzOr5lyW/TEMhM3Lvhf HICAT0mMewXA6GHnGqIziFGbpryq0dfVEBDNJA6foba9Vj2YZUvGtK7rutBHtR82w9T3 upeSzwnnncnCvSvGpEeYVFeO33L1bQHE8k9/pV1QlhZpLQo+5ZOB2JLAf8WCia5WLqB/ U5wCs+Ux/+uOFiS2XOMgrzXxXtlkhQZOXWtV9lGxzJePDrZXFWcglmSnxA5sLPSAc7+9 rvbwXvw8Nj9SAmZkLeM61UOM044J4u2URIlXiC4sJ2L0UhJw7qI90bcFIOLDzlGTlMhc qwGg== 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=MFu7VyKbJt5jPKrDPbl9HvWZrv41URsiI+OVHyxxpmIm/4zcASOQ41bTwPgHv8jXEW D3+um/egf7feo3KbeMJ6ZQsSFFjHuN/QBkkwwBioIaVv4mpbFia+gWk5oIBT3aJ/LQSP 01Pv0pzrlF6Xzr9FBwEBai2UBS+qNAhnCusMBXAxaAtEUuuWqomURLRVX0tfl4TheZlj S6ggmffOzBXCLAbiitfPGf17ztETnEjr7yaVSCONOZqIhI0lesiwPokVbTsulSjvXx0T GXqksD3xSRqb9G2Fq5eyQZgQRNwKoG+rDE04zWBsya4oMpcBKdwvRdYuEOJdcYUQ2bwf Suiw== X-Forwarded-Encrypted: i=1; AJvYcCVkAa77L3fOZlkkJnzpWAYmnOi04Oxdo12cxkbLQIcqqX9m1fZC1M0TI7lLVXZwNKWWQUzz0V8+sotDt87YKAe2UER5GRUM7ngbEi9dDaAq+OLNdohLxJkfEkqwuqkmEyMqtZVNXgCRRQ== X-Gm-Message-State: AOJu0Ywp/nz0MOhg3AyurdpPCFnqqZhooB0P+74nm4WmY4KlSBuPkcPK EizDwpnr0dukfj2Tdnt2Dfx6EYkfdxtQWAcQu4XPCtCNNFgfrxe4 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13633057 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73C2B12EBDB; Wed, 17 Apr 2024 09:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344755; cv=none; b=i38zvhzMrcALzbT0OVFwybHSOiQ7RkpIld2ij+HR091q5yvB0hnBGmSfasGfNwAvmEvqhtIRBBWmAms/HzVETE0T4WGxHNYO5DgbDMLvoY4Qgjbd01l0aiheQ1pXCNyHtwf1Oujz9PXvyYPu39cq/oIFeX3eVrC8zUOVEec9u9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344755; c=relaxed/simple; bh=2uYsElcOefKMaiubXZtKV2i4KRiPwfyEPELaTWFTBvw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cN2oR8esbqs4Uw7EQuuuq2k0cnxTqIBnnwXVVC/etWhb6h1ysmZ7KI8qU+fmiOMJw+Z1f8HMysJ8l9sFAQMNfnIutbtAEe/DCuxpqBpNOgCsrE2Qm4Gwn248vzvUMz5jXEp0ZCU0lvyfaeOaCCanEjWFQp9D7Qhvn4MfF4Equu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RhzdD3LA; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RhzdD3LA" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-570005cdf62so4553343a12.2; 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=vger.kernel.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=RhzdD3LAVTtx1rDKTSB/fu1J0IPiBi9+zaMHckxaGEMwxyjZLyePzEL5qwfbwGWJSn 2WkVyc4i8ZjvdIJcuo1R7kL9HlQYGbAnxJFOrU3If8MIORwzm1BY0QqslBr1GtwPT5r9 9AA+8nUfbqhVvP+DttBQnv6ME1yBb8t1N1GfB4qmkDP3yBHwIttVQv8yoGqgoeMspdyd xScSO+mwDeO1a22J0H9CAJJj3l/yubsNCorwRGq+TZpsk5ZcaVK+toE3V+UvdimBeUoc M7JttkTjIGr3hi540eSzkJMTFdOXLI+LifuhrK4oC75/acb8qmj9/L4Rbk7pOMbOOJHZ Zk3Q== 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=VkSxY8Sm1QhxrhbVNO6n/eevk5UaM+nJO2q5zAxa72JS2TUB7fIMeL7EgvTS+b9L2k QToN5ZVQJCEg53Wo+BUN9iycCAhC7Cc2EDEJTnJjvY9n2U1k2iQoSgBTzf0ZLE6HcqtF Nqkb8dynCb8Bn6DjDQQ9uNgC8jCOdnuqDWM/kg3lh4t1YGX7Husg/F48bYhLs/v8YxgK IuVzdhP7MDP7iFOLq0KsBIWG10H4XZulY3QoJbkSKAoz1OKACOzam1SxaGf/7s9LvSvu VJGMSnt+OI49NHp1VqJt7rUaRlBNPs613ufoNJYKpcga1g6VrY4fphLOGy+lUvBF0IRK glzQ== X-Forwarded-Encrypted: i=1; AJvYcCV0zLPutK/f7xXyLzX7byFgPYl7irUIVjAbPM/73q4/MBePcSMQnBetpF8LufA72CHV4wcHHWcO1DwP4xJ77tFsjDim0DVE9nk90W4yMRuREFowptCwGH4MSLbKCZ3oFgm17O4AfzEXgw== X-Gm-Message-State: AOJu0Yx4vEVBbGN6CVvz21IawNYLEdqxE26//qgPj4U2xFBky5urIiCb T1XAW/Y2TzNlo2XhTlkH4IqCqrDoyv/mjnrh34JOU2l+S7vThfeN 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13633058 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BB0457898; Wed, 17 Apr 2024 09:05:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344757; cv=none; b=TxF9bgYf6l8Hvube8XKfO6EgWNQ5kd2XEUjKkmr3v/FZAhWc+B+oileaCcg6HoXzAFYFWaFo4F2wFwOlIc2OYr/MTnVIKiE7fK7QdnuyHYqu/XF5eK2kAPJMpAMR/uS1rgyahqsnCKDcSMSy6HqXwc3tTy05P/jELcM3jMVNZIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344757; c=relaxed/simple; bh=t0Yp1kY6qtM37V8D5tGl8e+xZzRSxjruApL0YIVR4Cs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kUlmGvss7i7P1LlAd5oieIPZVgxxVCQFrT9ltkVqiL7YhO1ErO8XUZlnohZ1HWUcEFwUNXLsnLpFILZePPyPQSoVBDNx12m+sXULyaWD+gG/wDgRWE9QYAStzl1vuAhxepG50zJ13BMJvGFaqX84l5Z3RJAihfUVBfsWPKV3OI4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=i+zuGh8r; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i+zuGh8r" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5701f175201so1028012a12.1; 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=vger.kernel.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=i+zuGh8rKomRn6KSCG47IAnmsZf/Q9We1UJzgN13VYxlNBHWW5h47v174hwQZecImd FV5fB1f5WCkn60UvLFuwVNLHr7ZYwEJSwyGwQRabzpbWkz3CtLqe3b50Chkn8cdXiQDU hW8MZX5EOPB24XbKnRgoHxFI2Nb5sVqbXvsn/Fj8Nu6Hj8iVC1Y8IBVnW+dOEYjf2RQu u1HLTmhGYPyfQb0r7tbdxTC4JEvu6c/uUy4ORSUQSu50mmPVa99AnhUln3pCsFoDRKJh ZmEXoyWOmo6lpXbcxULHJ6S1NMfdPT4EoNXtXhU13hGmaPNbCx6R7pvqIMAli7g8/RGL YHAQ== 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=p5ZRTaWaPxhdSYTEfo3ks55Om7Ub3+B6P1flEsNDiC7fSDbx202bGNtApCXou1RmIV +Igo4IJZ8j/SCT7pceI9pIE4g11MqyP5RzTRlKTRsTCHVetr8fM8M2aiOOMR7CWQLeny zRw8Y1WAbfZ4GF1LP3pg6wY5/AF0FCyKM4BeE+dJybAYi2xGzdMdHSQvApvxNVtzglBx IDHzZ44mJtHBPj3D+hariAG3dI1xnFzx4naW6GRbyf5yk68In2SOhVLMERZXPg1Vs+oI eZoKmmZDjvdDFLUhi2tlR+oS7/lxQbRQyIOXiWdO4C5hQ5K051qrz2yQMvvk90mtv4o+ mTnQ== X-Forwarded-Encrypted: i=1; AJvYcCVTEAqjH1yJQLy8vsRx+MneJFcDytSKkk4pSqXEKLw7cTWLH2IxBYVoOMEQhPQYQ3Wmg64iWf520wtFaQXLUMIcLgM11ljcH/DzdFFua2Ama4sBFABxi+aPaMoz9gk5rN92kQF9YDcACw== X-Gm-Message-State: AOJu0YyUy10x1tZvIzuT+K9mZOA+aof8EigYqJJ5rAX5ocm7wFm7sk7/ 9Y8IhxlOa0+EHb1qVE03Q8sqyRNpINtNV/zWWwJb7wHexuq6k+qP 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13633059 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5338112BF30; Wed, 17 Apr 2024 09:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344760; cv=none; b=M+iksfIqNwtoq7eJyBLCkZeQpEiUNxW+deX1Ksg9CcatP1NCiLEBjBOJ7M7mCey9hotjvzuI1T8d+8v21kYMzA3xQf7XPQlUxjkkXTzQn2wkKi8TbwG7YlRxz+9vdxssiyVcRme2x9fild8uOEs8bo8ycw2DJomm643ujyR04o4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344760; c=relaxed/simple; bh=taU1a+PvqEj7zU9d98qqcwVmANraBiwZLPOEA43082Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lYJvViRUTnyLhv0nGjtXICvPTl2CE2AQmpbK4iPpEEaMDmLNjNUp1RA9OIP5OfmK2NDYadKpm97aKerYa9TZOQooKDmgAlzrKSbxgEYCLFGPL/Y6mlXjvM5KSHMpkMDhbE007bKVTjQxlUOXSo4vN2DRa7XQgMuuWLs4+EPKBto= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N7ZDe6vE; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N7ZDe6vE" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5176f217b7bso9476367e87.0; 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=vger.kernel.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=N7ZDe6vE8un0C8X62FoeBZI0xVDVATzMKqoMXeeT2/GQH7UfiBetpDC/Sw4Tr+E7gT 1vDPprmet9IBSxqRzPD2IEYoBGvc34FGk0LTdUK1AF1UvhHu4YZfn1AiNhw2kq/Sb+gM KUtQVQWPZ+z0EnXZdK2mhJQSB4YjX+Vx+qW5Ps5w4I9ePAjsf0lIGShg772DFUs6G269 h0Wt96vDQKX3lOJ65PR/peaAjtyz4lkQ2GMOczioDN6eIly5YxqaiMTBpzaW8K5PIlyx v/M7e8Z6u4z4Q0OKiOI/KkbbhqCeG2ajlCXdRF+Cl5qSBBrFfF5n5JaFdSK0Xg3k4o0H CyQQ== 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=oKog8jW1dYWrneaFYApLk0eMLc5QL/uLAJJX9ysBHhM4KdoIN1mJoOszyTpFznJuU+ tSSLO3UUdq640U4uyHEpTnkT/p0kvBLgE5geX4jL+b+YlIoVDSsnzumVBuoH7IRuY2Ha FEgbmEchiGd+WxqXZbGePlbeIBQ4NDt89AAcB2tgpjMpOSkktgwcxyIJ/WBevcPH5+yT 74Fi3pAmYkpuijyBA/yDv5DMMOGJsNVENzsjUqB/lMPN32iJ84Tkp6Gfs93YJaTA07Vn D+Hn01x0f6pBTaXa44tnUo2IC+L8FY79Ylz/NMUoilHUSLxlrLveb1sVFgUwvm2N88F6 nJ9A== X-Forwarded-Encrypted: i=1; AJvYcCWAHSQX4FAtlO5GnojlN+69Li/eXc0pVOycNeMvlhwsJMNM9qMmPkD75qdmhOGn6ChqmYWbjhwZsUIsyo4RM/3rxcTtjEbEK7OYe6iN2wClKfEFvvyyECzriOlqwE9laJ42TgwVAhNf/A== X-Gm-Message-State: AOJu0YypbUQ6CdZGLl0qezDficeUCgNrFqDt8wjicMxDTcG9O+7R6DM3 kQ3T8kUqgHyHgRTvT2xU25C/+X2oqf9ns33rmf6thqHy/xvZm1Ar 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> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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);