From patchwork Sun Sep 17 15:26:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2249735vqi; Sun, 17 Sep 2023 11:20:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENDLBe+7BXhAV/hLrswO1N5PULlXSg/s4GP8rOpv28U2K8ULYRBXkx93ogB1QVFkcpX3IE X-Received: by 2002:a05:6a00:804:b0:68e:4303:edb8 with SMTP id m4-20020a056a00080400b0068e4303edb8mr9341525pfk.30.1694974839958; Sun, 17 Sep 2023 11:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694974839; cv=none; d=google.com; s=arc-20160816; b=X87yEFfC4vMfZVq5Mv9WHrq93iw9ty3WjsQ1sJjE+kuWB00yRFpCBYbO/W+3J5Q6LH aCiW5O4FZH5aYFApOGFeujtWv8brM19QvdZpT2mVsFaoaqGq7kL1PEWNeVvV9UmxaPFg fl3r0xXjrgQv5x7L0mkm14BEZ4MNoYYjA32ZvV407BtOjNR9dGzQLZduuriuCQz/qmQL O/jyUldgj1ekAQM0KMv98JG0qFlIcsxh0XpwZa693fp1xbJn8wl5+me6eiwtnfBYMvXF uFrL/NbLNnjqmy4X2u67TrYam74yBD+/jY0kX7TuHvv75T4w9fqAD5d7jzvCWiTeEFmt DS8A== 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=0n50wlN15P0stenDju6p9cw+JcF6FZEojTnqcJ2Z8gE=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=RCjtPz2PcawmV0TMnWXdLMRg3mGBsYSRBtlxDBuZs5Ovph2rhdj0yBylRHgPTNblf0 C4R8pxcndheR+nm2dw2oXPZKAkliVnzz0jCu7DSp2opRFDpAL5XjZnJ9oNP+SFn2JKvQ 1TwXLoeY0SRounDisjgdCQBSjiUtslHV3yes7WPC9R0OJf0C/wipasI6sOaAsUxjA8Vp IX+Atu6kQ56FZ0zS50dWRWSYby5BoMQ6KlWVOY1s3PCCDK45lz1pIg9pJ/ULMHVPKkZB QYiwNn9kf7J6RveLyxrP6qFwoAtOizVVBZLi7nfPu/ojCpMSfVzzSkEDnuWeIvyrIRAx rPPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=W8KEsmdh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ct25-20020a056a000f9900b0065b4e2b52c5si6540917pfb.196.2023.09.17.11.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 11:20:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=W8KEsmdh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 095BE82296A8; Sun, 17 Sep 2023 08:32:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237336AbjIQP2S (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbjIQP1x (ORCPT ); Sun, 17 Sep 2023 11:27:53 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C04D18B; Sun, 17 Sep 2023 08:27:46 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-400a087b0bfso39937065e9.2; Sun, 17 Sep 2023 08:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964465; x=1695569265; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0n50wlN15P0stenDju6p9cw+JcF6FZEojTnqcJ2Z8gE=; b=W8KEsmdhEB40oiznYrEJUK9vC6qo3/+yRo1nGuhgYhqifIw2euID4lAVgDue1/SeWw MWCUcwGJ/7LFoKrLdFF7+YigHj6rT/l1QUorc7z3wevj4/RxzhIhzWdlT/j1myANbPDb aahTNietBw2Jr/l7aJm3aWwKylEX3IcS9O6CAprGCtBZjdVbjAs4RJF9EAaE8J8QHHOU 0+T9f1nTjvMMV+WdzHbJXPaeCerei79x6OcIQSqUU3XM/c7T+zWvAtzjFp0YwQarNMpI CNBKKq4/tzCpCoUOay9/uTHudJ+aM1IBQbwY1cyOiiIiRLcnw88KAmEAG2VWIvMIMoAy /CIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964465; x=1695569265; 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=0n50wlN15P0stenDju6p9cw+JcF6FZEojTnqcJ2Z8gE=; b=OCK83qDAYVFnbl3jEl7TbsxLaOa35f4PCmpQ2ZI7AfwsKM+ejvnuDVUGir24ouXek7 Ix6gLzyjAwxm/WGbJZX+4H/jdtyTcTfg/TQ26dg7+9DNjDD2TpG+ObcQt5O9uBrwdqby 1FIk5aCtvtd7L1PwJcF3E1VCAhAUUzPVUK5pPRwrMI9biEdHdyYQG5Yag1JSoY3BkWsT H0GbCC43w54mRMK9hNpa4rDovrRxXhyv7Fvujzyb9V73Xf+W1ylqZ3LndVmjZiDbELu+ gP/C7Ejnk9KUYyuIGBoYMiSUvIOaf6C6Cd+qeEVeqE9MdYV0mYv6mRs9J2WEIBpv3gJI vslA== X-Gm-Message-State: AOJu0YxqT4OmVQmKPsjgXOLVU6j1ilrVf7WcHiHpH6Qej69193KvReTd 2hqPcFOt6QQnBKnBmaZFY9U= X-Received: by 2002:a05:600c:2194:b0:3fe:ef11:d79f with SMTP id e20-20020a05600c219400b003feef11d79fmr6173540wme.36.1694964464977; Sun, 17 Sep 2023 08:27:44 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:44 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: [PATCH v5 11/15] USB: typec: Enable sleep mode for tps25750 Date: Sun, 17 Sep 2023 11:26:35 -0400 Message-Id: <20230917152639.21443-12-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:32:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777309937948311897 X-GMAIL-MSGID: 1777309937948311897 From: Abdel Alkuor Allow controller to enter sleep mode after the device is idle for sleep time. Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 29 ++++++++++++++++++++++++++++- drivers/usb/typec/tipd/tps6598x.h | 3 +++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index a97fda68cb54..3d9877551160 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -42,6 +42,7 @@ #define TPS_REG_PD_STATUS 0x40 #define TPS_REG_RX_IDENTITY_SOP 0x48 #define TPS_REG_DATA_STATUS 0x5f +#define TPS_REG_SLEEP_CONF 0x70 /* TPS_REG_SYSTEM_CONF bits */ #define TPS_SYSCONF_PORTINFO(c) ((c) & 7) @@ -205,6 +206,11 @@ static inline int tps6598x_read64(struct tps6598x *tps, u8 reg, u64 *val) return tps6598x_block_read(tps, reg, val, sizeof(u64)); } +static inline int tps6598x_write8(struct tps6598x *tps, u8 reg, u8 val) +{ + return tps6598x_block_write(tps, reg, &val, sizeof(u8)); +} + static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val) { return tps6598x_block_write(tps, reg, &val, sizeof(u64)); @@ -977,6 +983,24 @@ static int tps25750_apply_patch(struct tps6598x *tps) return 0; }; +static int tps25750_init(struct tps6598x *tps) +{ + int ret; + + ret = tps25750_apply_patch(tps); + if (ret) + return ret; + + ret = tps6598x_write8(tps, TPS_REG_SLEEP_CONF, + TPS_SLEEP_CONF_SLEEP_MODE_ALLOWED); + if (ret) + dev_warn(tps->dev, + "%s: failed to enable sleep mode: %d\n", + __func__, ret); + + return 0; +} + static int tps6598x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) { @@ -1131,6 +1155,7 @@ static int tps6598x_probe(struct i2c_client *client) irq_handler = cd321x_interrupt; } else { tps->is_tps25750 = of_device_is_compatible(np, "ti,tps25750"); + /* Enable power status, data status and plug event interrupts */ mask1 = TPS_REG_INT_POWER_STATUS_UPDATE | TPS_REG_INT_DATA_STATUS_UPDATE | @@ -1138,6 +1163,7 @@ static int tps6598x_probe(struct i2c_client *client) } tps->irq_handler = irq_handler; + /* Make sure the controller has application firmware running */ ret = tps6598x_check_mode(tps, &mode); if (ret) @@ -1149,6 +1175,7 @@ static int tps6598x_probe(struct i2c_client *client) return ret; } + ret = tps6598x_write64(tps, TPS_REG_INT_MASK1, mask1); if (ret) goto err_reset_controller; @@ -1286,7 +1313,7 @@ static int __maybe_unused tps6598x_resume(struct device *dev) return ret; if (mode == TPS_MODE_PTCH) { - ret = tps25750_apply_patch(tps); + ret = tps25750_init(tps); if (ret) return ret; } diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index d2c65387994f..0344b65cd55a 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -213,4 +213,7 @@ #define TPS_PD_STATUS_PORT_TYPE_SOURCE 2 #define TPS_PD_STATUS_PORT_TYPE_SOURCE_SINK 3 +/* SLEEP CONF REG */ +#define TPS_SLEEP_CONF_SLEEP_MODE_ALLOWED BIT(0) + #endif /* __TPS6598X_H__ */