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: 812706 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 AE46A18F2CA; Mon, 15 Jul 2024 15:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721057621; cv=none; b=q+EmRaLVvBq3LyGZnOqlxOWvQOOXlLxRT/B6l35/XiKDjD8/+QhWbj1OCyQpNtpo0/slHOqG0erjp3lll1zir9nDk9wSNc/epEy8PxQXpYqZovqnLI3+qtaSTPAGGXAgtSxRn5muHorvY0KAzQMq9KWDlsJK+H027V94rbm2YlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721057621; c=relaxed/simple; bh=w5gxgyW7pDD5OiYuiD/yPeV2bq0/fDV04JlwWC9nnUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SL8NJbhp4fiG1o1FrBT15++P46vL6cKtykDBHt2WOkZN6Mny82M9ADyNmJhielriVWLKFVYAyBLrB2ylILENZ9J0YKUnba51WZ/RT12jmLaYRgxIP42hfiNvK8mYrdq4WargR3X9ZbwWiAgQE8trQFQujJ51SyEHg5lMmR9rRss= 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=QRk9l93c; arc=none smtp.client-ip=209.85.221.52 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="QRk9l93c" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-367975543a8so2738956f8f.3; 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=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=XrCU6G9DnnMkxpZ0nGUhFrVcFHRKc9c76P/tMQAhH00=; b=QRk9l93cTNWatUQIa+m5sUZ8RWwox3CB6U3XTabhWUVjp8RBPNPyf6LPYy/4H2sCGv aOaPqiyEe4KyUTJooD+pAQ8J2UXrsR2TZRVgitis+ztiMq0xcUfTcjhHnnhnR7qxWUN7 5Mkwfvpid4r5qddTPivBshkS/NQckoUsj5pbV49brAJQf3tLi57vidJ8zDiAS1MH5enE bhpeEkpAeUfEDfQV4JXTZr/mGMG3GLPo+TrRszg/lOccBGlhbDHSfk7D52byIZhFAX1v S5aoEuSmKzMLFDzX0u9RSGVtrrdRAMJ8YUOL8WXT+gJHWxLgyVuteR+cJvRlHt+Pac2X JTjw== 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=Wb8UrAwBUHiDHRSP94EB8Ao/jpDPNXCe1hHBcYXs3Vp/Coybl4G7AdzbG48AFc/ypK oAL/oBc1Nr7dZXTUZsQFkNceIwJXLKfXXqFJor8ovxGLiQ9HnIVSNFi6jLyW3oPQpI4c Cf8CEYOSF0wq0A/SKsVP2ODA3iT7iNPThsPP6bBmvz0YovfG9Fcyctsw+sMF2DLiQzr/ Sxgm1spymfbmSq44sLx/8F2e4aZtO3BfSC4Vtut5Dpy4K7LohznFOlZ87j+Gd5RlW2Tg F/jpmQb/eGIvZt1kBpe+DfOvajWorXp7AZ/wtieqCY1LrLtBW47OaNlZmCsp9megGUDK eZHA== X-Forwarded-Encrypted: i=1; AJvYcCUEiuGxe6uwrwVqVCWLMq6Ya0KNXKK/8jkth5DMKn1GNk0v1DAz+DftU2fdVoPr9IINmIMgGLFg/aJO9wFoBQ2fM7wIfJwVPfU0s+tj0h/+czPDp5asVDSR2K6ZbBifV1LCuWk3BaDRig== X-Gm-Message-State: AOJu0YzkoWkD5VZy+9rQOJ7gnsWWvmS7W/4JVV+jxyfhdawjxC/uysVC 3G8dXXfa6op2hnB86zbQX0XMipmhAl/Uk4ft9jJ9Lwo/DJrX2uu0 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> 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 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: 812912 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 D070A18F2D8; Mon, 15 Jul 2024 15:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721057622; cv=none; b=O+e0eyiYqDB7UUQyifW4gLvwrQQUI8DKFSmy5sBrGkonDIKXgFGsG81tWqlUH9idCPDLbfft7h4F1Td2gWISMfR7c59Zjk1KAWR+K9t9DBDNqlfc8iWLNcLKWXgWNOfFWC96KKpASfK6UdfkYK5RdPq7QH2LOJMTgToxZs0j/dk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721057622; c=relaxed/simple; bh=sHT2gejI7g0XKR+lt1K92pFzxyjfVxJww2AwZ7KOL3Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tlTv1nWiLXP/c9W26KLVfYsEr2E5YR0RclxDMCB0cpzZf8qKB//D0QIJzL0/dteZy0iZj6x3wLJbqpHb1k/6Wp+BsNdI7zIPDliO3opEvUZza21gxxTnQ/6AuBV5qmbDqONyaxik95O+wtTuK6nkGc8Svi8gIo2KnIXyrgBST2A= 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=FovkSFN6; arc=none smtp.client-ip=209.85.128.45 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="FovkSFN6" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4266fd395eeso30388495e9.3; 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=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=AFhWGLjXxrpIBhuvDdpT6ZAZC88NAS6103pgQHGSnqI=; b=FovkSFN6grplptpuiBER0/cflvSm0vq0sqMY5HPzb362pu2tSrknPfa4ZrOecIcjFz QeckyS/NbQ9DQ/ss8SdHN7uRjh0MJBot7Hx7ZOZ1QS+abUpZAFFeWLOfyW7gzjhKGnDx vMYud8XplROF7e7QeVWIWyFAAOIcrCUmotKzUgsEPAJmds9+B+w2QJ5bhddjyfLuoaj2 4I3DTt99PrYUCloyOQS8/xzTxW0s4WwsvQ8tq39d2ZuCTFmQVHHd8I7K7L6U5y7z2KM9 ANUOmhBgS/eKTL0uGS991c+H7mlChGUwyb8Db5nd8P9NNHemoSBtwgQEaTXMRYFc1EOW 45yQ== 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=AhCPBwLdSQjS8Kz4v4LJEtvNV4jOefQ8u652GkYEVRn1O88eUM5d7UwaWy0UDbBFvJ 8zsiwUOpeOxUTDrOudvJY+2r1wgdTGmlnBmUBkyS+rh5BpXU6cY5eUlZR7X1RbmOAT/S Z37B1mirE6MUCx3V1F8ZEQt3VnomM+Dv4/EsT9Xrh9YUMxOPNX8eGTRBSV1tgXLpdI5b DOEkDA9zJNvmQ5y81zdC9X/qz8OC9E1hzbNNZwew4aNnhfeU7/A54Wm9Osjeb797yQvJ IItApLpUILDbzAzRxFgYPPovTtu+D5rKVDPgyTaI6//U8fCCOaX7oKuANxWzJmHtQvJ0 cyxQ== X-Forwarded-Encrypted: i=1; AJvYcCX69EddmS3dMEpc755h1HRHsVTd/hkzvdrMpsF6796+nMBM1ez8GiBxU4QTeV8p9cIZo/c52XFMvYg4EmI77vfEr6wTdIdvCYe3sOQBthJ5q8/DzRr8gQz5ery7o2zTYlzp2koH4YXUSQ== X-Gm-Message-State: AOJu0YxM6UZKNj/iszeYOy6ZUj959sNf6i+tSqbp9VQmvPuWHPkPqP5A bj3K+nwjng+5zOAwsYxRCf6cQHYRyO25ZemmqDvJ30XHeZWio2mt 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> 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 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: 812705 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 B2450190698; Mon, 15 Jul 2024 15:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721057623; cv=none; b=CgnlaQD04IjVzOCUMSlg13JnTz+yjh4AAapJ3N7MZpSfh3QaK+6zL3ooiSQGHRD+7wBWUq2fh46zzrb57Gz69QPKf0W8okVS1WSNrot5VtcdqI4ra9rZUdjeCEKj9Vn0+B9Xd1gc0yn6p7mzL82hBcfpfHtpSFzMQL0So5r8ap8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721057623; c=relaxed/simple; bh=wZEPi49ckDisN0y/9/bQlWJRFcnYmxT77NL/4Hr5jUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UFxH0L0cW0VWf6cJPtdFw9KLmnUAQONFKtyIWX5XQsdlbh8HIftWTv6OSiK5hYqIodyFSmMBXMXF17ZpqMynTZKQYgMNF0xlbXA6aOzW+OrOWs+mxMmCl2klcJJMaFbP+oGSywHOrCp1WHfI9YNKsz/kZL3ibsyiU1oqDsYidxI= 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=c2A08qQR; arc=none smtp.client-ip=209.85.221.51 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="c2A08qQR" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-36799a67d9cso3631589f8f.0; 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=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=wixUMSPfbRUA5ff8Q7KbeB+Bn7dETuvtQK3RDPocxSU=; b=c2A08qQR3CCYmtArnziiNHJQ0vsDHfFqmb3nYZSLoBRFKI++TYpJBMoK0hLFrizfnx PocHctDrUD2ZWqBMUAczlCChE5cYBBxdkXNmXMn1P6XDtsVm0c+ZeoqAjzPVDsEYr+FN JyqFh58chWFc4UY6lmftaCEmSq3mCvTk4bD06gflTVJ6nkpgi6n8n4b9avWWo33PWZjd sWl5l0ALDlU/4SYGC/cKQd5TeFmy2ItwDbWjTvzJ7kY477q54rEslVaACivxmEPYKL2J N2l5IoRUiXBCLCpI35yc+wwY2hoftBujskwiIOQxmMz2Z1zl/BdxczhQefzoEcAlNoUr ND2g== 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=cqrwwHewF6xTG8XfIuq8LX6QwYjJk5iJ5AbMn1FATQ4wVVdkkjjLkbVsjntOm9VrXA l60bzAVh7paYFRoa3dkcibhX+qbiBLHC4fcVO3N6fz4TVod+kzwyen7RsFq9hOyd6Mbx +4n/xILVJJMHi7caSHOMqZSf7tGPq2Wd1lqfrr1ke+qQr2OCFoVC5cy7a3j+mfuqi0J6 x+2V4ZayUhlkPmmREH034yc5kCC5P9wyLFTpJpnaCSYNQjLK4UjtZiREWqcvnKf6Lv4P bRIds+9gcd5RSs6e5HDTy22tQc96wwjj2N7uegR8ZvPU39sZwb9KA2+DRbt8FgigH85k 7IOg== X-Forwarded-Encrypted: i=1; AJvYcCVOK65REzpNRu7oLKwU5HJVkcHQAtNLu5QuyyoATdxfGJdg35sWFRn3C/Jy1MNorsBf8FS51Aq9/CkVhuGTmHlUl0JTongkEa0TznabnknAL832PNG/o71k5Vy2gaog/wPkK8Ytbtqqpw== X-Gm-Message-State: AOJu0YyKiUYyTRoyKQjgjCOm0pxMSlgbY1CVR3MdO4YVnMQWSoN2etsz zNrWrJ1a0dbCoX2sQ/uEYB63vvXnOoMF+6YKGU0FT1kTl6U1DRGS 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> 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 | 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);