Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp481483lqb; Wed, 17 Apr 2024 02:06:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3Inlv8VwNb2il3JJ1pTRrB+FryJqQSBtmZo3r063vZTxvaoaFycpG8SWdPSQJlcBZU2AAacU4byHXwbDPzmU2JKvKl29JvO7ARDLRQw== X-Google-Smtp-Source: AGHT+IFWQwnPZRgoD+9/hL/r/P+A/6jInCqOL1F8RPYhWeF4bdW5Mz5L9oeMSWI4dXhj9E5CkUbv X-Received: by 2002:a17:90a:3489:b0:2a2:88d:cdcb with SMTP id p9-20020a17090a348900b002a2088dcdcbmr18351329pjb.26.1713344773547; Wed, 17 Apr 2024 02:06:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713344773; cv=pass; d=google.com; s=arc-20160816; b=jfdX6bbyHcHChd/et+MFFyy3drq8HiM9ERvY1gz47lI8iwldPW6RaCBB2ugb6e882X S3klFta4d9b+050JZscBN3W3qhJi04vDJgN2TBxZFa7ajW1yTTFoFKvfIWoPN+h3ETFl H47OoeRDmuvhhEZrDodMbdL6qobnoN1OKnJp+/vlVEYrbrpWEEbayFgaExmk6EcBDSP8 gAeRzmwjXR+iLue4J7tyhOF3U4Yq92hTwJWsLhI2Cuzw/fp0rRVX6GMI2vqkDiCjxb+0 UI4yDIZHBoNXtg2AkmCNRU6aQM50OOldN+ZfzEeP3xAkZd4GKtZPESms+ulIRYPfX+lb wwLw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=a4Vk3Q7FWCEz42m30ao7B+UDk+tJ78nsGVh0gV/OBQY=; fh=Q+KFOXy7XcC2FWo/T4WZkZnNgF22a1BsEnelv4DYoF4=; b=XV8v9Qdc71VdmP5HiQ5efXLn2FyDisigM1p/2e5AosIDvOJn3QE/vYQ4vlgGeJ6iHC BmdYDLYqylm8olvANgMFJo9jJEoFYmRTeckstybsT9zB7sHQiyQgGeW1+fKC+VaBFlxG 4I+8TUh9PyuwtIzjk2UrjSMMipgMkZVXK/qbhRvSeFE2PQy1NxSpFm9rLPDMoYvgzbXI pATTyese7LtBXgOxrSfgAmUtqBbrt5APpxG9cagbEQikL8UvX5Z9Hhh8tTqG4WaL34dZ ZDjQLl0zqc8WSijG39bsv3NrcfFxwQahmMmOpM4KWy2AaB32/UV6yjugjSnqVRCS/GX9 qwXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m+Xz1SM2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-148203-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gn8-20020a17090ac78800b002a2adfc6206si959476pjb.171.2024.04.17.02.06.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:06:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148203-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m+Xz1SM2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-148203-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 36B922825F5 for ; Wed, 17 Apr 2024 09:06:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75ED1130A78; Wed, 17 Apr 2024 09:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m+Xz1SM2" 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 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-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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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) -- 2.40.1