Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp530113rwl; Thu, 5 Jan 2023 00:25:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXv1ofbSmgZCeoLsZq6aGRy30iXxM2r3RNtAzEORc7EbD9RpPsmzXyx0SY2I/qfqurt7POK5 X-Received: by 2002:a05:6a20:a687:b0:af:7cf6:1d4b with SMTP id ba7-20020a056a20a68700b000af7cf61d4bmr65307411pzb.23.1672907136637; Thu, 05 Jan 2023 00:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672907136; cv=none; d=google.com; s=arc-20160816; b=BTOhQ+VuT1m2EIQdt2/2oo8y1smpgkXdKTybxCNvNUMWhzOvyiGmIn0g8ZU/pFphCc qqRsiDqw3DSUZ1uBk/fVgqBYykVB17Ckviti6wmpvk3vJlDrtVKG/+tFwRp2i8rrDYGm wLNQLu5Df2mJ981YIjXD6Uz15VclZQ3uPuQAhzpSezo8YE+JkJu/qOpe+6Z6B/nm2qA3 gbO9wm+VoqhE4G/E5LVGwf5V8xTS9CssyN06wyq3x0pwfeMqPIOX8JntG1LBEq0V806W +oVaTNeUxkoMDmBIVy+k+T7QbFGlzFGhPK2u0FryjyKpluvwLy2VQbKrVd6iJt5FHEM+ W+9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6ohiE9fg/YmJyloLDZ4x/cahWGOvJ6DD66/fJFJqCKg=; b=bopiiu68p9Zfo1GH2qJEku304hBxyMn723b6wLNY88f3AoIh8Atxm/7V29jquxS2W1 SYwXYV70u+N2DT6v82hDVgamwmCkaGd/l6iIeUUxW8fFMYxVrE6/2jOyCki5VaRbQiVG 2vYjBS7pzS5yvI+yRRkhV3EYsWiNYT31umDcMF94ccYblG30BGABYhHZ72DzC9KxuZWU MNSZqtDsmgSy3cLn9mJCeRQUqz+H4eIRYGCEIUqLmL/iDPpQvdJhjG/PRWqpvFjUzLD+ 84BeAGNaQ9BLFGfzCu9oHUJnNz5tZUfcdC8l3hWap/BkX/zeGP0dMJlnlTHx8gyPLowK 0zzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CAb0Q6uG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a63fc08000000b0047895910bd0si35046714pgi.825.2023.01.05.00.25.29; Thu, 05 Jan 2023 00:25:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CAb0Q6uG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231234AbjAEHvR (ORCPT + 55 others); Thu, 5 Jan 2023 02:51:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjAEHvP (ORCPT ); Thu, 5 Jan 2023 02:51:15 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7C0A3E0F7 for ; Wed, 4 Jan 2023 23:51:13 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id 18so12561106pfx.7 for ; Wed, 04 Jan 2023 23:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6ohiE9fg/YmJyloLDZ4x/cahWGOvJ6DD66/fJFJqCKg=; b=CAb0Q6uGKu6IOMmryDbj7OUjJ6wQNikYrhBGFjKs+IdgdnsCQgB1jYji6e4FvB2hib BNqYy378sq00EZVxgL5CRhCv4olroZFbklBCnhvjg0bCNgYJ4bBHBigroP2m1/F1/c49 xtAC26swM8uc6DYHspV7zK9xDZwF3vv6Ax3NIZkarnrXOzRop2i4bTqgVnzJMCYEqLcW rvPhQRSUZBwwNQHOj1NpXukENXI/V3RBexDf8UQyu8n/F0lhdD1PBoxWeT12S3y+cb8g lHV088pT4w5X6oltYqZ6l6SzXN1F24a6tFNZ5xlUv13YAunfvQPalSSEVgPLWWYk/LlJ d24g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6ohiE9fg/YmJyloLDZ4x/cahWGOvJ6DD66/fJFJqCKg=; b=OwE5pjMrQq/Kiv72odE3JRL43xBu68mxNmT6TAf4SH3Dml45E/VnPP6LBPlESq0KQ8 hyGlzzvUGTFKFQYuE8AigOi2YaH3C0Dv2/GQgorNjKScjIVfNT1XFI9f7aP1Z0OBpFsP 3jdMpZg/rGZxjo39NjgU8xA2ZkbpCUywDhLqwwGiT2DiipKNwYhl3QYfvrBTAd/mpmUS QNQXN6AU0vKwvps21PJ4rtMFKXAEJWB/gG2F5SgMKhNNvQYgQvEb08lP5NygX3Yxm43b 62IisUnXE4grHr87j3HuO+hQBLkSZdT2uldOqMrEdPR70K//hUWvrMWPg/y+6bj/YwIb tWnQ== X-Gm-Message-State: AFqh2krK//T70KgqInsl2E+hS2WjDWID3OTPh3y3wZUqZZcirI/PtxU9 TNm0Q+In6K13Eim1/ETEy+w93A== X-Received: by 2002:a62:e911:0:b0:581:579d:5c44 with SMTP id j17-20020a62e911000000b00581579d5c44mr31980759pfh.5.1672905073357; Wed, 04 Jan 2023 23:51:13 -0800 (PST) Received: from niej-dt-7B47.. (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id g130-20020a625288000000b0056c2e497b02sm24513555pfb.173.2023.01.04.23.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 23:51:12 -0800 (PST) From: Jun Nie To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, devicetree@vger.kernel.org Cc: sven@svenpeter.dev, shawn.guo@linaro.org, bryan.odonoghue@linaro.org, Jun Nie Subject: [PATCH 2/2] usb: typec: tipd: Support wakeup Date: Thu, 5 Jan 2023 15:50:58 +0800 Message-Id: <20230105075058.924680-2-jun.nie@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230105075058.924680-1-jun.nie@linaro.org> References: <20230105075058.924680-1-jun.nie@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable wakeup when pluging or unpluging USB cable. It is up to other components to hold system in active mode, such as display, so that user can receive the notification. Signed-off-by: Jun Nie --- drivers/usb/typec/tipd/core.c | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 46a4d8b128f0..485b90c13078 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -95,6 +95,7 @@ struct tps6598x { struct power_supply_desc psy_desc; enum power_supply_usb_type usb_type; + int wakeup; u16 pwr_status; }; @@ -846,6 +847,12 @@ static int tps6598x_probe(struct i2c_client *client) i2c_set_clientdata(client, tps); fwnode_handle_put(fwnode); + tps->wakeup = device_property_read_bool(tps->dev, "wakeup-source"); + if (tps->wakeup) { + device_init_wakeup(&client->dev, true); + enable_irq_wake(client->irq); + } + return 0; err_disconnect: @@ -870,6 +877,36 @@ static void tps6598x_remove(struct i2c_client *client) usb_role_switch_put(tps->role_sw); } +static int __maybe_unused tps6598x_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct tps6598x *tps = i2c_get_clientdata(client); + + if (tps->wakeup) { + disable_irq(client->irq); + enable_irq_wake(client->irq); + } + + return 0; +} + +static int __maybe_unused tps6598x_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct tps6598x *tps = i2c_get_clientdata(client); + + if (tps->wakeup) { + disable_irq_wake(client->irq); + enable_irq(client->irq); + } + + return 0; +} + +static const struct dev_pm_ops tps6598x_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(tps6598x_suspend, tps6598x_resume) +}; + static const struct of_device_id tps6598x_of_match[] = { { .compatible = "ti,tps6598x", }, { .compatible = "apple,cd321x", }, @@ -886,6 +923,7 @@ MODULE_DEVICE_TABLE(i2c, tps6598x_id); static struct i2c_driver tps6598x_i2c_driver = { .driver = { .name = "tps6598x", + .pm = &tps6598x_pm_ops, .of_match_table = tps6598x_of_match, }, .probe_new = tps6598x_probe, -- 2.34.1