From nobody Mon Sep 28 07:18:12 2026 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.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 C9F82373BFE for ; Tue, 25 Aug 2026 04:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632418; cv=none; b=ivIYLKwG7eEwGQogRfmawUNlZOvnsZp+nmeoJZ+9KJNToCpj4YJy5N/VPZdJoyAhmlpH1uk0mmwNtKGjn4xdX9VJW78nx3+Py2kEKhlvY58ZfJRBVm4bl9Gx2tHCD+rvLlLjj5FOnp7mCZ07BbrYsqnbtham8rm55BiIS34UgLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632418; c=relaxed/simple; bh=5liJqj0QW6Tv4bSobBKxKVRFmiJfUE2WNmpCIGzcBLY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F/iY9sr0nFHvCm+Vu+nPSyMLCk4e9LEVY+KIsi5YoN77JeVS78U1dEe0Wl4uLntR70QBYl+lNWcsgPn0AlzQv6ifZQdfUdCKOIspEUwkDD5oTH/ay3nZkkyi+m3gDOciSt3oVCs8FCtyx0xoyOPGLrThRN6lqyNps9tIOWEHQFs= 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=VUWxEdEj; arc=none smtp.client-ip=209.85.215.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="VUWxEdEj" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-c9e7391839cso4159918a12.0 for ; Mon, 24 Aug 2026 21:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1787632414; x=1788237214; 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=gcqeYVtwEdBoGSrDXdk4fs5867JCY5OOBmzd0xKFWVg=; b=VUWxEdEjZOzPo4+xS0sT8mSHd8kXwsPSa15zl0dWGuye+sDDB1uxuuRfDAYPYPJo4m 0R94uFYshkQipaPbAVDmTFTpwwPnPd5mQ5fRVuzZpWJTjq9J0l5IUScx9vDoWH53N2w3 ftkJrrrNNLikjWxMjhAYaThEpPWhejL8CK4lk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787632414; x=1788237214; 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=gcqeYVtwEdBoGSrDXdk4fs5867JCY5OOBmzd0xKFWVg=; b=UBlRy+8VIyiwJaBHvUCtgs4bIScF8AkCknEnq9VMU+pk72XY5gnbiqij50it1ialKC v6qdjwDt7u6DLtFdgUvn1TvHEml/QjlZ64B8xci4fW070mXsRxIyXXi1t43uVfd/G/+G kMPv9oYm6s9QAO3or7gU2xN5DhEt0no5gk2X10DXarlVEflxxQdGOWXaLkXl6PzuyyeC LH5SpuDIZHNDdlixR5T1wsTWBXw9LAlGYyizqFVjH6ICqov4pzWwPYE6F6XQzwOWVQMk cs44y9OyW/2CU/XcEL+8o5NlJc1AVbfFHqTBQ4W6zu4oiFAog1KckUoRo9h+u+jRPt69 ab+A== X-Forwarded-Encrypted: i=1; AHgh+Rpo/7kxRVRZVHytjaKRpOOFJbZa0x1NLp47zbz7EFgIo61gd/6wUBB7XMo+8yEiLOO9w+0Cqr65+D/Pd4M=@vger.kernel.org X-Gm-Message-State: AFuF++nHXgraXzfGCh8xpyYRsnNL5Slcj9FxOh8hLzK+xnwJ1EOd+6+t gs8h84tqzown6lrTkfuerx3yoKkc3PsCx7SLP1smAzpPpJ9fv4teoM9lRuM3iyJr2A== X-Gm-Gg: AR+sD10CDGlGLISI5P+lEbJQAiA60Z4n3Uj+Tg6XWiwybq+H+Lm/qO4Ca8uqOOwEp9k 2rBjtGKvetyn0/2kAy08pMUE5IVDKHTvUIm3A27lHYsrQI3rREo8ktWv2mlGV4DNwcR2UVZZXUx EV9Xn6tjQzvnlhXnPOX9cS8lKia3RXAqytJdzScztKdixJlfpxoEPZux/zw8krTwCg77Cxpq+Gp Nhyit4nccYzlrEyy6LI27k7+DDwrzUMy3z98xj6A/9ueterFN1F5lGFit3TOf3BWnsf+vZaPQ0Q jTzP5fEYfByrFIxY1elRskBMPRX+yKWdlEx5tpLzBAADPAvMN2z9+JXnZzFSJIgbDesGj6bIbHP juV4tY3S7bIRLRD+kBX+NTOKuLtVWpSeHpa8kWEvWz9G3Zm16WS0UbSvQXiGKJiVW6rgX6b4aAQ yisSaNGLu+V61QlBm8mW+nxly0tn0q5Ui3NkPInf/r6smhw0RUon1OkHg9ZltazX2N4i/pEsDbu NCB1peAqpdBfUtrQ6bj5+2iMILd6pxFrdSPFsE7nLs/dus= X-Received: by 2002:a17:90b:3911:b0:395:543a:cf3b with SMTP id 98e67ed59e1d1-396463084famr7174715a91.2.1787632414107; Mon, 24 Aug 2026 21:33:34 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:a442:9780:24da:cb4e]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-396458212absm2187823a91.0.2026.08.24.21.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 21:33:33 -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 v5 1/7] regulator: core: Add "enable and wait" functions Date: Tue, 25 Aug 2026 12:16:19 +0800 Message-ID: <20260825041628.988369-2-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.860.g4b6b3295ed-goog In-Reply-To: <20260825041628.988369-1-wenst@chromium.org> References: <20260825041628.988369-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 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 | 117 +++++++++++++++++++++++++---- include/linux/regulator/consumer.h | 21 ++++-- include/linux/regulator/driver.h | 2 + 3 files changed, 119 insertions(+), 21 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 6a4008f387b5..3cc01b2f4c9f 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -99,7 +99,7 @@ struct regulator_event_work { unsigned long event; }; =20 -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_d= ev *rdev, (rdev->constraints->always_on || !regulator_is_enabled(rdev->supply))) { ret =3D (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,44 @@ static struct regulator_dev *regulator_dev_lookup(st= ruct device *dev, return ERR_PTR(-ENODEV); } =20 +/** + * _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. + * + * 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 =3D _regulator_is_enabled(rdev); + if (ret <=3D 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 +2408,14 @@ static int regulator_resolve_supply(struct regulator= _dev *rdev) } rdev->constraints_pending =3D 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)) + rdev->last_on =3D ktime_get_boottime(); + regulator_unlock_dependent(rdev, &ww_ctx); =20 if (!do_final_setup) @@ -3061,6 +3107,8 @@ static int _regulator_do_enable(struct regulator_dev = *rdev) fsleep(delay); } =20 + rdev->last_on =3D ktime_get_boottime(); + trace_regulator_enable_complete(rdev_get_name(rdev)); =20 return 0; @@ -3130,8 +3178,8 @@ static int _regulator_handle_consumer_disable(struct = regulator *regulator) return 0; } =20 -/* 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 =3D regulator->rdev; int ret; @@ -3139,7 +3187,7 @@ static int _regulator_enable(struct regulator *regula= tor) lockdep_assert_held_once(&rdev->mutex.base); =20 if (rdev->use_count =3D=3D 0 && rdev->supply) { - ret =3D _regulator_enable(rdev->supply); + ret =3D _regulator_enable(rdev->supply, NULL); if (ret < 0) return ret; } @@ -3177,13 +3225,19 @@ static int _regulator_enable(struct regulator *regu= lator) } else if (ret < 0) { rdev_err(rdev, "is_enabled() failed: %pe\n", ERR_PTR(ret)); goto err_consumer_disable; + } else { + /* regulator already enabled somehow, but timestamp might be invalid */ + if (!rdev->last_on) + rdev->last_on =3D ktime_get_boottime(); } - /* Fallthrough on positive return values - already enabled */ } =20 if (regulator->enable_count =3D=3D 1) rdev->use_count++; =20 + if (last_on) + *last_on =3D rdev->last_on; + return 0; =20 err_consumer_disable: @@ -3197,31 +3251,49 @@ static int _regulator_enable(struct regulator *regu= lator) } =20 /** - * 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 sin= ce + * 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 wa= it_us) { struct regulator_dev *rdev =3D regulator->rdev; struct ww_acquire_ctx ww_ctx; + ktime_t last_on =3D 0; int ret; =20 regulator_lock_dependent(rdev, &ww_ctx); - ret =3D _regulator_enable(regulator); + ret =3D _regulator_enable(regulator, &last_on); regulator_unlock_dependent(rdev, &ww_ctx); =20 + if (ret) + return ret; + + if (wait_us) { + ktime_t end =3D ktime_add_us(last_on, wait_us); + s64 remaining; + + remaining =3D 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); =20 static int _regulator_do_disable(struct regulator_dev *rdev) { @@ -5390,30 +5462,38 @@ static void regulator_bulk_enable_async(void *data,= async_cookie_t cookie) { struct regulator_bulk_data *bulk =3D data; =20 - bulk->ret =3D regulator_enable(bulk->consumer); + bulk->ret =3D regulator_enable_and_wait(bulk->consumer, ACCESS_PRIVATE(bu= lk, wait_us)); } =20 /** - * 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 wa= it * * 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 sin= ce + * 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 =3D 0; =20 for (i =3D 0; i < num_consumers; i++) { + ACCESS_PRIVATE(consumers, wait_us) =3D wait_us; async_schedule_domain(regulator_bulk_enable_async, &consumers[i], &async_domain); } @@ -5441,7 +5521,7 @@ int regulator_bulk_enable(int num_consumers, =20 return ret; } -EXPORT_SYMBOL_GPL(regulator_bulk_enable); +EXPORT_SYMBOL_GPL(regulator_bulk_enable_and_wait); =20 /** * regulator_bulk_disable - disable multiple regulator consumers @@ -6243,6 +6323,13 @@ regulator_register(struct device *dev, goto del_cdev_and_bdev; } =20 + /* + * If no supply was given, then the last_on timestamp could not have + * been updated in regulator_resolve_supply(). Check it here. + */ + if (!rdev->supply_name && !rdev->last_on && _regulator_is_enabled(rdev)) + rdev->last_on =3D ktime_get_boottime(); + rdev_init_debugfs(rdev); =20 /* try to resolve regulators coupling since a new one was registered */ diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/c= onsumer.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 { =20 /* private: Internal use */ int ret; + unsigned int __private wait_us; }; =20 #if defined(CONFIG_REGULATOR) @@ -192,7 +193,7 @@ int devm_regulator_bulk_register_supply_alias(struct de= vice *dev, int num_id); =20 /* regulator output control and status */ -int __must_check regulator_enable(struct regulator *regulator); +int __must_check regulator_enable_and_wait(struct regulator *regulator, un= signed 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_a= lias(struct device *dev, return 0; } =20 -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; } =20 -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 regu= lator *reg2) } #endif =20 +#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/dri= ver.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; =20 + /* 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; --=20 2.55.0.860.g4b6b3295ed-goog From nobody Mon Sep 28 07:18:12 2026 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 DB447356A12 for ; Tue, 25 Aug 2026 04:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632420; cv=none; b=Pa+IMRGG153rwHPSV5JuUlyQtWbYCRVFA90DJYdjbav/8CX/KEFjX0sPBgcp3c/5EZSgZgfKeaceavGUxD0wM7h2EYuEquAdhQa0GEyGH+ETbTovtBf7ZE3U2ZfXt/YvB/EAKSLQZ6Wy+3+VxN1sKeu38Q4IHAUzhxvVeXZtgVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632420; c=relaxed/simple; bh=cRuzIp0YKHNVkHOrNUk+CYNCeyPuFKnnKm3lwy7T2Kg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bqwpDVyKROegT7+9zmL+31KDgLBNvTvwIUuiTuRz+3FGORkx/9rVm9XcpVgt3ZpZYBhh4tRb1vP6J97jRRIkl0f1a6ZJcojyKJhPZNm3BWWZUWaf6JOC8eU9TRUsnwczWKL/1BzM2B/H/VKbXwKAczNhsujkW5JOimVvqFCF7/I= 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=a5mAseLU; arc=none smtp.client-ip=209.85.215.178 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="a5mAseLU" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-c9eefcf9175so4392445a12.3 for ; Mon, 24 Aug 2026 21:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1787632418; x=1788237218; 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=O3x3zvQVHa95aIkNqH4RuqCyE87uGo0+4gPg8D8l4X4=; b=a5mAseLUz17+WwOGp1O1stqEVmt+F4+9JwoBJr2emmTS3J89/GxvL8TEJdgOOql0AB e/KDsQkkdntGrN5ellJGF7oHU2woSgCJmbEfcPqUyo/XCFo3RmNCbdh0cT6gh7GibZ2E Em6y/Y5YR+h1wx2CrkYGpcoXNq2ksDmOftYhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787632418; x=1788237218; 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=O3x3zvQVHa95aIkNqH4RuqCyE87uGo0+4gPg8D8l4X4=; b=tEpJeBJijxnK4Aj5UP5toiH2LWO0zYVXAo/2KAHQu4AeE/6yn11D5/VVRBtIrdgQux QGfHrZXepQ4AESl9uI80JnG9lYSd//XZHLwjiBhxp6+1J5rTRCt6jr9axGlfJFjaont5 Eu/jqDNCbPrMgqGavxGfE7iSqFQvsZP/yILdT5xMB0J+H9Lvrvyse5FWAA7PMEHrCwoh 9l9cAy3O16g+jqpiZWIkC3WNGAXJzYcX3Zw/BOSo5CCu16WiL4Keb4ellBUSa/DEyZdW L7xqzREfoYT+F7l3vraFBZBELjuEdtWYbFcTRv4bfCpp0SFUan3pLXRzRA/M0lnj2h7y HlRQ== X-Forwarded-Encrypted: i=1; AHgh+Rp1H5XSzHBD0fJDexMZkeaae8dKJ9gssjI19RMjmH7LBA3eBRC/KcvBiCixnV1QLrZzXooWQevfqCguPTw=@vger.kernel.org X-Gm-Message-State: AFuF++nNce7UVEJPXoJgSGaDKerBxOE7NGj3FJIjO7F7OUzdZsMfdwly QQmS5MmBbL1IciIoyJzKOHWuDFoIQd5U8ZXetj6dhtDPg80heV4yMJKa1fXLJCtKaA== X-Gm-Gg: AR+sD11IcTl+L+B7SY/IhpdIC8M26dCV0OBi9VfoJn65k2G6pLoJ1qYdy4HPvE1kjoN 5Kj+zec4AuigrJ0daUXuJn2iKnZqDqjZaROG0pEOavrlRNDmYIuMBIU/zAgWmHdRwcGQLb1LoES S+xXX+rAxbbGOEP0mU7URxLdIAX+XcukHZYPEeiKDhsWS3OJhRYWqkjzboWvUl1eKr7R/JYUBlz H12iiF5sCr8qv5bdV8kjjOlrVGo1X/Lr6M1IAZOJfgVIH3LE6bUIjIzmeTW5XSJRpOBb+XrV/Vq xFEHISoxabEtmnL5ZomTPe/ntGko/DNbzh5QcPS6qrBf6wrBvL+tioxeeOo222r6SeouSWFNYfN IbclU0hUWWNxznmfgXYAOqx+erocAornCMOvsKhI/MIRgS3UO80zyRwPowEsPINSHCAFWxE/e9L qCt0F8LK8fQO61DTu8dL4gawyEcp4Mbq1QBgsSwdM7Shsl7MnJ1heoWIxBYGpmiBGkRGOUr3d/5 Bod5ic+cV9SHGLlzf26jHUG3WfTcithmozEJ01ovXG0/H0= X-Received: by 2002:a17:90b:574f:b0:38e:49c0:75a7 with SMTP id 98e67ed59e1d1-396463f1346mr8081145a91.8.1787632418173; Mon, 24 Aug 2026 21:33:38 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:a442:9780:24da:cb4e]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-396458212absm2187823a91.0.2026.08.24.21.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 21:33:37 -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 v5 2/7] Input: elan_i2c - Wait for initialization after enabling regulator supply Date: Tue, 25 Aug 2026 12:16:20 +0800 Message-ID: <20260825041628.988369-3-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.860.g4b6b3295ed-goog In-Reply-To: <20260825041628.988369-1-wenst@chromium.org> References: <20260825041628.988369-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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") Link: https://lore.kernel.org/all/20241001093815.2481899-1-wenst@chromium.o= rg/ Signed-off-by: Chen-Yu Tsai --- 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 =20 @@ -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) =20 /* 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' regul= ator\n"); =20 - error =3D regulator_enable(data->vcc); + error =3D 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; =20 if (!device_may_wakeup(dev)) { - error =3D regulator_enable(data->vcc); + error =3D regulator_enable_and_wait(data->vcc, ETP_POWER_ON_DELAY_US); if (error) { dev_err(dev, "error %d enabling regulator\n", error); goto err; --=20 2.55.0.860.g4b6b3295ed-goog From nobody Mon Sep 28 07:18:12 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 9B1403A6F0A for ; Tue, 25 Aug 2026 04:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632424; cv=none; b=eESjCtytIL2w0y5y/M6uZbeLECKbWHM029ffyRaq6c1pZpQlhtR0VqvDZfXiydvoYfz8zL8L68RGOCi9O1nBnQ7oZ/73itHSty2mH2HfZ9WAhxhipzc889i0PdoBENuBo28HtWF5z8Oks2Ym6dQ8/Ptw34WnqZObYd33RTYEsN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632424; c=relaxed/simple; bh=Ilgr0c2G4UGsySFV2bD0fiAVVF8lI3iPrBZ7oXN+Wgw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PZO2+iepu11HNcM3XJBKX4f8KsOK+Kx6Yf1SHH/6jZ9Sl7s9nC7M3R1XD0p26emMdgoRj8C+ZrprKiC0GHaUodAB98g1YlFCX3crvS0O764lBDH1qh8dkjLYdOfa+IqtRgENi/a8/tm/TPVkqToPqfuYKVOiuyFB1rRm8FaIC48= 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=c9K8cPqX; arc=none smtp.client-ip=209.85.216.49 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="c9K8cPqX" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-38d489b6b71so5139004a91.0 for ; Mon, 24 Aug 2026 21:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1787632422; x=1788237222; 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=GFuutJe+E+uxqdXe1I5xllbey7G2lsjmwPbc3FHp/cg=; b=c9K8cPqXigFe5zjywcRxm/M/n49+Cxa+zh+2mbO2oWIDexxYpJH8rxXXcCzup93G3+ R2ibgROjUigyp1L3YT6t34gfmGlHlhNJR8Bfuvvb50PkHB1hR/wWuH71TRXwbr5VJ5Qx XnN56lnnXzsN5MM2dEDufwFOrSgHCUb0IQWeY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787632422; x=1788237222; 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=GFuutJe+E+uxqdXe1I5xllbey7G2lsjmwPbc3FHp/cg=; b=BkU+kUvjJ4bkBZpp1b1LQJLp0UvGlJwDvQN+iyPHQ5L31xLdAq0nY+e2vc+ce/3Pw3 JYwb5zp5/mzgblF+O2iA8E5hKKaB01nugEq98vYfI3n8MZnlNsZhUHXVow72DK9GNx1E ZWKFT+iqoL2AKwbVB5MJ49go30nXc/0dA6FX3MXd5dZCnOwKLLPw01+Ncmdr4c9O/YJ8 cwYNAN1mZQMRx8XfVnqGVmxzNhrfrTYAWtsD2dPiQS9bNxBsH5zMWxc/7NaeUN1CnxgV 5tMXqD1Z238FB1fbdBExy3NPiJvQ5EZfgf0aWvWPm/sXGlTnL64yJmLLCnMwJXEcRZOA x/ZQ== X-Forwarded-Encrypted: i=1; AHgh+RrE7RsE1FrqmFUdpuo1WT9zPsyxpQB14CNY2uTWtomSnIXJBebA8v/Nir2/cPO07AP37QGZphdYsjvp9aw=@vger.kernel.org X-Gm-Message-State: AFuF++k3ke3dty/8hnzVYVk1GnoauCOUn1YWtG8LiC/Hieha7+4wQ5xG eRCWSsaej3R5C9/jZS0EYtziTGJGeIZ4GdfBsF/afwOTaOqP5g2HgSY5zDjcq5joqQ== X-Gm-Gg: AR+sD1230ekMGNMhP/72tFC8Bb7cFk/mQDHVViYedwH/ZAlnFmv7CJRW5snnZNQ/vj9 F0r68jfpO3T3N2Xz15FyrV/KDg5ABub6dmUMgaceitL9SagbImSJZYbEg6OyPp7jaE4VNcFW0dt +xTn7hJVImfwBsvNM4PIsD7D88DYweHFH0i1kEXhu2ZxufKMyRhvBaOAYznFJNjANW5HvKsYNBm 2Yfzf5pWXRrRKfXN7V4NmJI77Vp9oFSfqn9AvBV9LY5AptZeaf1ba8Yaxnwlal9xXkIYMKvgWVP iAeFJ1tC01PNWRkvLQG5yLHoNYLl3RZIxpzDFqwfVEei0QVU/Hw1Ed5t7Bz/dSDKTZYRtUClS68 GcRoeOG25qANuiu0zUjDKxfEWK/qlg0bM7JaZ5/WU3ovXFxHY5fKJuh2/IoC690tL5SVP0n43YJ 8N3sKxPtfTJkmZb9DWW5h7F6jnTcyAfIi886QzCTOHdx8vjrV+eItTaAHd7g0KWMeACpLi0P46t 6dDIQl8A+NBW9NskK+JDizmllOmDOTecoEFmB29hcp2Y5XyeJLGCd3UJA== X-Received: by 2002:a17:90b:164e:b0:38f:2168:b9cb with SMTP id 98e67ed59e1d1-395c352fa60mr48644179a91.9.1787632422068; Mon, 24 Aug 2026 21:33:42 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:a442:9780:24da:cb4e]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-396458212absm2187823a91.0.2026.08.24.21.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 21:33:41 -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 v5 3/7] HID: i2c-hid-of: skip post-power-on delay if powered on sufficiently long Date: Tue, 25 Aug 2026 12:16:21 +0800 Message-ID: <20260825041628.988369-4-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.860.g4b6b3295ed-goog In-Reply-To: <20260825041628.988369-1-wenst@chromium.org> References: <20260825041628.988369-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 #include "i2c-hid.h" =20 @@ -48,16 +49,14 @@ static int i2c_hid_of_power_up(struct i2chid_ops *ops) struct device *dev =3D &ihid_of->client->dev; int ret; =20 - ret =3D regulator_bulk_enable(ARRAY_SIZE(ihid_of->supplies), - ihid_of->supplies); + ret =3D 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; } =20 - 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); --=20 2.55.0.860.g4b6b3295ed-goog From nobody Mon Sep 28 07:18:12 2026 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 A1AE73A7D81 for ; Tue, 25 Aug 2026 04:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632428; cv=none; b=j/H60h6HvgJjuQx36dSyF4fHeO5xifV0+IHiD2vghuXuGHXqFRayyroPntVRNMu/ZHwnD5IeVFivd8henT+zU+upnHsAlJUoFY6VGtQqXD/KrVNmqPo91jNeDS4OW5VKPpLW/GO92roiXzM39xzjz0kNCDYhF2xaqoDbqe+r238= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632428; c=relaxed/simple; bh=RLvkM8rAzL3RhKW8i1oL2AWPBIGjPlkazQkJ9ggYoGc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i6BvCSxX1TiL8RIu8muSJ8mgM7DHAT3GqxnCtvFY01sABBj0QgfBPfViGaPBsXhVMzOjYsv05ffQz8HZ9S+lUOy4TMmOtjOvkbGzZV7wSXZjrBMkSYQ8nM1Ob8YYD0IEMH8m6f+a+Jcv4uS16XPXrv22pYPY740tilYKQ70JAGM= 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=nckBrc4R; arc=none smtp.client-ip=209.85.216.50 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="nckBrc4R" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-38e42560ebcso3408028a91.1 for ; Mon, 24 Aug 2026 21:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1787632426; x=1788237226; 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=mwfUQZyxeQn6CZecIrqNJeI2DT4d3jBF64B9NW5XMEM=; b=nckBrc4Rqk6p2KSHLYVlCfj524jyUNtTthzfSHPiKEznsc4le02TxNdlM4k9Ib4867 ge4Nj30U5tNOVz4j+2Lh0fo3lDfs+3uHy2oI+RTIiC3JpZizx8x/namANmy5ka/+Z5RS bGWGgg/+Aocacvev/t+oJqQ4i1C5HUXB8XKm0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787632426; x=1788237226; 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=mwfUQZyxeQn6CZecIrqNJeI2DT4d3jBF64B9NW5XMEM=; b=SVGUR70KbBCZi/g24UP8M8+UVuCqgYbbnHsZ3FZqVXRp0KIql75UOOIElqIUEPVVhZ +3ItdC4Jakx6QK3GGoyUz3Y1CrEeNPQn6EFKDvARkwO4eARCz02Ey8XMQ+6CM8RJpyoC Tvt3Raq24s1Bhz3a8jIs9GF4ltKkzdd+KmvwiqAf8uh7BkF63VhtDYP4PqCNK3UvmAvz wyrok0GDb7KG+1Y7FBSB1fZ4qWG0w2t7bn5kudijrXkryG3HtcvkaCGfYqPVZW+53LTi nW2y1LcGI9uIM2dgHF3AeNVscOf0M4q2UzNngMibfyMGqNUwWlVPi6e6DktJACQ3WBD4 9MDg== X-Forwarded-Encrypted: i=1; AHgh+RrjDKz4HLsTNIqsKS+uY+feAzeSJ1nsaNSkza6y0Xj9XbYa3evDtKJP2NC1rJd+EHYGuQSc93bPJNROf8o=@vger.kernel.org X-Gm-Message-State: AFuF++lbGY3oj7fj/LDtaB+HPno0aRh3Ai7q+9VV8rOVAc9lLCN+aQmu hFTw8HIH6TjngSQviAFY4zBdM7u+PVi4X0tL+x6N9g7r9+59fFmw2ZBoUAo4sFWSew== X-Gm-Gg: AR+sD13MR5fGmDZvfEf0fdgmSqTRbJRAqTbatSsfLnUBOd0t7kVeRyjKBVGyPpQ4G9K mD5mYJY3mZzXIErdVvSR6042wsvhBHtfFZKtNEVmLm7x7X7hGb18rXMtkdv8WXlDh8WyM/6eRm0 yM7fuKblUeK6T2no5X7BvzjibyemKExDQzSq0AUj7vEY2xMVgVN0mG7k6Kg+d5md3nRwQJ15lXs Kk53hEEjKYoFytpJ0KKWqvwKG1R1x+2CDoLbqIQSzgtFwHIM1tdbNRGhllm7pMrExWyT1DaNDzw gVsw6DjbTj5sLbxGHWTnwvADt323lfB42wLJfA53D8/4bO9nmASMjhOYlCHXLW0QvXC2dtDyW5v eSZ4Q5PwG5Pg3pv5xNRKsxs9UO22LcOFKCVsmKo3fNqc0sLx+V0tHA5Fbu93ZWc7NpyMts3O6Of kvWWu9hp2ItSiYzNVBNkGF/EJhLmb+RlubXrXSACJWzD9lSnJRz2fMz4VKFnDt/PobGjD82aosl t9UOT4VHNR8Us+fnx21gQ3E4cC86qWajKksqu7n4pCdMqhvgbEay5UdpQ== X-Received: by 2002:a17:90b:2e4b:b0:38e:7168:281 with SMTP id 98e67ed59e1d1-396464a18c5mr7911836a91.10.1787632425871; Mon, 24 Aug 2026 21:33:45 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:a442:9780:24da:cb4e]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-396458212absm2187823a91.0.2026.08.24.21.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 21:33:45 -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 v5 4/7] i2c: of-prober: skip post-power-on delay if powered on sufficiently long Date: Tue, 25 Aug 2026 12:16:22 +0800 Message-ID: <20260825041628.988369-5-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.860.g4b6b3295ed-goog In-Reply-To: <20260825041628.988369-1-wenst@chromium.org> References: <20260825041628.988369-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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-pro= ber.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 =20 /* * Some devices, such as Google Hana Chromebooks, are produced by multiple @@ -226,13 +227,11 @@ static int i2c_of_probe_simple_enable_regulator(struc= t device *dev, struct i2c_o =20 dev_dbg(dev, "Enabling regulator supply \"%s\"\n", ctx->opts->supply_name= ); =20 - ret =3D regulator_enable(ctx->supply); + ret =3D regulator_enable_and_wait(ctx->supply, + ctx->opts->post_power_on_delay_ms * USEC_PER_MSEC); if (ret) return ret; =20 - if (ctx->opts->post_power_on_delay_ms) - msleep(ctx->opts->post_power_on_delay_ms); - return 0; } =20 --=20 2.55.0.860.g4b6b3295ed-goog From nobody Mon Sep 28 07:18:12 2026 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 6BEBA3A7F70 for ; Tue, 25 Aug 2026 04:33:50 +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=1787632432; cv=none; b=jV8Brb/kUHpenLqJxT8W7wkAVaYFw9drYrN6E8SjKejtkLDNmV4ZjYLh57DhGxmg8fyOf2l93lJ+Fd5JjWq6MFk9GFRu4w90AlM0l2mjPoBMYslIEx8zW8cykb5ycfbm5Toypih7IfEz4DSJscl0Xa1QIu1lRVjFWty1JjlSpPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632432; c=relaxed/simple; bh=hcSfq4drLww4pOwuoR8efBtvnetanTEdlwrBXzAG9GY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RONjCD78ub6IZel+0gKreicZaL/gKzF6X0uQf+lePyf6HVMJrA/dwCAMIv4Ywd8egIxky20gC3oFSw3i2Y2/6uU3TBcMSuHWgo+AUBaBagw6ea1ZxnjcF73k3aIVh/6QmLDKl1rt/xYtwh1yd28KjoihSQW9pB2Du+oogzT7zKA= 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=chhT4fmk; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="chhT4fmk" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2caf228a910so33367785ad.2 for ; Mon, 24 Aug 2026 21:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1787632430; x=1788237230; 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=Oxe4lxlNlfZyQDAPdCLYOQIha/yPu61CBjEM7zjIg/A=; b=chhT4fmkfKiupvyAt+5miI+Iv7pO3DyEyfsZfP49l0BVEF2YEGiAQ5Wjjmcs7/uSNx +OCFN9wBJtGBTIt1sx8SwZYqbI5zrlC5l+zZnLS6BIq0sK6WWtbRcoZYm+SFUfip8mz5 yLD38I3l+3y6W7KSBhjb+sEsXiUFRBatqHmBo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787632430; x=1788237230; 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=Oxe4lxlNlfZyQDAPdCLYOQIha/yPu61CBjEM7zjIg/A=; b=kEzwGi8iqfyUbyIV6bV1YNdMz3eMTS4Tvj/sKNq8yjs4qT5A57g5WKheBO+2UnRsTP aiCgcH60uRAHnl2sMCSUvTzsBnitms/gAYPp4Yl7sdGwqDaI4R7lj0jqwC4CLMDJh7En DGtQcGvELvTN/fvgTiIN71TCB1lhjQsB27Lb1khT6X2xnmWhQfo1BDJ2X2J6xot+iUkl 8hZ0FkLAsAxfgSskDlzaiuAjqk8xe25/C28Q4xWOsfClNTM0QstdDJFr3JQvWr+aXJGD k9TjqK7q/GSxAoMcOv661YNyCMZZq4/WmAYJOfmmsNU6zc+ftv+NBYkWM4WUagDqDxZH fg7w== X-Forwarded-Encrypted: i=1; AHgh+RqqbufLlmB97RK3OcpJjxvEbPwoP5EJxjlspuXcjr4YIKHWV0ORmmplPn/p9rLVtK0X99T7lPR4W2pi1Rk=@vger.kernel.org X-Gm-Message-State: AFuF++lNlMqZnWl0N2DH3eBpkW3Y4FdfgBaJWf8xLWh075ClgOLf6ZKd F034pEDfkJJ6983M+04u3pgIuLXlDaRqTpG+DhuEddsKQN3oVYugwONJBZpx/q/15g== X-Gm-Gg: AR+sD11PqZpI8tyASfVdPaRYik1jsNajUD0tPY094rtMH9LzAGoS9lSHwhSrEoqNQ8o aSLMZaRurAWn5LUim9SXwQMXXqnDAKvippDBj4OFoS7puwUKd98tkSbm4l5y0BB0/I/Ay2xeAcK yC4G4S7+2EspYP7UWiekD1vrMbWN246Hl3f8idpRD/hZUViK3nhrxWyngT/YWvhG/IboCJvvrIN b+8jAxIl/VlNnvUZzxfcoDYnqXNTz6X4l7sjqyBsS9XUGdho8CjDXKgiu1aOXhMQ3P3b73Pyyl5 Me10wUQswJmYw2ZuIVSpYsoUGAmPTjYLiSGoDaANEJV4asWThhleneyMhG6XxjUdgKWk5hqJS7a q46jFBjeRWmZR8MqEtpzxBLCbpKEcK53dadhcbIYmyPLFKuOR8ga7QKs4Th9iU1RutKXnJQwEQ3 XRu6rSfJJGmDtLRHxyNW3YQOZeSSOj3F9O6maHnObftMJDOmuYqT6KwcXiXD5J9zOxf1eRHjdrt RdTzpaGHbM3KUuFD81L8U3vVgLvifwHYrowHhBy/j8M+lQ= X-Received: by 2002:a17:90b:280a:b0:38e:bfe:81e9 with SMTP id 98e67ed59e1d1-395dee56103mr48478004a91.1.1787632429764; Mon, 24 Aug 2026 21:33:49 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:a442:9780:24da:cb4e]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-396458212absm2187823a91.0.2026.08.24.21.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 21:33:49 -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 v5 5/7] i2c: of-prober: Defer regulator_disable() on successful probe in simple helper Date: Tue, 25 Aug 2026 12:16:23 +0800 Message-ID: <20260825041628.988369-6-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.860.g4b6b3295ed-goog In-Reply-To: <20260825041628.988369-1-wenst@chromium.org> References: <20260825041628.988369-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 v3: - Added commit message section showing average delay needed --- drivers/i2c/i2c-core-of-prober.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core-of-prober.c b/drivers/i2c/i2c-core-of-pro= ber.c index f9f3c0ef93ff..68c929b16b06 100644 --- a/drivers/i2c/i2c-core-of-prober.c +++ b/drivers/i2c/i2c-core-of-prober.c @@ -235,11 +235,23 @@ static int i2c_of_probe_simple_enable_regulator(struc= t device *dev, struct i2c_o return 0; } =20 -static void i2c_of_probe_simple_disable_regulator(struct device *dev, stru= ct 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; =20 + /* + * 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_nam= e); =20 regulator_disable(ctx->supply); @@ -356,7 +368,7 @@ int i2c_of_probe_simple_enable(struct device *dev, stru= ct device_node *bus_node, return 0; =20 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: @@ -401,7 +413,7 @@ void i2c_of_probe_simple_cleanup(struct device *dev, vo= id *data) i2c_of_probe_simple_disable_gpio(dev, ctx); i2c_of_probe_simple_put_gpiod(ctx); =20 - i2c_of_probe_simple_disable_regulator(dev, ctx); + i2c_of_probe_simple_disable_regulator(dev, ctx, true); i2c_of_probe_simple_put_supply(ctx); } EXPORT_SYMBOL_NS_GPL(i2c_of_probe_simple_cleanup, "I2C_OF_PROBER"); --=20 2.55.0.860.g4b6b3295ed-goog From nobody Mon Sep 28 07:18:12 2026 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (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 849663A8755 for ; Tue, 25 Aug 2026 04:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632436; cv=none; b=EdKF3/LXIuCG61YLqvIsgl6cJwPLC7hU20SsWI0wgoF37GMOxp3vlqt0MkAfDt5ErSKsHGJjUKSQBHFmdAzNHhMZ8sMD+iUcIv1Z5pZoSr3IAdvv/5/7zDj1c/+HkdRNvydNLa1DCpdSaR6WogCLBBlbzU6ZoQzzrKKlYXJctAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632436; c=relaxed/simple; bh=EE+LUrGjrLCUzObF2AhS0Yq8IeA/ddk0uB7J5ixxoHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eTfIqxmTCmcrqBCPBAP1xgEPPrzmjoQDjB7E0LUOQoQdMp6pt4orzCbAtSbfIC2PtKFNjAx9wMcAYalzvdxzMIQgP7jO4OBlzZWbOKNNYQk0MbrXHOW/cmYck7ByP46KowoReIWPxxo7Z0CltezaWoQnO6cnmpdvOYbvVXS5E58= 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=mHUi/giB; arc=none smtp.client-ip=209.85.216.46 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="mHUi/giB" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-38759bcd877so5356618a91.2 for ; Mon, 24 Aug 2026 21:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1787632434; x=1788237234; 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=swqV9OkZUZK5n8fVzKea7zlEh5+bBS1TUXycwoDYO2E=; b=mHUi/giBEqzlckpCKp2GQjNZwzhpJhQZaWQR7vio9UiMbOlHAafeAF8MjBLg5mNku/ Fwuqt7TtgK2Vzwe7GW2Tm7D5z/1wsCAdY6V4uGl2KzBgltWAXlwXkBvBfVU9X3pyY/Zs Sna9hQZM5QQ9VgnoSzNeJojT7p0cM/utOkgQY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787632434; x=1788237234; 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=swqV9OkZUZK5n8fVzKea7zlEh5+bBS1TUXycwoDYO2E=; b=X0nmkhBRjU/d6aeMkTKurGjBZAcRoi13TOyoaF3cBqYW+8GegaiYa4NxeXUja5hz7H MCCDaQ7+LgHz/Cbdmt2fYsL4/C1rTKRyfr4l1+HJQ6grSeWR37vEEbn63tou0cAZwPHr /mLaosk306UOmVR/MB21i7bVgN/xpKIw0PiWvolhmQ92t7GoKn8kNk8VMxVRFQwkSG3T 1zHE1CXr3aYxN7lmaAh4a8LuJHBcEOURjR6e93X8Umo6eDVFqJ277bkzSlhXPiiOdsXf pSGmXDqyS4yUTu28RJQDRY7tThiRvaikIOYR8E8PyUoXRitqgWeurcJc2oQcNK3dqOSv LFHQ== X-Forwarded-Encrypted: i=1; AHgh+RrdV1bBq5INcDA8FWbciCqdPEZgBGOuqi43l2ggeFtIxdsJVQzbRw/ZyKIWeJ8boieTJdcxVvWBgLSv4GA=@vger.kernel.org X-Gm-Message-State: AFuF++lj/JAVZr5Bx//LM/gO/KNGuaQJypG4H8ClSRPPbuNhdkuitPfJ SxGh6m2F+oOc1z9/u9eMSjKH1BQ+eSsAZF4H3NcDiU8XNDU+nHmNKQjfsu4ragGmfQ== X-Gm-Gg: AR+sD10jZ22zWL+vs6PlrLFjn71OAKupec9OSOWfhCw5gixn1urZxoLaP0LKprPX2Wx BX3B8umtMF9eP3AMHqOpZK1bnCTqUnxQczOeoYWDSt+P8gG/SRdTuhTImQpl7ytJJ9ugAjXPm9g 2S6Jmkr3fKQQggCmY8nZXo2DZUvkDD8uYjP++G8nC731t5MAvZoXG0TsM9CsH3FdupKk5Zlmwbf 5sKyAp4VekoaKWBdKj7OvrqA+sURR4KsuSSliH8tPeLlUnM6gJjy78Ny1NPj9XE/iRageaBAROz Nb3X546GRqI+M0oJLj2+J7zOCkf69hRtVZPw8ctEqHmEMa/OsaNS5G5POJ3KfEsF7NCYUNkQvro NXUdLUAEmhNPSDn9eHk6wdNrYoUCr7X4/pGRRtqs0gtcH8vT7ZyquYH5TVlI10la6tshpFt2wF3 ShqPjVCPeUgd6CoAlUwjuYjbBTcNoC3oQglRxR52T9JcYUYLZzsnAyE9fjfAG3/i4hK8d+92rLM QbEXhjvjIYJjWFsG3biYRomFGTv1CAxAg2YIB6g2nc7bdk= X-Received: by 2002:a17:90a:d44d:b0:38f:bbc:6a0f with SMTP id 98e67ed59e1d1-395dee7e2eamr44794746a91.1.1787632433680; Mon, 24 Aug 2026 21:33:53 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:a442:9780:24da:cb4e]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-396458212absm2187823a91.0.2026.08.24.21.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 21:33: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 v5 6/7] arm64: dts: mediatek: mt8173-elm-hana: Unmark trackpad supply as always-on Date: Tue, 25 Aug 2026 12:16:24 +0800 Message-ID: <20260825041628.988369-7-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.860.g4b6b3295ed-goog In-Reply-To: <20260825041628.988369-1-wenst@chromium.org> References: <20260825041628.988369-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Chen-Yu Tsai --- 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 =3D <&trackpad_irq>; reg =3D <0x2c>; hid-descr-addr =3D <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 =3D <100>; vdd-supply =3D <&mt6397_vgp6_reg>; wakeup-source; status =3D "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 =3D <3300000>; regulator-max-microvolt =3D <3300000>; regulator-enable-ramp-delay =3D <218>; - regulator-always-on; }; =20 mt6397_vibr_reg: ldo_vibr { --=20 2.55.0.860.g4b6b3295ed-goog From nobody Mon Sep 28 07:18:12 2026 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (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 632E93A75A3 for ; Tue, 25 Aug 2026 04:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632440; cv=none; b=J5xfC6PLAJePXSxKToHdaHDPfF/jbP6ElklWzHpf6I6Bd425Xms4aOjmUCNe+yvmEvXthSvnO9Mf4PP6Yq2DcfZaurUCAno9mUbojoGuVDKyi0nj0AJA7UTNvb6XiZC0kd9DIvXG/mgEecXbJJKCHZ+F9h3TedTooitdKzVplQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787632440; c=relaxed/simple; bh=GMLwta5oNasseK5udjS+I9A6d+Krjq5yftEXv9H/4cY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nOFb8XopO7xqLbDExF6iMUG2bhlY4JX5j8we7ntQQ7qC7fww1m9+8wypHnER7uR0gBOgxy6ywM75Wav5GILMcS2Z+PK7DQs2DEukOCZk6JdwLBCvn1fmQK4+tV98jfaB6Y4SNN6meyNgdaQiDAFrBDvP2Ob/180L1JI0bT0wS9A= 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=e5kYiAs9; arc=none smtp.client-ip=209.85.215.170 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="e5kYiAs9" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-cc11a905ba5so3110680a12.2 for ; Mon, 24 Aug 2026 21:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1787632438; x=1788237238; 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=2tEwhTxKNyJs3pF0LaNEucWWGIQ4rU4SyQWya7wYtjg=; b=e5kYiAs9AUEqkLYVl5q/MccLd0weqROGKSD27dA9zlsQVc5Y3WxaKxEEj6no8L5bUO PHJFA0L+IA2eb5kDD34qacx5HH3zsNvbf/XKqZCQDJkuObLi0bGC0I2hsejE7JkO3cuz dFeBjbaAopcVrjwBuaHwlCMt8jE7wFKltOnpk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787632438; x=1788237238; 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=2tEwhTxKNyJs3pF0LaNEucWWGIQ4rU4SyQWya7wYtjg=; b=ASIKwVF2PdI5vdTliqB4Fhw6J8yE11OtfbSBotVFLvuQ+03u1QMLBPJKdHRshEx6Xg RHgtxzNHJ03RnKx+HHmfSxzgfj2GQ4MqYS+46w3qaGOI94LKFf2S8iRdnmY0TfjzSg5W sbbhGOJPEGKEkKfbztWw8tkT+TxY4anR8vrtQ7vQb7ewJPwF+hJtH2Tt2+6qsUbWSt7A 506XshPilC/UqGtOU9z0GeF7ldxr4Bbi3ba9iTW0zWg5bto8Ivky5+zFAYpRz0hLjX4s qQcmlXLFIOqyBzCh6t4PUTwbhJklPIXH0x4PGw1YNOMi2F8TFO5mWI68MIHfADin5MvU Ueug== X-Forwarded-Encrypted: i=1; AHgh+RqVmd4odmPujE/x5jKYfMgldweS9L1G5wMeCQHiJDh9634W6CXLc57nnMzGQwmEQnQo8zYrY+mCGxuC4QI=@vger.kernel.org X-Gm-Message-State: AFuF++nyunPJpADA1sR/78Q+8sttuhNIaqz67Xm46KlHjMIsTnk9BYJY lUe0IuTuVQNBAvKGhT46PMd8kZ5hpPcpBdzrYe+/Wj2UalRqo8c9oPv+EpFMQH3O/g== X-Gm-Gg: AR+sD12DN3KRVA3YZvptJlsHbri+zga6SJ61CTQoyThIJ+k/vS1HVU+XQvEnM3f7ibW cOXNKz7tbN4BdVS0SuPDZw18Vz2lI8viMModx9xoLyWZjv5eev6p3MCyr1xWOMXrJDkPLJXdyAc 7bfYK4zviJhtnGF7icNa5mL6OHb+nevW3A1obr97mo92k3dRqV0vlW8uvx28We1x91a0KuCL8ui NcYgwGai9T5CQb0MCeRmGzwRkx0rP6uLxc37HQfBN+RGUifrwYUitfhRJFq8rOOC+OrCE7B9qWe Ul/6mmHyHSHRyrat8xgm63sp4wDIbvvQx7QG9tK4LOm/bka/uBOqDvwahrD4+8odZYLtEfJn3e0 pPHtMZgEFGu9QGY/2DiRUIKO5Nayo1Y2yHFRn1bmBwk3NXiKUstKkvVFEQdjx4wZMWersRt8dJ8 DOtuYwYz79NhM3k1kd86DHrth8ak9O2MA6DvLCTOcoasu3wUJlpDAFusuNNnVmuWZuXq0udixRu BUnzCvaa5ZY/UAhf8uD4cM/uLDh+KVkaTbh913XT9zHdgI= X-Received: by 2002:a17:90b:17c4:b0:392:6638:2e6a with SMTP id 98e67ed59e1d1-39646519363mr6944892a91.13.1787632437771; Mon, 24 Aug 2026 21:33:57 -0700 (PDT) Received: from wenst-7875.tpe.corp.google.com ([2a00:79e0:201d:8:a442:9780:24da:cb4e]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-396458212absm2187823a91.0.2026.08.24.21.33.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 21:33:57 -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 v5 7/7] arm64: dts: mediatek: mt8192-asurada-spherion: Add Synaptics trackpad's supply Date: Tue, 25 Aug 2026 12:16:25 +0800 Message-ID: <20260825041628.988369-8-wenst@chromium.org> X-Mailer: git-send-email 2.55.0.860.g4b6b3295ed-goog In-Reply-To: <20260825041628.988369-1-wenst@chromium.org> References: <20260825041628.988369-1-wenst@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 p= robe time Fixes: 925ebc0cd55c ("arm64: dts: mt8192-asurada-spherion: Add Synaptics tr= ackpad 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 =3D <0x20>; interrupts-extended =3D <&pio 15 IRQ_TYPE_LEVEL_LOW>; wakeup-source; + vdd-supply =3D <&pp3300_u>; + post-power-on-delay-ms =3D <100>; status =3D "fail-needs-probe"; }; }; --=20 2.55.0.860.g4b6b3295ed-goog