From patchwork Tue Sep 1 07:49:19 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 2295658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ZUVLsXo7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-i2c+bounces-20344-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [IPv6:2600:3c0a:e001:db::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hYyq55QSlz1xwg for ; Tue, 01 Sep 2026 17:56:17 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 50BA96004B for ; Tue, 1 Sep 2026 07:50:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E02D633B97D; Tue, 1 Sep 2026 07:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ZUVLsXo7" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 7A28646EC88 for ; Tue, 1 Sep 2026 07:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788248996; cv=none; b=ijFIPilsLLx4zOw+GO33OKfM0NtJzsCJZvU1fRloQ3dIjvPW3QrFr1jkuVLdiJ58KlFQmoNqJs01alcLuo1kiHh3c4R/S6u/7k76XL3VeghPrWcYt9Vjt8pyTBwjuVq4hGX/fbMawNWh9GD3MqROwhRUUJq0T9+wr3V4u1PaQqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788248996; c=relaxed/simple; bh=2j3Dm0aFz6+DYVPQ4bDg6M1hmAIxbGZ0tjnY1/wZ04w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VNu1/ZBV/0aaAooHbw2XWwa6yOtP17wbklPb8qWHoXn6Dd1kMdm/dh0vX8guTyZ+kIvx1X03cl/MaElzqdwfbQXNvlUIFkWgSIDdj3UPRrz2f3zH/qAKaNDU1zw6/N0ZjUM9OuZ2Kpxf+8bKllJBbMX7XfouAp3FP9/55e86kn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=ZUVLsXo7; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2d71a50caa9so7535835ad.0 for ; Tue, 01 Sep 2026 00:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788248994; x=1788853794; 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:content-type; bh=NJMnm69J8RdOeWIBaNigEROVzoE1nH5G/6Xl+5Lr2x8=; b=ZUVLsXo721pJQvM/1c7s/r/p4G0xvGpVbxFn0+21L0W4R7F+1AbG3+LERt5CNJ97jq 1JEF42Uu9JjEJzOeLIcOZA2uDMu4gBalh/o972vlddjtUemVqPdFzW/fRHOiqRNzRF7J SC05R5vbCmzWiitxWN2WxdzFDjNh/CbvTMehg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788248994; x=1788853794; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NJMnm69J8RdOeWIBaNigEROVzoE1nH5G/6Xl+5Lr2x8=; b=XO95mFfECQtGwIZkmBFKe52az2MsMnFIkkyFLdK6FBDsQdqAu1fW0yAANMm4jaaEtL p227U5ryeDuZ+hmkwesDzkZ+FPjq7DfxDNfDQK4MCzvsdzjifGn/uit0onQ0L3kSF9Kf 17LLuOlCfHhQwe16ArYNFAVczJ/oDi9rGDK7DSTjUKXR4ZxqY8QcbIBFz9tQ/kR9uzpe wtTqwjz3e0tyN6/vTVaYVRTPyBHwCLRPG5JOb0QhKwoRIy5b5FMtf3QzbWXW8TgqvvJb fI666dHxxtpZ/KtUeQWvdARBQ+PHYZLUj6/CMngUDkmsX88AA/2l1tAl/wGs5PedIvHu tgvA== X-Forwarded-Encrypted: i=1; AKwUvBylra9YLMU7mbOJTM4JqOtNCFwWIn+sd/bdLAKbfqi74QBUi0mAkOx4la4QCy9SAhgLC2RQHzXssCs=@vger.kernel.org X-Gm-Message-State: AFuF++nF/ILLud9V4cjT6WWQad48db3TP6pib1PY5HVK0t6PaM5h8Dd4 r4oSL/4LaEBz3+oURBNLNncVvhAlj0+vM8VvvhgZNZN+DAjkltgEOB/9/RuviscJtw== X-Gm-Gg: AYBFou1ayvPkYeSIeKgKnFt0lFQTq7oFZ4GnsfrqStgDegSRwNta6fGrr8YypJMFGAr 9JlCgPMfl3ujW9ujY3YNtIImScmV6LTeV43Nl49cdL/h27ed2EryCF703QVrgt4WoLr4PcHxenu sicxVszRPkDz4NT8ltHxeWjPKgAut+mFhXnFTp2JZEqUi4WGTqa/7wBScsyG+KMyEtt7/ZY4sxk //Ril1kZ6rg0/alivYaD7zSf9mbojQSJnMe4GrSxiI/QGAUluZXyuWaF7cN39plBf5F8CgCOAM2 L1Viu7Mu4h1AZGD9QdNQLCfOeAQDiVvRCLAIEgVJd+75Tu+ugMHiCRGIDTI/qSHSp8TE2UiPCxH aLX+5I+dUGXe3wqNsdSAzD5nvFR7UxHvTKaKyQcfRlcpC9XIyOyDgQsIx1yPkJKiEWG9JkG6vIU nuPc02RSdkFVmt4tYj8X41VIo8gAZjee2qsVpGXS72L7B7iFDKmCfjJ8F/NWSEp823XcaT6lwxo YBP7os7ph35pzG2WYXjYP0HI+bUtH+y5PUCSU+MacUorg== X-Received: by 2002:a17:902:fd85:b0:2d6:ffa1:429b with SMTP id d9443c01a7336-2d74dc6f7c3mr521877535ad.7.1788248993464; Tue, 01 Sep 2026 00:49:53 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:8cf:6df0:9c4e:f5e1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d75988b699sm48142515ad.59.2026.09.01.00.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 00:49:53 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Matthias Brugger , AngeloGioacchino Del Regno , Dmitry Torokhov , Jiri Kosina , Andi Shyti Cc: Chen-Yu Tsai , Benson Leung , Tzung-Bi Shih , linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/8] regulator: core: Add "enable and wait" functions Date: Tue, 1 Sep 2026 15:49:19 +0800 Message-ID: <20260901074930.764550-2-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.897.gb25b4bd76c-goog In-Reply-To: <20260901074930.764550-1-wenst@chromium.org> References: <20260901074930.764550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In device power sequencing and initialization use cases, it is common for the driver to enable the regulator and then wait for a certain period of time to pass before continuing. In cases where the regulator supply is always on, or has been turned on or left on by another consumer, the driver could shorten the delay or skip it altogether, provided that enough time has already passed since the regulator was _actually_ turned on. Tracking this requires support from the regulator core. Introduce a "last turned on" timestamp field to the regulator device, and "enable and wait" functions to the single and bulk regulator consumer APIs. The existing "enable without wait" functions are then converted to macros that expand to the new functions. The timestamp is updated each time the regulator is actually turned on. For regulators left on by hardware default or by firmware, the core will set the timestamp if it detects it was left on and its supply (and their supply, and so on) is on as well. This is unfortunately best effort only. The core can only assume a dangling regulator (one without a supply) has power. This also applies to the dummy regulator. Signed-off-by: Chen-Yu Tsai --- Changes since v5: - Correctly assign wait_us to all bulk consumers (Sashiko) - Check _regulator_is_enabled() > 0 to check for enabled regulators (Sashiko) - Lock regulator_dev on final _regulator_is_enabled() check in regulator_register() (Sashiko) - Make it clear that _regulator_is_enabled_recursive() assumes that supplies have been resolved (local AI review) - Consider supply's last_on timestamp for regulators that are already enabled or have no .is_enabled() ops (local AI review) Changes since v4: - Try to update last_on timestamp for regulators that were left on Changes since v3: - Added __private modified to regulator_bulk_data.wait_us field and switched to ACCESS_PRIVATE accessor for the field - Moved wait outside regulator lock scope - Moved "remaining" value assignment closer to conditional - Fixed variable unit name in regulator_enable_and_wait() prototype Changes since v2: - New patch --- drivers/regulator/core.c | 129 +++++++++++++++++++++++++---- include/linux/regulator/consumer.h | 21 +++-- include/linux/regulator/driver.h | 2 + 3 files changed, 131 insertions(+), 21 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 6a4008f387b5..d7a193a3bcb2 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -99,7 +99,7 @@ struct regulator_event_work { unsigned long event; }; -static int _regulator_enable(struct regulator *regulator); +static int _regulator_enable(struct regulator *regulator, ktime_t *last_on); static int _regulator_is_enabled(struct regulator_dev *rdev); static int _regulator_disable(struct regulator *regulator); static int _regulator_get_error_flags(struct regulator_dev *rdev, unsigned int *flags); @@ -1675,7 +1675,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, (rdev->constraints->always_on || !regulator_is_enabled(rdev->supply))) { ret = (is_locked - ? _regulator_enable(rdev->supply) + ? _regulator_enable(rdev->supply, NULL) : regulator_enable(rdev->supply)); if (ret < 0) { _regulator_put(rdev->supply); @@ -2186,6 +2186,45 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, return ERR_PTR(-ENODEV); } +/** + * _regulator_is_enabled_recursive - is the regulator output enabled all + * the way to the root supply + * @rdev: regulator device + * + * Only intended for checking regulators that have been left on by + * hardware default or firmware. + * + * Assumes supplies have been resolved. Must be called with dependent + * locks held. + * + * Return: Positive if the regulator output backing the source/client, + * and all of its upstream supplies, have requested that their + * respective device be enabled, zero if any of them hasn't, + * else a negative error number. + */ +static int _regulator_is_enabled_recursive(struct regulator_dev *rdev) +{ + int ret; + + ret = _regulator_is_enabled(rdev); + if (ret <= 0) + return ret; + + /* + * If .last_on was set, then this rdev was either enabled through + * _regulator_do_enable(), or had been checked before as the target + * of regulator_resolve_supply(). + */ + if (rdev->last_on) + return ret; + + /* This is the root supply; we can only assume it actually has power */ + if (!rdev->supply) + return ret; + + return _regulator_is_enabled_recursive(rdev->supply->rdev); +} + static int regulator_resolve_supply(struct regulator_dev *rdev) { struct regulator_dev *r; @@ -2370,6 +2409,14 @@ static int regulator_resolve_supply(struct regulator_dev *rdev) } rdev->constraints_pending = false; } + + /* + * regulator was left on but not enabled with .always_on or .boot_on + * constraints, and thus .last_on timestamp is still invalid. + */ + if (!rdev->last_on && _regulator_is_enabled_recursive(rdev) > 0) + rdev->last_on = ktime_get_boottime(); + regulator_unlock_dependent(rdev, &ww_ctx); if (!do_final_setup) @@ -3061,6 +3108,8 @@ static int _regulator_do_enable(struct regulator_dev *rdev) fsleep(delay); } + rdev->last_on = ktime_get_boottime(); + trace_regulator_enable_complete(rdev_get_name(rdev)); return 0; @@ -3130,16 +3179,18 @@ static int _regulator_handle_consumer_disable(struct regulator *regulator) return 0; } -/* locks held by regulator_enable() */ -static int _regulator_enable(struct regulator *regulator) +/* locks held by regulator_enable_and_wait() */ +static int _regulator_enable(struct regulator *regulator, ktime_t *last_on) { struct regulator_dev *rdev = regulator->rdev; + ktime_t supply_last_on; int ret; lockdep_assert_held_once(&rdev->mutex.base); + supply_last_on = 0; if (rdev->use_count == 0 && rdev->supply) { - ret = _regulator_enable(rdev->supply); + ret = _regulator_enable(rdev->supply, &supply_last_on); if (ret < 0) return ret; } @@ -3177,13 +3228,26 @@ static int _regulator_enable(struct regulator *regulator) } else if (ret < 0) { rdev_err(rdev, "is_enabled() failed: %pe\n", ERR_PTR(ret)); goto err_consumer_disable; + } else { + /* + * Either the regulator was already enabled somehow, or this regulator + * itself has no on/off control. Either way our timestamp cannot be + * earlier than its supply's timestamp. supply_last_on == 0 if there + * is no supply. + */ + if (rdev->last_on < supply_last_on) + rdev->last_on = supply_last_on; + if (!rdev->last_on) + rdev->last_on = ktime_get_boottime(); } - /* Fallthrough on positive return values - already enabled */ } if (regulator->enable_count == 1) rdev->use_count++; + if (last_on) + *last_on = rdev->last_on; + return 0; err_consumer_disable: @@ -3197,31 +3261,49 @@ static int _regulator_enable(struct regulator *regulator) } /** - * regulator_enable - enable regulator output + * regulator_enable_and_wait - enable regulator output and wait for time + * passed after regulator actually enabled * @regulator: regulator source + * @wait_us: time to wait after regulator actually turned on; 0 to not wait * * Request that the regulator be enabled with the regulator output at * the predefined voltage or current value. Calls to regulator_enable() * must be balanced with calls to regulator_disable(). * + * If wait_us is greater than zero, then check that wait_us has passed since + * the regulator is _actually_ enabled before returning. + * * NOTE: the output value can be set by other drivers, boot loader or may be * hardwired in the regulator. * * Return: 0 on success or a negative error number on failure. */ -int regulator_enable(struct regulator *regulator) +int regulator_enable_and_wait(struct regulator *regulator, unsigned int wait_us) { struct regulator_dev *rdev = regulator->rdev; struct ww_acquire_ctx ww_ctx; + ktime_t last_on = 0; int ret; regulator_lock_dependent(rdev, &ww_ctx); - ret = _regulator_enable(regulator); + ret = _regulator_enable(regulator, &last_on); regulator_unlock_dependent(rdev, &ww_ctx); + if (ret) + return ret; + + if (wait_us) { + ktime_t end = ktime_add_us(last_on, wait_us); + s64 remaining; + + remaining = ktime_us_delta(end, ktime_get_boottime()); + if (remaining > 0) + fsleep(remaining); + } + return ret; } -EXPORT_SYMBOL_GPL(regulator_enable); +EXPORT_SYMBOL_GPL(regulator_enable_and_wait); static int _regulator_do_disable(struct regulator_dev *rdev) { @@ -5390,30 +5472,38 @@ static void regulator_bulk_enable_async(void *data, async_cookie_t cookie) { struct regulator_bulk_data *bulk = data; - bulk->ret = regulator_enable(bulk->consumer); + bulk->ret = regulator_enable_and_wait(bulk->consumer, ACCESS_PRIVATE(bulk, wait_us)); } /** - * regulator_bulk_enable - enable multiple regulator consumers + * regulator_bulk_enable_and_wait - enable multiple regulator consumers and + * wait for time passed after regulators are + * actually enabled * * @num_consumers: Number of consumers * @consumers: Consumer data; clients are stored here. + * @wait_us: time to wait after regulators actually turned on; 0 to not wait * * This convenience API allows consumers to enable multiple regulator * clients in a single API call. If any consumers cannot be enabled * then any others that were enabled will be disabled again prior to * return. * + * If wait_us is greater than zero, then check that wait_us has passed since + * the regulators are _actually_ enabled before returning. + * * Return: 0 on success or a negative error number on failure. */ -int regulator_bulk_enable(int num_consumers, - struct regulator_bulk_data *consumers) +int regulator_bulk_enable_and_wait(int num_consumers, + struct regulator_bulk_data *consumers, + unsigned int wait_us) { ASYNC_DOMAIN_EXCLUSIVE(async_domain); int i; int ret = 0; for (i = 0; i < num_consumers; i++) { + ACCESS_PRIVATE(&consumers[i], wait_us) = wait_us; async_schedule_domain(regulator_bulk_enable_async, &consumers[i], &async_domain); } @@ -5441,7 +5531,7 @@ int regulator_bulk_enable(int num_consumers, return ret; } -EXPORT_SYMBOL_GPL(regulator_bulk_enable); +EXPORT_SYMBOL_GPL(regulator_bulk_enable_and_wait); /** * regulator_bulk_disable - disable multiple regulator consumers @@ -6243,6 +6333,15 @@ regulator_register(struct device *dev, goto del_cdev_and_bdev; } + /* + * If no supply was given, then the last_on timestamp could not have + * been updated in regulator_resolve_supply(). Check it here. + */ + regulator_lock(rdev); + if (!rdev->supply_name && !rdev->last_on && _regulator_is_enabled(rdev) > 0) + rdev->last_on = ktime_get_boottime(); + regulator_unlock(rdev); + rdev_init_debugfs(rdev); /* try to resolve regulators coupling since a new one was registered */ diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index 56fe2693d9b2..0b83acc015d4 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -145,6 +145,7 @@ struct regulator_bulk_data { /* private: Internal use */ int ret; + unsigned int __private wait_us; }; #if defined(CONFIG_REGULATOR) @@ -192,7 +193,7 @@ int devm_regulator_bulk_register_supply_alias(struct device *dev, int num_id); /* regulator output control and status */ -int __must_check regulator_enable(struct regulator *regulator); +int __must_check regulator_enable_and_wait(struct regulator *regulator, unsigned int wait_us); int regulator_disable(struct regulator *regulator); int regulator_force_disable(struct regulator *regulator); int regulator_is_enabled(struct regulator *regulator); @@ -209,8 +210,9 @@ int __must_check devm_regulator_bulk_get_const( struct device *dev, int num_consumers, const struct regulator_bulk_data *in_consumers, struct regulator_bulk_data **out_consumers); -int __must_check regulator_bulk_enable(int num_consumers, - struct regulator_bulk_data *consumers); +int __must_check regulator_bulk_enable_and_wait(int num_consumers, + struct regulator_bulk_data *consumers, + unsigned int wait_us); int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers, const char * const *id); int regulator_bulk_disable(int num_consumers, @@ -410,7 +412,8 @@ static inline int devm_regulator_bulk_register_supply_alias(struct device *dev, return 0; } -static inline int regulator_enable(struct regulator *regulator) +static inline int regulator_enable_and_wait(struct regulator *regulator, + unsigned int wait_us) { return 0; } @@ -457,8 +460,9 @@ static inline int devm_regulator_bulk_get_const( return 0; } -static inline int regulator_bulk_enable(int num_consumers, - struct regulator_bulk_data *consumers) +static inline int regulator_bulk_enable_and_wait(int num_consumers, + struct regulator_bulk_data *consumers, + unsigned int wait_us) { return 0; } @@ -676,6 +680,11 @@ regulator_is_equal(struct regulator *reg1, struct regulator *reg2) } #endif +#define regulator_enable(regulator) regulator_enable_and_wait(regulator, 0) + +#define regulator_bulk_enable(num_consumers, consumers) \ + regulator_bulk_enable_and_wait(num_consumers, consumers, 0) + #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_REGULATOR) struct regulator *__must_check of_regulator_get(struct device *dev, struct device_node *node, diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index cc6ce709ec86..8a74aa681df3 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -658,6 +658,8 @@ struct regulator_dev { unsigned int constraints_pending:1; unsigned int is_switch:1; + /* time when this regulator was enabled last time */ + ktime_t last_on; /* time when this regulator was disabled last time */ ktime_t last_off; int cached_err; From patchwork Tue Sep 1 07:49:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 2295659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=VBP/nchK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-i2c+bounces-20345-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [IPv6:2600:3c0a:e001:db::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hYyqB2V42z1xwg for ; Tue, 01 Sep 2026 17:56:22 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 1DF8065D7B for ; Tue, 1 Sep 2026 07:50:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FB9D47011C; Tue, 1 Sep 2026 07:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="VBP/nchK" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 2A9D946DFF8 for ; Tue, 1 Sep 2026 07:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788248999; cv=none; b=U8E2ARq4uEUY6hpTykeIdcB00EMwzCCnNYMdhZExvQcRR5LR56a8vNmUn+ish0BQzotSqvfXvnmKyzb95uDfEsARn78wUu4z+PdHCSdnEA4luOH5UxWSwIRr5ELdb++mIjp6qq6jdfnk9oIfkD6RAxlK1KQBDoI894veRYzTHx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788248999; c=relaxed/simple; bh=rlbm//2B5OdqBjqqr608z7OgF45U9aPq6hwy3/UJHTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HMtGBqZKvDG30R4nnQtodH/bbOJU8ECVKI+UZuCSrhZFN6BbAXfYUMnyxXRTPPunYRJ9/atYYOwPCtoSk1rkCWLUHn2D/gf9smb25M9KNKx4pSQGbKa5pKE5iE6V/xe1MWtui72nTaa0JRP5KLRLwGT6D71A2qI/ClMX2KFvCUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=VBP/nchK; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2d9004f39d3so27644605ad.2 for ; Tue, 01 Sep 2026 00:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788248997; x=1788853797; 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:content-type; bh=ppTKN+ViX0ps4m1x8WbWgM6kLhXVltmE87oNPgspGL0=; b=VBP/nchKDZDalaoDZl/c3b3OHY3d9H9nDT0Ay8vR+0iR1ALVod1jsqaIQNBBtzbhWJ DMKJdyyEGJu6HMQ1AsWQR18Afjekvsm2nTRKHXPTyuXgJ1akYTXyO+Rexjpef19azrzq D5jCSe0A+6GJu5CmP8ephOuFZNMJ4XzTFWp4Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788248997; x=1788853797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ppTKN+ViX0ps4m1x8WbWgM6kLhXVltmE87oNPgspGL0=; b=kmYP45/GsBsbDyYE2XHG5SdmcvHVjkoYCj7CNgifOjZV2JdOQELO7MtGeh9d1PvvkR V1r2TYUWu37Uq5HhA/JbRCADwL1f9qX30/B+ndBkkdfHS0k8b8EaNyiBgIUjzjNdVk+t zfhbx/sMl66PsdUVobabjR4b+lXxLxEqztU0p2X3hQrqzBV+WhsvaYI0xkNhaySOkA5O CNqlCvkHAsJI7hLqVEHbSec9WUndUj3+2rPmiiEJ+SLn58941w52t3U/hnMSpBD2ppdt 53N3r08EwhxqK1h9FycBbtWSc6kXSr9v1DcihJjIsibczFc4b7aFlYSv2R01H8Qa/GOw bCrw== X-Forwarded-Encrypted: i=1; AKwUvBypCn0OsPO4ZU3u7D2u+lCbZ58W3cLhGFFI4CAHega2iyVWXRmeg327GyOK52YClvDxHj82hfhmma4=@vger.kernel.org X-Gm-Message-State: AFuF++lsUW4mWLwkTGviZi93DX76efmf+f+ePWIWydVzEpDyGUZck9v1 uSUA1Cdt/VRTuI+l0nEoCX91dJuPprCVTnw8SikADDGyLcEh+bphXxalrfAHhtl1Ug== X-Gm-Gg: AYBFou0tLsZuyvFP5EZTjwecpeGC0krE9+dSLSuriARWj5wIZmTqPIg/ff9IlxOmNpB Rijeazyv8jGf4eN5mbP8NIWsg5KjyPsinRg+F4o8Liuh2rRpJ5O/3fq2WXHPKmR7a2TqJOX4HvJ Rdw/CLRwC4sY+9fk58ZyTKXUCOnLRxls+4GAi42yJBTb9GaMY30BCcGbeiDmf/1ccTqhAhvs26/ q7RyRB8yHXts7W4e1dBcD+0uEObvlGR0kq0gGk+qHFwquPc2TZLNQu3yRIRCvCjIdrbSb5MSZf6 Ke1cp+F+YL6keMtFaRbI7aZKXAAjeTQ2BUah3CJJx2t4aZqfZy2Jw9YwxBrScALnjLBDr+jDF7N pOutk9Ma6TsLl6PeyFiCnwcp4sUB3d/rvJFHs8eCtUVEhmwcQ14bjyVZWpCSjDfstXurv7IL/9M wDBDeQUT15p8msEPCxSWpjwdxYzw/7ihYrFUI1IFOSR84kUZyA62BuYJfuc5007BSQlieeqkjVN 1eJMmZxqerOu4+hr5kUeW9v/KSaP1hMGBOOUWLIMvUcoXg= X-Received: by 2002:a17:903:3883:b0:2d9:216a:cdd3 with SMTP id d9443c01a7336-2d94a93609cmr90196685ad.18.1788248997383; Tue, 01 Sep 2026 00:49:57 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:8cf:6df0:9c4e:f5e1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d75988b699sm48142515ad.59.2026.09.01.00.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 00:49:56 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Matthias Brugger , AngeloGioacchino Del Regno , Dmitry Torokhov , Jiri Kosina , Andi Shyti Cc: Chen-Yu Tsai , Benson Leung , Tzung-Bi Shih , linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, stable+noautosel@kernel.org Subject: [PATCH v6 2/8] Input: elan_i2c - Wait for initialization after enabling regulator supply Date: Tue, 1 Sep 2026 15:49:20 +0800 Message-ID: <20260901074930.764550-3-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.897.gb25b4bd76c-goog In-Reply-To: <20260901074930.764550-1-wenst@chromium.org> References: <20260901074930.764550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Elan trackpad controllers require some delay after enabling power to the controller for the hardware and firmware to initialize: - 2ms for hardware initialization - 100ms for firmware initialization Until then, the hardware will not respond to I2C transfers. This was observed on the MT8173 Chromebooks after the regulator supply for the trackpad was changed to "not always on". Switch to the new regulator_enable_and_wait(). This makes sure that enough time has passed since the regulator was first enabled, satisfying the power sequencing delay requirement. This allows the delay to be skipped if the regulator supply was already enabled by some other part of the kernel, such as the I2C OF component prober. Fixes: 6696777c6506 ("Input: add driver for Elan I2C/SMbus touchpad") Cc: # needs new regulator API Signed-off-by: Chen-Yu Tsai --- Changes since v5: - Added noautosel tag Changes since v2: - Switched to new regulator_enable_and_wait() API Changes since v1: - Delay only if the regulator was previously disabled / turned off - Link to v1 https://lore.kernel.org/all/20241001093815.2481899-1-wenst@chromium.org/ --- drivers/input/mouse/elan_i2c_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index f5e505edbc33..4bbc6cef8be6 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,8 @@ #define ETP_FWIDTH_REDUCE 90 #define ETP_FINGER_WIDTH 15 #define ETP_RETRY_COUNT 3 +/* H/W init 2 ms + F/W init 100 ms w/ round up */ +#define ETP_POWER_ON_DELAY_US (110 * USEC_PER_MSEC) /* quirks to control the device */ #define ETP_QUIRK_QUICK_WAKEUP BIT(0) @@ -1260,7 +1263,7 @@ static int elan_probe(struct i2c_client *client) if (IS_ERR(data->vcc)) return dev_err_probe(dev, PTR_ERR(data->vcc), "Failed to get 'vcc' regulator\n"); - error = regulator_enable(data->vcc); + error = regulator_enable_and_wait(data->vcc, ETP_POWER_ON_DELAY_US); if (error) { dev_err(dev, "Failed to enable regulator: %d\n", error); return error; @@ -1416,7 +1419,7 @@ static int elan_resume(struct device *dev) int error; if (!device_may_wakeup(dev)) { - error = regulator_enable(data->vcc); + error = regulator_enable_and_wait(data->vcc, ETP_POWER_ON_DELAY_US); if (error) { dev_err(dev, "error %d enabling regulator\n", error); goto err; From patchwork Tue Sep 1 07:49:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 2295663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Lq846xDp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org; envelope-from=linux-i2c+bounces-20346-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sin.lore.kernel.org (sin.lore.kernel.org [IPv6:2600:3c15:e001:75::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hYysD2BWwz1xwg for ; Tue, 01 Sep 2026 17:58:08 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id 557DF2FDF4 for ; Tue, 1 Sep 2026 07:50:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1A46470433; Tue, 1 Sep 2026 07:50:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Lq846xDp" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 9E59F470135 for ; Tue, 1 Sep 2026 07:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249004; cv=none; b=a+O4tTTxgeUGjz3+CC/lXVqqTyj6G7oiZwF2SJPspbvFdN4vvhlrQN0nS6b/m/cM1kMbHewr18IHoJtn/IRsX4TgU0KVqaBcS0k9ecvid1VRW4ofyC6lliBk3UrWInfvJ3/Dik1xtG0cDmInFQHOaU09K88zV3Y2a4Pq864tLkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249004; c=relaxed/simple; bh=KSh5c40N/ncjUkxNS2dUoSiZ9wDsl5oOe77nz1eIIdQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MTgvoTQFSV5wcXFg/I08Y3iIEsTmotEaWiShtULCCqA3fmK7TvM5pBktv2aMLxj1pzgg/LVu7o5j1Tvcti+iQIpJnnYu+FlI1/4jTZjPMqkhGleO9CqmfddEM4sry7jp1gjJ5NlJYpuIPPv/lkgpS687U5/r8FjwSkAI43QxHyk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Lq846xDp; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2d7200b2e15so47414915ad.3 for ; Tue, 01 Sep 2026 00:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788249001; x=1788853801; 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:content-type; bh=wJzWbza2zag3QhFxPq/teShXqDf76npySrhO2+9Jdis=; b=Lq846xDp2aXhMzO0BQBk2BNWZI23Zq2slbPd+5IkCZNq59bQxrB1RfACIKZaPBzzoE 7LeWfaoFDZW0aL0f6gq6AIjS5ZIJX1FYRrBjDf5VpyRADYTZNYCuQPPJhWyzanlDJfkh gE89DdoSmckyYlvPRmQWRk4B/75Im9he7yJcM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788249001; x=1788853801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=wJzWbza2zag3QhFxPq/teShXqDf76npySrhO2+9Jdis=; b=YcsaL5agSPdqLXNdYUvpF4i8jOqrQTlz8iTUp92/PCDXtbhM+fLgptgVQ0uLkjUuPg JX3B3+khwvMVaIpQj7mwaawnHFdGlWn9FndIow7DTKz9UvMeZ3xtM/0V8/1XcDPLRl0B XgRezw7adXL617wZ1rQq5L2OSG+XJeH1vJH1BJ/mIWcNazmbCz0fDgSM41HUeSdevf2G w/pNmqNyVH8J7duC0+OqJi59kGBnlvQ4ks25Q58y22J0OK+jFwbxIxqK8c8ozhPIq7pQ kM9ddyizdak9Ydp8Yc3IL2uG4jheiGG9yO6CYiLY5XjxNw+uDECLg+dOzOJReniZVKDA J0tw== X-Forwarded-Encrypted: i=1; AKwUvBzrS9X07wHih7lUJPz7Eypzj6iUqaDwZ8FiIXz+8M7Q/pcvdbEgz4eayoRRDYYIMv5h72K5J3UrVrM=@vger.kernel.org X-Gm-Message-State: AFuF++ljlDoken25bU4/X+dsQqIOAoc62STMQoCpurVprGpJs5Llgkr+ +UQqOcDbyLjeima2QufsdJ3cK/hy7LYjjiMqfmVzqghXFZ4N8ZtvqR68TuVwtI3Q5A== X-Gm-Gg: AYBFou3pqD6wf76fBNTG1FYyJXYTUGlt79T/MkXNHprHHhEjO7qXoA7AUrso9bl9CEn 1iQr9oJP3uNnnOyxiBApvjV15vti50kY30Z2WIOR6B8D2KiCcX89OaQ/C98W8jf297PpJSh9MOQ ZkdT7ekKoocwSdJ5IeX+kQ6TWXBSLdeCMbHK++uwvGq90RplNrU2aKDLc0UanJgR4hNC8poRaab 9APY7y6pSzD5xsyINfrpV81NQKKxCI2IjGm9uMEkmTB4EztwzqZ1aUl/lkWEpW7KTL6KIwOtUqI zVJXNPoqmOlkB3UjrqU4Goo0mvRZghNNyEk/BFx/dEVAoupJsnyjoWgN2STAi1peG86E2C112Hf scZV0yLQcLZLNXqjvoYO2Ro5drGBOyUMIXoAlfQfqZ6EV0Nm3uUz1WNgQBZLARK+enPxQlellGu /2SkIDrTWAR8SP8NeVyo731ynTBUpkcy44tWvMrG8lGnwFX0WrNIv9ls2iQoqTu28Bl4PywI3L5 Lf+rvcr2YzFDdceSzuCn/849NnSVcm8EKZX7z8DazB7bQ== X-Received: by 2002:a17:903:3d0e:b0:2d8:d4d7:f055 with SMTP id d9443c01a7336-2d94a930d44mr91456335ad.22.1788249000970; Tue, 01 Sep 2026 00:50:00 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:8cf:6df0:9c4e:f5e1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d75988b699sm48142515ad.59.2026.09.01.00.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 00:50:00 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Matthias Brugger , AngeloGioacchino Del Regno , Dmitry Torokhov , Jiri Kosina , Andi Shyti Cc: Chen-Yu Tsai , Benson Leung , Tzung-Bi Shih , linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 3/8] HID: i2c-hid-of: skip post-power-on delay if powered on sufficiently long Date: Tue, 1 Sep 2026 15:49:21 +0800 Message-ID: <20260901074930.764550-4-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.897.gb25b4bd76c-goog In-Reply-To: <20260901074930.764550-1-wenst@chromium.org> References: <20260901074930.764550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On some devices the HID device is powered from an always-on power rail, or the power rail has been left on by either POR defaults or the bootloader. By the time the driver probes, the device most certainly has finished initializing. There is no need for the delay. In such designs, the system integrators tend to work around the delay to avoid the boot time penalty by simply omitting it from the device tree. This is undesired, as the device tree is not fully describing the hardware. Switch to the new regulator_bulk_enable_and_wait() function that makes sure a certain amount of time has passed since the regulator supplies were actually enabled. Signed-off-by: Chen-Yu Tsai --- Changes since v2: - Switched to new regulator_bulk_enable_and_wait() API --- drivers/hid/i2c-hid/i2c-hid-of.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid-of.c b/drivers/hid/i2c-hid/i2c-hid-of.c index 59393d71ddb9..fdaad451e710 100644 --- a/drivers/hid/i2c-hid/i2c-hid-of.c +++ b/drivers/hid/i2c-hid/i2c-hid-of.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "i2c-hid.h" @@ -48,16 +49,14 @@ static int i2c_hid_of_power_up(struct i2chid_ops *ops) struct device *dev = &ihid_of->client->dev; int ret; - ret = regulator_bulk_enable(ARRAY_SIZE(ihid_of->supplies), - ihid_of->supplies); + ret = regulator_bulk_enable_and_wait(ARRAY_SIZE(ihid_of->supplies), + ihid_of->supplies, + ihid_of->post_power_delay_ms * USEC_PER_MSEC); if (ret) { dev_warn(dev, "Failed to enable supplies: %d\n", ret); return ret; } - if (ihid_of->post_power_delay_ms) - msleep(ihid_of->post_power_delay_ms); - gpiod_set_value_cansleep(ihid_of->reset_gpio, 0); if (ihid_of->post_reset_delay_ms) msleep(ihid_of->post_reset_delay_ms); From patchwork Tue Sep 1 07:49:22 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 2295661 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Zr/ZDFJ3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-i2c+bounces-20347-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hYyrw1rSvz1xwg for ; Tue, 01 Sep 2026 17:57:52 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 96E7766B2C for ; Tue, 1 Sep 2026 07:50:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4E0546EF92; Tue, 1 Sep 2026 07:50:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Zr/ZDFJ3" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 F05C9470133 for ; Tue, 1 Sep 2026 07:50:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249006; cv=none; b=nwfM4l+xXWn6KUtl7qAclVCmg81ENZDlpqEZoTAaJwtNCTrO2TRRTsTJxqbVPwslr1g8DS2NCZ6CD1dMNFjmFkUS0dIfsMmT575pnOOzVWL6ehLcIt4Xz8wBr7HhFGgTJ5HaS1Dz1COYiGgXETSwv7UZMhr0my0UmOuPyFXSVsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249006; c=relaxed/simple; bh=SPcW+mZp0p9SXTvYafIM3g/Oq10MKnc+TqcPitNlh8Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KbVBVSrz4c0vpaQJ4wH/kpEEYTKt5d2vmba530VZBStFHjCkrfktK3+8ZLRY/h41W0cuztqRSERK4dyJHTGHvHFKf8tph2b68l123leOUBicp1uhUFkONDqbe9AIAQdwivj5Z97LLrXt1jSRVhu0FHZ69UFCIXzC1SssjNW7YYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Zr/ZDFJ3; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2d6f9e2f681so42961885ad.3 for ; Tue, 01 Sep 2026 00:50:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788249004; x=1788853804; 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:content-type; bh=Lkkm1waPZ+HrT9oYZpgc7xZ9xBFanNK2vNiOpJD6Fs8=; b=Zr/ZDFJ33z6iPtyMTtb6LEYHj0DKmGGV7xYUfeiTEx1TN65aGbYzIn6Ngx3GZPMBvQ kj0GCrxvwIRzY5r04DMSTdmuRiWaGs01ehvy0ynLmhArjdZ0pOMXwePMKcFPMg9vJ6/t PqEIK4SyadtP2uOUd+VAOc+pBrpLA4rMXCUaA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788249004; x=1788853804; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Lkkm1waPZ+HrT9oYZpgc7xZ9xBFanNK2vNiOpJD6Fs8=; b=rxrj7/Nnc+X4dSrglqWY+XJnweWnHLXGjttPbowNzP6aNSt2StdgnB3tBVx/k1YAll afy8gKfn0OHZU0ADIM1ZeePIEiCB4bIidXpceD5duUZ5CNmmDIeeoRPyjEPcG6Ozn7Da jAP4YWoTz437aZobHUivb/J+u19IYnCjBgC98vSNnE2+h524QcmnVadlWPB0Hu+p4AoQ 34BCe1mleLOdTykBZ6y9GvSkrsnO41UMbmsYFOsmP2LfyfHNcGf3QYhWDlwuSL1RUx3w 1ayTly0bUcwxPDq6FaPleV/wYeYZN//QNHAmzNN4t5Dh+iVPqE7dHi3W5EJIZg4TMmUT 43qw== X-Forwarded-Encrypted: i=1; AKwUvBxItXYVyaxUPSoF6wPnyl27myjjrPLhky3UFHMbuTLo9mGbysM3N8zu+7kGEyHKOUM5GK97MkxiDuU=@vger.kernel.org X-Gm-Message-State: AFuF++ktw/zyQP8qz9l89aqudjB36LdHyAzdgtQpmRqxDSqA7LeOIU0f Zc/M18tz91kNnqespt5XFKerx13o0Lp1C8fct5PUnKkyBE4gxX8N9nrRv0cOpdTNiQ== X-Gm-Gg: AYBFou0bvTe7+xKlgUMyZXif3Aqq4oqgvxpKY6QJ9fSfUzA8Hc3xWYntStJWdGtoTnY C2Typ5fZiCOt7WyscxazdZtOQudQsEYuArybEhPiz4GbHlMBfFcIk0scXqs8tpN8J4XpIaxxzZS wKE+ris6DqFcZOGxSVBy/D/1q2XsCeBhaZNCcuOZteH8S2/5LOS/k9+ii3297MfbABqBNiiD6ks tTIBl+LfU40yIIJJ1Mi0G0vcODackNDFJU18xCCGa5omGFrbxIseRDW+J6aM66PPuIc+O4+N+GS jvexOqSu1HKYMishhP28/wna/AlmpjGJrZYHj+XdLkrEMNwt7PVv9cLEFPUCUEglqmrLCdOs/im HrrFvmcrQNj7PcVYy1VMSjrkLirpHtrUU3V6PJtljMFX8Qk6Eu5QIZWg3Xi063QUk4gOFUmQAyZ 4mBH8cCXTN2w89UL8p6rlpU1VtQ3QA58BF9OwMkC/Egktt7IRjUCRoireJOGqDRhZh/k2DUSPxk RGErbAaUJnyuDBmSfOLtXfFYD1g9U+9WGmN4FXSBa39lw== X-Received: by 2002:a17:903:3d0f:b0:2d8:d4ce:7e3b with SMTP id d9443c01a7336-2d95d5fc28amr40543015ad.16.1788249004522; Tue, 01 Sep 2026 00:50:04 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:8cf:6df0:9c4e:f5e1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d75988b699sm48142515ad.59.2026.09.01.00.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 00:50:04 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Matthias Brugger , AngeloGioacchino Del Regno , Dmitry Torokhov , Jiri Kosina , Andi Shyti Cc: Chen-Yu Tsai , Benson Leung , Tzung-Bi Shih , linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/8] i2c: of-prober: skip post-power-on delay if powered on sufficiently long Date: Tue, 1 Sep 2026 15:49:22 +0800 Message-ID: <20260901074930.764550-5-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.897.gb25b4bd76c-goog In-Reply-To: <20260901074930.764550-1-wenst@chromium.org> References: <20260901074930.764550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On some devices the I2C component is powered from an always-on power rail, or the power rail has been left on by either POR defaults or the bootloader. By the time the prober probes the device, the device most certainly has finished initializing and can respond. There is no need for the delay. In such designs, the system integrators tend to work around the delay to avoid the boot time penalty by simply omitting it from the device tree and the component prober. This is undesired, as the device tree is not fully describing the hardware. Switch to the new regulator_enable_and_wait() function that makes sure a certain amount of time has passed since the regulator supply was actually enabled. Signed-off-by: Chen-Yu Tsai --- Changes since v2: - Switched to new regulator_enable_and_wait() API --- drivers/i2c/i2c-core-of-prober.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/i2c-core-of-prober.c b/drivers/i2c/i2c-core-of-prober.c index 6a82b03809d4..f9f3c0ef93ff 100644 --- a/drivers/i2c/i2c-core-of-prober.c +++ b/drivers/i2c/i2c-core-of-prober.c @@ -18,6 +18,7 @@ #include #include #include +#include /* * Some devices, such as Google Hana Chromebooks, are produced by multiple @@ -226,13 +227,11 @@ static int i2c_of_probe_simple_enable_regulator(struct device *dev, struct i2c_o dev_dbg(dev, "Enabling regulator supply \"%s\"\n", ctx->opts->supply_name); - ret = regulator_enable(ctx->supply); + ret = regulator_enable_and_wait(ctx->supply, + ctx->opts->post_power_on_delay_ms * USEC_PER_MSEC); if (ret) return ret; - if (ctx->opts->post_power_on_delay_ms) - msleep(ctx->opts->post_power_on_delay_ms); - return 0; } From patchwork Tue Sep 1 07:49:23 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 2295662 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=GrVLjJRT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-i2c+bounces-20348-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [IPv6:2600:3c0a:e001:db::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hYyry3QM8z1xwg for ; Tue, 01 Sep 2026 17:57:54 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 27FD366F2F for ; Tue, 1 Sep 2026 07:50:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 592FC470EAD; Tue, 1 Sep 2026 07:50:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="GrVLjJRT" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 006FB470EAE for ; Tue, 1 Sep 2026 07:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249011; cv=none; b=ah3w0wuCjv00evMw5i7cPWJQAhcdqB0Kphpn49HlWnSQuqFZSDAC1/faHEr1f5vhiPZ0RgMQTFxCs2aYVMjOACE58ZIcZyK6pDco3V+5C/GL05VKgYv+pOHJZkSEh/FQFJ1sVal4cZAjPFX5TPYKwF+Nz37MY11inoMAc8IrGkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249011; c=relaxed/simple; bh=6ab1wCEQP5zPcBfT0PBKodK0oU1IQzXD1fGtvF3pHJE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OaYTDmbZdmTcRMbRJ4ynDnI2rVJ12ggoqR8+czuMXBdJgA9yxO4zWFAThOsiBE2HfjAoVlCEI9dSw/vtrPPISJeWShYHSjhzMUhBfy3Bt7Gq1/EGvIFUE04qm2TY4TPpTuP85k9xT+FJsSgIYLVIRRP3mYmIgxkWSCu22bp1lmU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=GrVLjJRT; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2d71a50caa9so7539625ad.0 for ; Tue, 01 Sep 2026 00:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788249008; x=1788853808; 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:content-type; bh=377z9agroO9vgw/MPipyApHAj2rPTrxxSFp/0FEh+cY=; b=GrVLjJRTUdU/jzM1vH5Wt5/vZikPdp2veR7YQ4ZPfhm11Vzid1cb2wpTIFi7MV+pW0 5P1nWbZ6I1p2r/lAKYLDXRCcfqoA2dSYcVjDmbl+AXMitvMzAjOgIVvdCXZXJBa8LKaG 7j+G0INHwm6iHmVC1S13o+0u1QLKzbg4eGtac= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788249008; x=1788853808; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=377z9agroO9vgw/MPipyApHAj2rPTrxxSFp/0FEh+cY=; b=lutwsMrrMFUS6VbFCHxb1YoeLgEaKXXdE4wLlnq+qisRyiicBDW4vNEz/2Uz7AmTYz Io6QxPJrbR5TuRSs3OaXrnNT36AgCZ08BQpnjS7AhuA6o+pFlxT/Ahoc380MzEL8WyzR R4ADVQElia2buz6OmUP+oOsJ8bIKdjrRcEkA5JaLSaWeR77Pj2ZoYDTmCSSnkLsi3amT BH91iYkvRVpVu6juhkM/z14UOG8nI3vCuP1epjCjwV/EiYBasd2McJjwkQze0k/X8RgG iCsKBZuwtMN0FeVTzSEJf9xQgpG5E8ZN5er8qYBDhrNKQj6srgOQNUmX4f8mEhSexlYv GVoA== X-Forwarded-Encrypted: i=1; AKwUvBxoxkiqS4y/gm5FTXSxzPFzzpc1Q/L0l4xTm1+3kPKn2NIUuW0SouALc5Olo793om+nbHAtjEt4RpM=@vger.kernel.org X-Gm-Message-State: AFuF++n/+NvJu3aH/bA7CE0Iaq/90yGrRCF4OKL7watET9Xx58k6Q2Jv 2++DRF4QonCkYps8uDorQWD2SOzgZti2jfvpK4rtzyaAvJ7FAAirYx9K9MYGsJ8ogA== X-Gm-Gg: AYBFou2CFQ0kDhFVvzAaA7dFyTBqzpW5pw9hG/Uq5MLDQop98OLGTPRoH3odK/oaf+c 28qJwxV5ch66n1bJr032Vpo+uvz7y3MEot2t09KnMp2Lew3UZWgFmANeFf30LNo+IL3HNZ6nUE3 lDxotwF4pkw/gaFJjxcEQeUDTIRB+GDyeTkhsib89a8XeFqDR6Zh7rP6wIx2QzwB32Px9JXDqCq sKpNOTYNiq3a26Qk3hjOdjKbQRf6gnrOO4Nk4wLbyoP63+fGk7C9UwNhOKsEjQEOYtxmTv7Hd/Y 4Bm+CV9kAkqRHyipUG9LPkHRyZqva9e5vnLM0PxsjMwU0hJQUOUzp6i9iggK9mWiBc0K1QCd5Jw Y1esD8Zn8HBW+MmPLFElhPtUHsMOArUXU6c6mD3NxbtGNqqkPQi0cGKNsRbJLupgBerq8hSNQT7 A70HaYu18L3Tgnl9jVAUM/uPRUG24WiQljn0s1VgPxBHaXYsCbWFgfEdbsO30J+kUVrHN6c12XW dghMLAQk1FiOMydG5bPtEeqroAGrAYgIGwO8gsIV1Y2KA== X-Received: by 2002:a17:902:ef52:b0:2d9:383a:30f1 with SMTP id d9443c01a7336-2d9383a326bmr139940935ad.4.1788249008298; Tue, 01 Sep 2026 00:50:08 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:8cf:6df0:9c4e:f5e1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d75988b699sm48142515ad.59.2026.09.01.00.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 00:50:07 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Matthias Brugger , AngeloGioacchino Del Regno , Dmitry Torokhov , Jiri Kosina , Andi Shyti Cc: Chen-Yu Tsai , Benson Leung , Tzung-Bi Shih , linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 5/8] i2c: of-prober: Let cleanup op know if a device was found Date: Tue, 1 Sep 2026 15:49:23 +0800 Message-ID: <20260901074930.764550-6-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.897.gb25b4bd76c-goog In-Reply-To: <20260901074930.764550-1-wenst@chromium.org> References: <20260901074930.764550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The prober's cleanup op may want to do things differently if a device was found, such as wait for the actual device driver to pick up resources. Add a parameter to the cleanup op to pass this information in. Also fix up an incorrect reference in i2c_of_probe_ops's kernel-doc. Signed-off-by: Chen-Yu Tsai --- Changes since v5: - New patch --- drivers/i2c/i2c-core-of-prober.c | 8 ++++++-- include/linux/i2c-of-prober.h | 7 ++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/i2c-core-of-prober.c b/drivers/i2c/i2c-core-of-prober.c index f9f3c0ef93ff..97ef58bb4c04 100644 --- a/drivers/i2c/i2c-core-of-prober.c +++ b/drivers/i2c/i2c-core-of-prober.c @@ -130,6 +130,7 @@ int i2c_of_probe_component(struct device *dev, const struct i2c_of_probe_cfg *cf const struct i2c_of_probe_ops *ops; const char *type; struct i2c_adapter *i2c; + bool device_found; int ret; ops = cfg->ops ?: &i2c_of_probe_dummy_ops; @@ -159,6 +160,7 @@ int i2c_of_probe_component(struct device *dev, const struct i2c_of_probe_cfg *cf if (ret) goto out_put_i2c_adapter; + device_found = false; for_each_child_of_node_with_prefix(i2c_node, node, type) { union i2c_smbus_data data; u32 addr; @@ -171,12 +173,13 @@ int i2c_of_probe_component(struct device *dev, const struct i2c_of_probe_cfg *cf /* Found a device that is responding */ if (ops->cleanup_early) ops->cleanup_early(dev, ctx); + device_found = true; ret = i2c_of_probe_enable_node(dev, node); break; } if (ops->cleanup) - ops->cleanup(dev, ctx); + ops->cleanup(dev, ctx, device_found && !ret); out_put_i2c_adapter: i2c_put_adapter(i2c); @@ -388,12 +391,13 @@ EXPORT_SYMBOL_NS_GPL(i2c_of_probe_simple_cleanup_early, "I2C_OF_PROBER"); * i2c_of_probe_simple_cleanup - Clean up and release resources for I2C OF prober simple helpers * @dev: Pointer to the &struct device of the caller, only used for dev_printk() messages * @data: Pointer to &struct i2c_of_probe_simple_ctx helper context. + * @device_enabled: True if a device was found and enabled. * * * If a GPIO line was found and not yet released, set its value to the opposite of that * set in i2c_of_probe_simple_enable() and release it. * * If a regulator supply was found, disable that regulator and release it. */ -void i2c_of_probe_simple_cleanup(struct device *dev, void *data) +void i2c_of_probe_simple_cleanup(struct device *dev, void *data, bool device_enabled) { struct i2c_of_probe_simple_ctx *ctx = data; diff --git a/include/linux/i2c-of-prober.h b/include/linux/i2c-of-prober.h index bb6d47f50ee5..f28a40780d1f 100644 --- a/include/linux/i2c-of-prober.h +++ b/include/linux/i2c-of-prober.h @@ -45,7 +45,7 @@ struct i2c_of_probe_ops { * * Only called if a matching component is actually found. If none are found, * resources that would have been released in this callback should be released in - * @free_resourcs_late instead. + * @cleanup instead. */ void (*cleanup_early)(struct device *dev, void *data); @@ -53,8 +53,9 @@ struct i2c_of_probe_ops { * @cleanup: Opposite of @enable to balance refcounts and free resources after probing. * * Should check if resources were already freed by @cleanup_early. + * |device_enabled| is true is a component was found and was enabled. */ - void (*cleanup)(struct device *dev, void *data); + void (*cleanup)(struct device *dev, void *data, bool device_enabled); }; /** @@ -131,7 +132,7 @@ struct i2c_of_probe_simple_ctx { int i2c_of_probe_simple_enable(struct device *dev, struct device_node *bus_node, void *data); void i2c_of_probe_simple_cleanup_early(struct device *dev, void *data); -void i2c_of_probe_simple_cleanup(struct device *dev, void *data); +void i2c_of_probe_simple_cleanup(struct device *dev, void *data, bool device_enabled); extern struct i2c_of_probe_ops i2c_of_probe_simple_ops; From patchwork Tue Sep 1 07:49:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 2295664 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=KHtxbtec; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=linux-i2c+bounces-20349-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hYytw2JVJz1xwg for ; Tue, 01 Sep 2026 17:59:36 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id 0B9713073D for ; Tue, 1 Sep 2026 07:50:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8963D470EAF; Tue, 1 Sep 2026 07:50:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KHtxbtec" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 9227E471249 for ; Tue, 1 Sep 2026 07:50:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249014; cv=none; b=CXNP6o6iCD2ODeqfE4WCKgsGATooRbLPIvkODZ7fWwB+pJ6iqORmsVnrZ+EQTzsTDdqL0iwg6x9fUxZtzhmIW/YDZtvl3/N8HkHCHQLa/czuyAA1EQyx93izBByFiPmzwJnKcAoBJ7PwNiyDy29x9mRtbio8ovYt1KcaT9ZW9Ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249014; c=relaxed/simple; bh=pi+LmqXIY9yJrLb+q4YTgitdGHvgUDFnXpm0aWGBEfY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fTvifK+9+iwd/awqZmXI2b7zXfV7AE9fWjDS7f3PnO5SCxKAxyRa/xe+9cMUGrpF9Dvlzfrb2qZQ37BWulK7a+pOK/xbLw/vpDkJ4mZfo0x5PXpfjvSzcM/QxfwFFBfW5Ug5OzU/+6HNZN/E5jWzuVhUGTY9ubY8BO8LAS06v2c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=KHtxbtec; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2cf452def93so6884135ad.1 for ; Tue, 01 Sep 2026 00:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788249012; x=1788853812; 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:content-type; bh=wWs+YupxZ44ht1HfvkGhk8oEQeiiBAO5zBbFEZpHIfw=; b=KHtxbtecrHGyH+XwE+ribIyy5vwWhnwwS4g1x+nyBhn6vn76S1VBsV/WYVT6tXK9xS zPNOWw0nbXgkVF+PTMzKdDHISatwhwCY+Fnt5ermYtlHvSz5pYj9jRioCal1K2RrkU+o PDPR4xW2b+5vux1dCjEDPGy1oR4w4hvmQUOHs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788249012; x=1788853812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=wWs+YupxZ44ht1HfvkGhk8oEQeiiBAO5zBbFEZpHIfw=; b=k/F1uVU17d2JwMi8+eGHbVu38684cA1+zHqgklYhW9cjKx2QJOXbnsvp1/wAaakn7E VHid3q2U577o+S+t0Hm6UAd2VszIrYMEl8paqeDYOpMT7pQcuy9n8iQl1YkhSck79Coa D6F+BDTNzMfOB7UTUrMHpS6/YP1jAt0N7826UOFalTHUmphVrV9VQ1G1ZA9MHVb+Azmu A6PWXbXb8axGaAAaAcRZauyz1J5zz4lUfFd3udaTkpqAmqnDqwsmpZwY9g5dGnAI9+v6 mQib8MGDzzedSVf60/prHBUyccCmF+YTSPQlG9r3E0HjUhBAAD06LpSRytXL7tOfw0Rq ylCA== X-Forwarded-Encrypted: i=1; AKwUvBym4wZk+dIvNpJLJ0heoBVQ89x4yXVMOgJ6oJnIhJEFrp9zXYdems4Uqg6L0qxPcyJpSb6v0E4Sioc=@vger.kernel.org X-Gm-Message-State: AFuF++lQ14IRwmYQVpZatYn0RVbAmIUtCCzuHAKkqmj790nStN7T7vsL OLWhdgvRlCuR7Pi6kOB9UK+fP3eBYFSmdFNVPj1vLJ3A0w91HqP9SWZCy/7ujgTO7A== X-Gm-Gg: AYBFou2fqMQjw5tc3DUtrV2OZCbvQYUOqTglo0XYjl528z+7MQpKUUHB7nWS/LdpufM v6U1pis0CeSSY/pFN4m5XTQ1OlrATkVPbcvrDa3UECCHvq+v8lbeAU3TGgAXxCcacrsl+IYNNOU 2M9/q7sxmr00fGPqRs4+qzBFR1gyGQ1KHVtoJrGyT+Pvr5XjIoK5IA1CaWLGo39SGsMwEYLb2nu 52GmfP4bX7YSf3MhvtM7xWGJdtgwAoWyTZX2qTYOAL78onaO+TokIhUpacfkHETydtQvNVBUB61 X3iD2mqbFAFX0PJZiooLcqvsqtwZlmAfoCs0IGMAj4X2grQTyKk+aeLL/0JIIygcDrpgZgP6uVr ZbpWyo8mcAwFR88b3oTC7fPYbAxZRQi5pICeHnqyzZMFFneHUs23C7+0/ArGIsIMR4DVTpIPJg8 ss555r5MDiQejOqCxaUAsCi0An9zriTdg5HtU+kuvVn8PArSLJP10LJY90898vYFU2sgv9AI52W s5ja1UgZ0tVnMRLV//cvA3PL1eGODPcu/oVyOJPJwOiqQ== X-Received: by 2002:a17:902:e747:b0:2d7:1b20:e98f with SMTP id d9443c01a7336-2d952687ef9mr35651975ad.2.1788249012058; Tue, 01 Sep 2026 00:50:12 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:8cf:6df0:9c4e:f5e1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d75988b699sm48142515ad.59.2026.09.01.00.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 00:50:11 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Matthias Brugger , AngeloGioacchino Del Regno , Dmitry Torokhov , Jiri Kosina , Andi Shyti Cc: Chen-Yu Tsai , Benson Leung , Tzung-Bi Shih , linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 6/8] i2c: of-prober: Defer regulator_disable() on successful probe in simple helper Date: Tue, 1 Sep 2026 15:49:24 +0800 Message-ID: <20260901074930.764550-7-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.897.gb25b4bd76c-goog In-Reply-To: <20260901074930.764550-1-wenst@chromium.org> References: <20260901074930.764550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When a I2C component is found, it's device node is immediately enabled. This triggers device creation and driver binding. The prober will hold the regulator enable reference across this part. If the driver probes synchronously, then it happens within this window. On the other hand, if the driver probes asynchronously, there is high chance that it happens after the prober's cleanup function was called, in which case the regulator would have been disabled when the driver's probe function is called. This would then require the driver to wait 100 ms for the hardware to reinitialize, even if the probe function was just a split second late and the regulator was disabled a few milliseconds ago. Recently, some of the drivers for the component that are targeted by the I2C OF component prober gained the ability to skip waiting for hardware initialization if the regulator was left enabled. This happens when the PMIC has them on by default, or if the component prober left them on after probing the component. Tests on the Hana Chromebook showed that if the prober and trackpad drivers are both builtin, then the time between the prober enabling the device node and the trackpad driver asynchronously probing is between 5 ms and 30 ms, though sometimes there are outliers exceeding 100 ms. Wait 100 ms before dropping the enable refcount on our end so that the actual driver has the opportunity to catch and increase the refcount on their end. Signed-off-by: Chen-Yu Tsai --- Changes since v5: - Only defer regulator disable if a device was found Changes since v3: - Added commit message section showing average delay needed --- drivers/i2c/i2c-core-of-prober.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core-of-prober.c b/drivers/i2c/i2c-core-of-prober.c index 97ef58bb4c04..f52ab3f54933 100644 --- a/drivers/i2c/i2c-core-of-prober.c +++ b/drivers/i2c/i2c-core-of-prober.c @@ -238,11 +238,23 @@ static int i2c_of_probe_simple_enable_regulator(struct device *dev, struct i2c_o return 0; } -static void i2c_of_probe_simple_disable_regulator(struct device *dev, struct i2c_of_probe_simple_ctx *ctx) +static void i2c_of_probe_simple_disable_regulator(struct device *dev, + struct i2c_of_probe_simple_ctx *ctx, + bool defer_disable) { if (!ctx->supply) return; + /* + * Wait a bit of time for async drivers to probe and increase the + * regulator enable count. This allows the drivers to check and + * skip waiting for re-initialization. + */ + if (defer_disable) { + dev_dbg(dev, "Deferring regulator disable\n"); + msleep(100); + } + dev_dbg(dev, "Disabling regulator supply \"%s\"\n", ctx->opts->supply_name); regulator_disable(ctx->supply); @@ -359,7 +371,7 @@ int i2c_of_probe_simple_enable(struct device *dev, struct device_node *bus_node, return 0; out_disable_regulator: - i2c_of_probe_simple_disable_regulator(dev, ctx); + i2c_of_probe_simple_disable_regulator(dev, ctx, false); out_put_gpiod: i2c_of_probe_simple_put_gpiod(ctx); out_put_supply: @@ -405,7 +417,8 @@ void i2c_of_probe_simple_cleanup(struct device *dev, void *data, bool device_ena i2c_of_probe_simple_disable_gpio(dev, ctx); i2c_of_probe_simple_put_gpiod(ctx); - i2c_of_probe_simple_disable_regulator(dev, ctx); + /* defer regulator disable if another device driver could enable it in time */ + i2c_of_probe_simple_disable_regulator(dev, ctx, device_enabled); i2c_of_probe_simple_put_supply(ctx); } EXPORT_SYMBOL_NS_GPL(i2c_of_probe_simple_cleanup, "I2C_OF_PROBER"); From patchwork Tue Sep 1 07:49:25 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 2295665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=eb45KZiC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org; envelope-from=linux-i2c+bounces-20350-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sin.lore.kernel.org (sin.lore.kernel.org [IPv6:2600:3c15:e001:75::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hYyvm1dXNz1xy9 for ; Tue, 01 Sep 2026 18:00:20 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id A838030C0F for ; Tue, 1 Sep 2026 07:50:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D0A646F4BC; Tue, 1 Sep 2026 07:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="eb45KZiC" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 62EBE471274 for ; Tue, 1 Sep 2026 07:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249018; cv=none; b=pQm66bjO2xcdgl7poWNJICydw9IhOdZQo6t+JT+GjXSCn8YUYT+DTz2e9GLga3rQHxsGScTUMo3cEOozjHrImXPfwdDQNwx4iLlWud8eZunqogF3CtD91Z0kZY8fw9A5+4fwgKV/RjfJJnxXCLad0sgvNFYiLhQCdXdpmFo8/3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249018; c=relaxed/simple; bh=389GhFdcHXE9CQfcu38KBKyKduXJD5XyKzkLeecuPRA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OzdGiKCT2gRYfXlN6Ms0qOqPwgMEPGIn7SfLHWx04xymnJ5p+8UWptE7Uk/GuSrAZD0ou+hE5I62Jw3MlbZU/nQ8exkYIxWcZ+M/RoJipiEon+1w2/Sb2HDV830OQK8PKPFraV9wxN2WdnBpvIVTSjSai7fCTQ6gef2XEZVTASM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=eb45KZiC; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2d01663d816so4350025ad.1 for ; Tue, 01 Sep 2026 00:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788249017; x=1788853817; 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:content-type; bh=2khEECovfca18HsEnd2rATuHpO1VYqgGWGgT+k6yyKQ=; b=eb45KZiCKTD+9RGYKgjYq1mwU4GKaWsxlxcQYsA0OvN0LApbY9pj9tCUGcKSPCHV4R +auvNxX5MR+5zz+wJqvIRnw4H8iew0FnhwnTfeGzpTSIykn3UB5eHffmAahmRUkwbbwK Rfb+VAaXBTaPHdvGaXrFDyGRsSldwULDH3VpI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788249017; x=1788853817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=2khEECovfca18HsEnd2rATuHpO1VYqgGWGgT+k6yyKQ=; b=JNV3chXJgwxCJTkgRgbGbYxQJKBbYVFnA1M8+1afMwdYI++OzQKfIp/PLYtC90tCfx VgOSEa9kxwcExxXKMNQqE8+1FRmV+SdphnBRYycN9ALomWkneB/7tLrWXoln3hZdKXr8 gbPaPGXkjbe3SWqLEREtHT4Ti/OFpm7QghDUTIv9nOkiQ3yowZD8cgXNdy6GWYU5xC8F 1Gmd/jAy1PfMndgQDkNTvUyB27Y2Zi1UI+8LFhSJycxDRZzjmMxJBUrnGlxDNhfIL+2X 9wFLZDlWwKc+0uFc4i62rvjQHQkuC8f8sEdwBg9n77MTNwIlvINWfV0A7aMkJSiT80ka +TVQ== X-Forwarded-Encrypted: i=1; AHgh+RrWKl8Vu+/1D23hIJPQD41w6D9OtWF24XlNsXw6dQ/31ABlP2FDH7VgmXDw0whtxZw4ZGZVA+QMp3Q=@vger.kernel.org X-Gm-Message-State: AFuF++nt+pViqXjGUAFXvp3AryE6vcg3fYnSY3HRy2eGEDhggRpnRS6Y pMRIgzDoFXWKlFnXW2dwW8cPzNlSuNl22dQNu0/BJRLEnf9fHCLXYxo355x3dqIbUw== X-Gm-Gg: AYBFou13xqI/ItEDU+F140Lhc7hAJdx9ZOwCAcM4+HnunhCbHxkfZAEwlyGRixDZweH AjYiUikrUZSactz/Sm3BhilFrz67EN7rFMuc+oDmEO/5G+XG1SXebE6m+DNuPj7GXfACryD85TR LnSxvrU2KJ3fQGcOS1ZrhPmTcexfFplrO9MC2FaxjHkLKbzhrmiDyrK9zijEhlquTkebg8zCNf0 0VBM03VPlpliJtAdabXfE/tl+rk4Zx0ZQhrb7Ag1BSZczaT2tN5Iv17302Ez2ez2wJeFm13NwH6 LyoRCI79tuDPXY4ySoPSgBLuYJ2F7BiQFIiHeJiFb0aJX2952W6YXYzs5ZEpcaANEiFEQZf2zmR gpCeu6YoLl26GI3ZGrQcpMlVk2XYPbTUyJmBJ+kkBGg6gD5fC7U1PtwGk0IJeoY1AlwAhHEVgx0 LodQrdFL9Nu6XJeGRz4OVorHOMDLYXe76koeCjxFZk0q57byb4byF5OWtoW/sEHypjR1YoaX8kj a98RKcmOBcmiwyp4jAb16a6Zn/A7jE8TVqb1l2XNzD6AA== X-Received: by 2002:a17:903:324c:b0:2c2:62ee:5a0d with SMTP id d9443c01a7336-2d74df1c634mr532551805ad.14.1788249015708; Tue, 01 Sep 2026 00:50:15 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:8cf:6df0:9c4e:f5e1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d75988b699sm48142515ad.59.2026.09.01.00.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 00:50:15 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Matthias Brugger , AngeloGioacchino Del Regno , Dmitry Torokhov , Jiri Kosina , Andi Shyti Cc: Chen-Yu Tsai , Benson Leung , Tzung-Bi Shih , linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, stable+noautosel@kernel.org Subject: [PATCH v6 7/8] arm64: dts: mediatek: mt8173-elm-hana: Unmark trackpad supply as always-on Date: Tue, 1 Sep 2026 15:49:25 +0800 Message-ID: <20260901074930.764550-8-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.897.gb25b4bd76c-goog In-Reply-To: <20260901074930.764550-1-wenst@chromium.org> References: <20260901074930.764550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Up until now, the MT8173 elm/hana device tree has set the dedicated regulator supplying the trackpad as always-on, simply because the Elan driver was missing proper delays. As a result the delay for the Synaptics trackpad was also omitted, as it was not strictly required under such a model and delayed the availability of the trackpad to the user. The Elan driver recently gained proper delays after power up, with opportunistic skipping of the delay when the regulator was originally on. The I2C HID driver gained similar opportunistic delay skipping. So has the I2C OF component prober library. Now fix the device tree to have the regulator not be always on, and let the I2C HID device have the correct post-power-on delay time. Cc: # needs matching driver changes Signed-off-by: Chen-Yu Tsai --- Changes since v5: - Added noautosel tag --- arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi | 8 +------- arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi | 1 - 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi b/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi index 1004eb8ea52c..b9e311fcd9a0 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtsi @@ -62,13 +62,7 @@ trackpad2: trackpad@2c { pinctrl-0 = <&trackpad_irq>; reg = <0x2c>; hid-descr-addr = <0x0020>; - /* - * The trackpad needs a post-power-on delay of 100ms, - * but at time of writing, the power supply for it on - * this board is always on. The delay is therefore not - * added to avoid impacting the readiness of the - * trackpad. - */ + post-power-on-delay-ms = <100>; vdd-supply = <&mt6397_vgp6_reg>; wakeup-source; status = "fail-needs-probe"; diff --git a/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi b/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi index a0573bc359fb..6b9f47f515c7 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi @@ -1093,7 +1093,6 @@ mt6397_vgp6_reg: ldo_vgp6 { regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; regulator-enable-ramp-delay = <218>; - regulator-always-on; }; mt6397_vibr_reg: ldo_vibr { From patchwork Tue Sep 1 07:49:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 2295666 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=WqypnplQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org; envelope-from=linux-i2c+bounces-20351-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sin.lore.kernel.org (sin.lore.kernel.org [IPv6:2600:3c15:e001:75::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hYywY0tXJz1xvS for ; Tue, 01 Sep 2026 18:01:01 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id 44A9330FCB for ; Tue, 1 Sep 2026 07:51:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAECB471CF2; Tue, 1 Sep 2026 07:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="WqypnplQ" X-Original-To: linux-i2c@vger.kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 1DB4447141A for ; Tue, 1 Sep 2026 07:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249021; cv=none; b=HDFVIF238wU6GviQ1QqwypX0R2FRG6pjHS6LkQ4/E2fEpi0YL1wZn7j37k0PkDdrEb7/R5KXB8hExlDOiBh2Y4DGcraM7arOP6rDZhsp/U7JY4sPjl6JTBUCshEm/Mz1+XmVQ5AdyfnnYrsjkVNqUxk3n1eguOCPXVxfA0FzODw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788249021; c=relaxed/simple; bh=/rbvHcyLFzkOkhdGFkadotpTkB6WTk/HoLFqLifD8i0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s4Mkz0ezK/zM33ne470BgnxvmVPuEGrRRnFJDEmgbQw5HTISOIid9p0hx9dIH5c4Ygrm9tw5D662l0YRkSycn7DcUGILPZwQ7ZRuPgNWVnYWK92KUpa7CZtSlFedXVH53rXtZbDOt11FkPcNdmedPxwcRUux5O84yn79KnIinu4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=WqypnplQ; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2d71ae3455aso8934785ad.1 for ; Tue, 01 Sep 2026 00:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1788249019; x=1788853819; 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:content-type; bh=3ehsC4fkcGYgZxU5YfTTtJEKH9Dtw/4IjhfNmBesfrM=; b=WqypnplQyVWsYZqIG85/APXZrVaLZMa5u3WqpFXEkkKjbClBhfvPLbN1GRxNgMzLMO AZdP9/+Yto4wK5TR3mQmZ/qxx1OHofL+O6uy5a7Y4qsPVk2XIxg9E1snvDjtAHy9/BoB yiRZne9aNo9S0PiBiWJ4DxUk9yuw+sqaUbSXw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788249019; x=1788853819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=3ehsC4fkcGYgZxU5YfTTtJEKH9Dtw/4IjhfNmBesfrM=; b=B4Upx0BOmLIG6gqNgO+eOtJO1BC+UL5LNwWp/3d0WLgkRHWIs4bIqr79KO8eoHll6V 86Cr4Af8KutjXRODYO1jv8mztOlQ9iIPXG+nh1r5zfczd5e/o6djRwB6HKO3zqzeY9/S ZF0rnZqWUmY8lS/K68XkoQizs9KNb7lW3eeN8RaETQFYT7NbD3OB8zpkLAseCq1b6M1B rBHeYl06kAd+B8nA/TR8181zucgFrSj/VF4Os4/WVN/+U02kEEFbivITl1rp36Ish3RR Zycm/7VuDni2nMbfi+rXG4msgL/lNlcEWKJCAxIZOa3EJwMP3PnERQj1erIEeOssHwYc s1+g== X-Forwarded-Encrypted: i=1; AHgh+RoEQuA5oQml44Yb5QSb+cWtbbycKnkr/WCB1WM/arc+bDrrAa27h+qXe9HH8QI9e5mlGIhL7o5jY0M=@vger.kernel.org X-Gm-Message-State: AFuF++mIB+dCaj8lG4DNBqrVyjB7WAxZJ7nN2HzOk26wPz/DxjJCHQQF RAF43GeZ+Ma1ayLR8gQ1GwCGIZE1k2ic8ZcFmQM1eTCzr7Vr4yh5EkWbgRgTrr5SQA== X-Gm-Gg: AYBFou3HT+Wj+KZjyd/owx1R+63DTg4CF0urk/R+fOFFRFMwXFB02ZXa5L94+upfhRS SQEvicM0lVK1MUO1k8A+/jDDRXNkmN61PMaX7i4upYRBehT4dygPPr3oUF3xw+19k1NemsaFNvV +AXNrb8ukvAjAjnjf6WmGkHuc5EcL1cs58i8yq2lubeL9u4xbLqTgwvAoBgjEn5MzrX5PpFAk63 nFChBinno4Ct0LJbGlimLyDFN6jQrd8I5Xn96RdLQVC/0KHNSFtphWAs2HIkC1fmeIFugUZ2IGX AgJdtX3kmosExzbLhuJePEVzN3ngGwYIfGJPvbtv9q9j/2Jitxd0d6Hx8zouWvK6byfVlpAMRw0 6xx9lVJ5bbHYlNOYEA5B4h2czTeq6bv8woPj+WMiYwTBKUolmLKdQRHcltLvzGDWANN1tcjKnjM FXXRHaYYvnccMXrE1w9jZIAaIA9ZlbzFrercqaYy2R1VKnv3HZKjQTECCiQye3/JTlCHT45CAVp gl3Lc5miClXeK2Im69rSb6wnbwSLsNjIHtG3gk2fyhUTlw= X-Received: by 2002:a17:902:f791:b0:2d9:1dee:43db with SMTP id d9443c01a7336-2d91dee456dmr196089085ad.15.1788249019467; Tue, 01 Sep 2026 00:50:19 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:8cf:6df0:9c4e:f5e1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d75988b699sm48142515ad.59.2026.09.01.00.50.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 00:50:19 -0700 (PDT) From: Chen-Yu Tsai To: Mark Brown , Matthias Brugger , AngeloGioacchino Del Regno , Dmitry Torokhov , Jiri Kosina , Andi Shyti Cc: Chen-Yu Tsai , Benson Leung , Tzung-Bi Shih , linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, stable+noautosel@kernel.org Subject: [PATCH v6 8/8] arm64: dts: mediatek: mt8192-asurada-spherion: Add Synaptics trackpad's supply Date: Tue, 1 Sep 2026 15:49:26 +0800 Message-ID: <20260901074930.764550-9-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.897.gb25b4bd76c-goog In-Reply-To: <20260901074930.764550-1-wenst@chromium.org> References: <20260901074930.764550-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The Synaptics trackpad, like the Elan trackpad option, is fed from the system 3.3V power rail. Add it to the trackpad device node. Also add the correct post-power-on delay, even though in practice it is not required. The Synaptics trackpad requires 100ms after power-on (or deasserting the reset, whichever comes later) to fully initialize. The power is always on and the reset pin is not routed out, so the implementation could try skipping the delay. Cc: # Without driver changes only lengthens probe time Fixes: 925ebc0cd55c ("arm64: dts: mt8192-asurada-spherion: Add Synaptics trackpad support") Signed-off-by: Chen-Yu Tsai --- I think this shouldn't be backported, as backporting it without the driver enhancements just delays the trackpad probing with no real gains. --- arch/arm64/boot/dts/mediatek/mt8192-asurada-spherion-r0.dts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8192-asurada-spherion-r0.dts b/arch/arm64/boot/dts/mediatek/mt8192-asurada-spherion-r0.dts index 68caf4c58cfe..8adbfc307fca 100644 --- a/arch/arm64/boot/dts/mediatek/mt8192-asurada-spherion-r0.dts +++ b/arch/arm64/boot/dts/mediatek/mt8192-asurada-spherion-r0.dts @@ -94,6 +94,8 @@ trackpad@2c { hid-descr-addr = <0x20>; interrupts-extended = <&pio 15 IRQ_TYPE_LEVEL_LOW>; wakeup-source; + vdd-supply = <&pp3300_u>; + post-power-on-delay-ms = <100>; status = "fail-needs-probe"; }; };