From patchwork Sun Oct 1 08:11:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 147127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp941127vqb; Sun, 1 Oct 2023 09:00:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFKiSAN4uNymqcEBVauB6lP5mcGxRxd6U6SWTrpcvdWMbZEQS2JIqOL6zQPp2Mq07Fdpnh X-Received: by 2002:a17:902:ea8b:b0:1c2:82e:32de with SMTP id x11-20020a170902ea8b00b001c2082e32demr9526255plb.0.1696176040431; Sun, 01 Oct 2023 09:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696176040; cv=none; d=google.com; s=arc-20160816; b=VEGEMZ4bIPTLWQjQRqE2w/vXcLjSdxIAKkmlfGJH3jCkTxco2kh0QDCZnpJjnJmPv6 uSWOOD8udbnR8NEi28Mgh/UGbLrpXqpxfd99fbSohDLRl/1ANdZqn92cQgm5DrY9sRnD QTL6jIPYV+Tbpot4DFcV22CJpUted3l35myHznTmJlGJ1YWRnzioWFD9G7djLFkVEG/3 u6bUYn/wibzUskbBiz6MJ+svFXd/lQrupcE5tqbmqeNo58jjGe0Q66sG99In4Ys3OSB0 e6O8D0XLXWi1CQBSWY3yA/GOdvVyOkeCl246R/z14y4coJzCWMJBdJoQOezneQzc2bCf pPAQ== 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=6ObRy5c8YFdrnW2Ux3zmbr7cSFwdsAqt7EeK0em6AeQ=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=b33UDPsjyV9iPgetpbOZg+hts6PI5zjU3eZXmWOPzlQIJaZiPbeH6272b5ibfywEZo 96kT5RCeapOFAvuomCbhzhN2COuagmLiKP0qQ22JxUwO7lLfRez3Sd2PAuZpWlAO3TQc l6DIF4I4uHZOozXoULEflw0n/SN2+YSoMKiy5c4LKvdzl4UTfoRsAz3vpfBBEOQaMo4x SQEvoT6e6rQfrb1eqGnDzdY1UJESe7zLxJqXA2fzd6ZsTr67SA8rEqzSq9dXQZmvWdAa hhN/uk538GkeXwOxB9DauG7QuGhWkTcCPhUxdPxK+jMChcV5MH19uK8Qlm0txkjadwAv 1JFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BFAqTOp7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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. [23.128.96.32]) by mx.google.com with ESMTPS id q8-20020a170902a3c800b001c6189eaaebsi4869468plb.186.2023.10.01.09.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 09:00:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BFAqTOp7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 12DA1809564F; Sun, 1 Oct 2023 01:16:21 -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 S234576AbjJAIPt (ORCPT + 19 others); Sun, 1 Oct 2023 04:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234533AbjJAIPc (ORCPT ); Sun, 1 Oct 2023 04:15:32 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C145CFE; Sun, 1 Oct 2023 01:15:29 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9ad8d47ef2fso2073155666b.1; Sun, 01 Oct 2023 01:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696148128; x=1696752928; 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=6ObRy5c8YFdrnW2Ux3zmbr7cSFwdsAqt7EeK0em6AeQ=; b=BFAqTOp7EC8UDxEhRwQiBk/VQy5h07n3WTHzZgbqm49BL3XcVbYsqBL5SAhskToELR Jx6YFE0IQ1uW3EwSruTS74qiPS0rcjuqYvoMHWwxIseB0DMWvGYT/BbvHpdsbVwMKarO AXIYnL8tpC04nB7Xo28ZtPutU95eKxV35gq2toMkHfUOQeaR/LqtlrlWUL5tLKNn3swy heYnA8OZL8KbNDZVSh+BEjHCMY8lpANzWAWi4hi+reOY0/zhJYMko55swTgYnz+4QNmX fdwAOO+POSMKVjwtN4WdH6t3V0Ouvz1XumWUeMh4AO4cnmEk1F5Tz4NpugbDslkuxyMe 4jKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696148128; x=1696752928; 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=6ObRy5c8YFdrnW2Ux3zmbr7cSFwdsAqt7EeK0em6AeQ=; b=DbxX+jVURZorp4+Zh1WgZDq6dxdBndOBI+BE1pyysbiL9yWO9la+fQFdDz/15f7SjA 9YjtPdn2iCVS6Su3YfC0k0DwVTrDc/u9twyixnSb09/xkxS2R4j1In2RxnOYgNt3xiw1 WOxPex6NuexHcj4CyC430aXAg1kfTDoM5QT7BxEwTpttqsz39XtKmq9F0DPDGHpnuOMe Fx20chhTYzCAPffeRV6Gp3f7pQQ6koMPKMZUXWzzRF+9s/fhc2LE9fynmXGDcQ9ISvLv H7uwKhRtZwKPonK7f8+5OwCRefGJyVyqqXVdL5NkhfKnMnWRIxnwvUU+/O6PDax+gnBA +FKw== X-Gm-Message-State: AOJu0YzbNI74xidBIfWQGNKLNDPkiDq4ykm1lKD+mCzEk/ICss5g5YFn qpUUmjXwTYD9fXriRec4tKc= X-Received: by 2002:a17:906:209e:b0:9a2:120a:5779 with SMTP id 30-20020a170906209e00b009a2120a5779mr8944577ejq.60.1696148128017; Sun, 01 Oct 2023 01:15:28 -0700 (PDT) Received: from primary.. ([213.139.52.198]) by smtp.gmail.com with ESMTPSA id e8-20020a170906374800b0099cf840527csm15121841ejc.153.2023.10.01.01.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:15:27 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: [PATCH v9 06/14] USB: typec: tps6598x: Clear dead battery flag Date: Sun, 1 Oct 2023 04:11:26 -0400 Message-Id: <20231001081134.37101-7-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231001081134.37101-1-alkuor@gmail.com> References: <20231001081134.37101-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, 01 Oct 2023 01:16:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778569487470025574 X-GMAIL-MSGID: 1778569487470025574 From: Abdel Alkuor Dead battery flag must be cleared after switching tps25750 to APP mode so the PD controller becomes fully functional. Signed-off-by: Abdel Alkuor --- Changes in v9: - No changes Changes in v8: - No changes Changes in v7: - Add driver name to commit subject Changes in v6: - No changes Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 16 ++++++++++++++++ drivers/usb/typec/tipd/tps6598x.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 21b0ea2c9627..2598433a69cf 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -946,6 +946,22 @@ static int tps25750_apply_patch(struct tps6598x *tps) } while (ret != TPS_MODE_APP); + /* + * The dead battery flag may be triggered when the controller + * port is connected to a device that can source power and + * attempts to power up both the controller and the board it is on. + * To restore controller functionality, it is necessary to clear + * this flag + */ + if (status & TPS_BOOT_STATUS_DEAD_BATTERY_FLAG) { + ret = tps6598x_exec_cmd(tps, "DBfg", 0, NULL, 0, NULL); + if (ret) { + dev_err(tps->dev, + "failed to clear dead battery %d\n", ret); + return ret; + } + } + dev_info(tps->dev, "controller switched to \"APP\" mode\n"); return 0; diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index a80d0929f3ee..c000170f4547 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -200,6 +200,7 @@ #define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B (BIT(2) | BIT(1)) /* BOOT STATUS REG*/ +#define TPS_BOOT_STATUS_DEAD_BATTERY_FLAG BIT(2) #define TPS_BOOT_STATUS_I2C_EEPROM_PRESENT BIT(3) #endif /* __TPS6598X_H__ */