From patchwork Thu Jan 5 07:50:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 39359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp176606wrt; Wed, 4 Jan 2023 23:52:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXvsYttUkcr339E6z+KazhOJ32FKPqO9x11Ehi/kBLEjW4vFtTf2K2h7natVTa9qG1lLlKgw X-Received: by 2002:a17:90a:8c11:b0:219:8219:9179 with SMTP id a17-20020a17090a8c1100b0021982199179mr29113316pjo.8.1672905124447; Wed, 04 Jan 2023 23:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672905124; cv=none; d=google.com; s=arc-20160816; b=Z6cdBqn52LnwCafEhVqnq6NY5C0ic3p+HmFYxpFFonu89+hXgnzbhWxhDh8rIZRIGW NDjMrJNTxEgkSUoQQENUFN6jNcRqpLWi4JyE6KqKkdq6v/nyYT0KW1ZimrpxrERWDSRw unm6rRtbjyJfbWqS1cbFbciFBfwItgzke7PiaAye/5qV4hQ94wh5Zh7SB2DeSpNbKOwj Yo46jb+RIaodbE8mHoFXEFlB91/GyPvS2pBXbsOIj3tcanlH52g7Gwv/3gDO2oDaOJw+ dL+hpzysW+pxCRvRqfCgq7lp+apigknso6r9wq99wVeyIXfRIpgMfAzjDzvoR0NTvpqA /rJg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ACKJJiJLwOD+bKHkEbqMQJLUZaVo4k37AOJXtfHcw4s=; b=Exorh2io1xe1ovNFOJGtYW/5QbtyR8EBEjng4SBvbkXqSiYjKTqp5p03+TTBuX58Td iOIg8YR+9EhlK8FN9SLo/v/Rmky7nE0LgPC3W9ig0gdaC9G0L6TUrcRDdmPeBD4p5pl5 bkvAKlfd1HwKn8CIGCINjR/0V4YDpChaas0rZahjcE5Zu0hhqkhtwWF92vugoXTv2pRi CPqf3WnbBjoCX1HlwRjKpWjFNuhP6nGQEsR29sbrCJxDVTqyiL34lA7Um0SiWbXsiwVc mwN3/aujtdsMPEjM5uujVhRY5aRx0eeacZjJ2l+UKX8s9c3t0P9wTi7cSWJZAMSbkFHC Tyyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TjHFlXlY; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u15-20020a17090a6a8f00b0020b2101908asi1265899pjj.16.2023.01.04.23.51.41; Wed, 04 Jan 2023 23:52:04 -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=TjHFlXlY; 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 S230521AbjAEHvK (ORCPT + 99 others); Thu, 5 Jan 2023 02:51:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjAEHvH (ORCPT ); Thu, 5 Jan 2023 02:51:07 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E02E39FA7 for ; Wed, 4 Jan 2023 23:51:05 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id c2so11040378plc.5 for ; Wed, 04 Jan 2023 23:51:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ACKJJiJLwOD+bKHkEbqMQJLUZaVo4k37AOJXtfHcw4s=; b=TjHFlXlYP8a6e2cNMwXF3OtUlGDX67wYUv03D5hc3N6jjhFQx26qra2p3CoxaCo9T2 QiQgtTgyOL/e39N+D+N54ZbaYHgO5ZMLZXMvNT/O0Hvt0a4s4vQLY00/Ukc75Ny3mgDQ cKIVrQHx9eJHyW7wwg5Hy7OutS86AHKs56/UGYqvDyUVGPyRo6ZrOQ5B0aqYdvg963vL cWk4Ap3ogtD35fvR9p46D31wsz1tfyyPthfRvWyt0mGX/IeFuB4VuvRaiXruWWlHc9cv 1pZGYclb82fxEHVpBLHS8lnw+XwzTx8SCZFd+v8kKu4vd+KkWz2tUTj9izgqneegr/iu dceQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ACKJJiJLwOD+bKHkEbqMQJLUZaVo4k37AOJXtfHcw4s=; b=gDzLDDt0tmdePSW5Ga0E003gVA24gyjJw8/ktpJIMrOFhwWvhwgFAOzSmpw9XSxc+T vKpLmBLWJIVUoDA2VgJOE2Udw2JF6C8q/Kpw+Ygz6zxf6a7rvtu+q6yOfBRR/gt7Ogxx HLhNu6L9qfaf/RadOppxIbXrOQjxHLa7Wfh8GbBoStGXv5Mtbv4DSutK+wuVpEfk9Cba cJUlPMNCbaGWPAdmwjElvy3BerPwxw9JsX0wtCwKu/G9XKN7yFGqNeGm4pPzAqLniymY kejjHR1FlMPjfWoRjoKbcvVuvtWGlgzjmgO2qJ/x0dpIe11Yze00XufmLmgE/Pjc8lkp QQhA== X-Gm-Message-State: AFqh2kooD7iLSjyILJ8w+rRPWBd5uVhMDjFYKY23xAfYj6YtTs9qxHX4 BAgaNBqbnHjG1qsHIrzVTV99lQ== X-Received: by 2002:a05:6a20:6aa8:b0:b3:87f8:8387 with SMTP id bi40-20020a056a206aa800b000b387f88387mr31789839pzb.50.1672905065014; Wed, 04 Jan 2023 23:51:05 -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.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 23:51:04 -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 1/2] dt-bindings: usb: tps6598x: Add wakeup property Date: Thu, 5 Jan 2023 15:50:57 +0800 Message-Id: <20230105075058.924680-1-jun.nie@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754168163762066141?= X-GMAIL-MSGID: =?utf-8?q?1754168163762066141?= Add wakeup property description. People can enable it with adding the property. Signed-off-by: Jun Nie Reviewed-by: Bryan O'Donoghue Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/usb/ti,tps6598x.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml index fef4acdc4773..348a715d61f4 100644 --- a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml +++ b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml @@ -23,6 +23,8 @@ properties: reg: maxItems: 1 + wakeup-source: true + interrupts: maxItems: 1 @@ -48,6 +50,7 @@ examples: tps6598x: tps6598x@38 { compatible = "ti,tps6598x"; reg = <0x38>; + wakeup-source; interrupt-parent = <&msmgpio>; interrupts = <107 IRQ_TYPE_LEVEL_LOW>; From patchwork Thu Jan 5 07:50:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 39360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp176904wrt; Wed, 4 Jan 2023 23:53:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXtj36kMje2JjvnHMaki57EfQBj5mnFesabavKI4qE6PAYYKEOslqLghh0X9BduZDNhv4ILv X-Received: by 2002:a05:6a20:1586:b0:9d:efc0:67 with SMTP id h6-20020a056a20158600b0009defc00067mr77233776pzj.15.1672905182851; Wed, 04 Jan 2023 23:53:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672905182; cv=none; d=google.com; s=arc-20160816; b=C19AiMj9UEUlqFvEQNwO/dX4/gPtdHXaJz+p0w8P443e8/jwDeLUmqgmzJ6+6/Oku4 9GdSobrPLrj6DuB9Bbf4zEtf+6+1hqJrfcZyxEa7WY5YQ1t4XHKfmaLiWPP4lvs2MIBo OAc3cEDqUpqhjhb0XOjcqeTLINySX69n89NGei5JMA8SaJlG+JBcl34HvBrPRCZDeYmE tftZbNEBeoxfjGDk+FhrurXefpOqKeFmVdg7hXKY9Rxq8WTMdVUa+vZFWR/q87vPljhW SnSvsCtoKiq3R5oZ8sGtJgCkXL+LUtLAkPFdAylGZfhXs7jmsSFMlK/w3D7TbX7QSKQd KsmQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v13-20020a63464d000000b00477d8b03517si37591780pgk.524.2023.01.04.23.52.50; Wed, 04 Jan 2023 23:53:02 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754168224967502311?= X-GMAIL-MSGID: =?utf-8?q?1754168224967502311?= 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 Reviewed-by: Bryan O'Donoghue Reviewed-by: Heikki Krogerus --- 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,