From patchwork Sun Sep 17 15:26:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141198 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2296279vqi; Sun, 17 Sep 2023 13:55:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzRbQNxjuJiXFr7fdyHsIy28sybgbWHOZXHv9I6eELEPHTdhDF0RWfrhmZWxG2etKYs3U4 X-Received: by 2002:a17:90a:ba88:b0:276:7683:70f6 with SMTP id t8-20020a17090aba8800b00276768370f6mr22270pjr.33.1694984125354; Sun, 17 Sep 2023 13:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694984125; cv=none; d=google.com; s=arc-20160816; b=elgHBNCT8QOEAjL3kabxODPQiMpaz7gDqZwvM7ia61luvZmlrNvJHyFFavaesBsmyM cZ7mVLXiecyzDITlGxMWdeNaATzrtK0Kpvo92/F3roJVdwZ+5Jw3T5aLUemAjV+eW7SO LAt0ekFXlNvnWv9l0eD4ng9rutYN889z944B4/uVV1DFAIrBc5l8hT0vrKbKBxvO7Lio BuVNzT983zHfSdIIUYNJb1nO3O1fP38TFERMp5zLyUtYBtT3AwjyUX2WdXyMDGANWBzo w7uAi8YDa0FOo/jtaj2QlhE7IRpClg909nFXsPsPNoLUvxjBuqRTnCHsJTqkIdyOEkZE y0gA== 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=6/OQx1tSDBSLV+D4ziu7/m5M5iv3V8DehxeIrYNTs6k=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=NrAjBURyQ4SRgSVXNlbe+5Oqcb66+1uVh1El8rNH+Yuw4OyJG7MNDPSZVgQIvITAcR f+AG/VD8z2X8JRA5cV8WejPpAivvqniWqSl9C+a45tgALF6xbd9+9wS4P2FtFQVA2R25 p1DCbPkmmxz35KSbrtkCJwoBqkXyabBT+0URcq5iavd1IOjvcT+9bnla9BLRAnrnOkv9 OML8IjMkDf3uNLy/Hoq31MjDzWVGNmQ8OjLmNisVDBWAzvbJ1QwB5LaqcWHVJNu/Arha ojWlZfFB/JNSUjAn9xzse1xAACdAY6K+7tcpcicEsPMJEvYBjvgH70TyJYlRdogYk5u7 1KLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Ytc/HWWA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id in19-20020a17090b439300b002613720fcd5si4512376pjb.35.2023.09.17.13.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 13:55:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Ytc/HWWA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 27D0F80834BB; Sun, 17 Sep 2023 08:30:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236759AbjIQP2I (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234619AbjIQP1i (ORCPT ); Sun, 17 Sep 2023 11:27:38 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FF4811F; Sun, 17 Sep 2023 08:27:33 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40472f9db24so36127975e9.2; Sun, 17 Sep 2023 08:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964452; x=1695569252; 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=6/OQx1tSDBSLV+D4ziu7/m5M5iv3V8DehxeIrYNTs6k=; b=Ytc/HWWA3p5zxh6JakRudNaXgI+twkdnmUQq47NuopbX7bnclWdSso0UfyJhVlXs2p Edq+vcUSI9YguteMiK93br2XtFrNP+LPZaa5SJhDFFuNzav77ZTN+TK67qKTPF6j/BjE dUzj8uN+kf4vd5ByP0W0Ji/7/ugm4IdXWL2YcqOF2xK6UK16Ll9IQL7U8IrvcLvj9vAY 2n06uXoXLr5GDETTWdXZaJH9GaRcyF4eQjCtP+UcJrsXnoIhORfMg2lVUUrpBsN2rmnM TUoZFsoGrgyIpMNUCgEozlPT2BeRJD0V0vFhOUHsbdR5Nnvy53+jpyw2fuJ/P0XPSa92 hCcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964452; x=1695569252; 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=6/OQx1tSDBSLV+D4ziu7/m5M5iv3V8DehxeIrYNTs6k=; b=SNEVZSYKMjyz01UmGZGoe9CBdDBt7R8jQc5TBam9vOoXdrH2ll3vx3dkHi/W1CbzQf 71PdwL+9SGifPdsFI07L0fAVPKO9Zv3I25sxaCuOVHjdY4hSo6UqTJ1tUzA61rEw0fJi 9X/X85RiVYO1s+ayRRl0W2ZDEQYSm2e0EMijtoei/sH5//QFMlZLk/oiciXSZh6AOi7D vfMTu/YP7wKiy0s89QzG0wkCzqcUBhzvqsZ7NFahBR8xzpjTL2BEQKiWwvo+vLToGcF/ JTdZcoGjCRPd0UsOTEiSy9a1OXTy0KPY2fUPAUF0SRd43hpS+dWtpdAw9DwhBKtvQwJz bDCA== X-Gm-Message-State: AOJu0Yy4m6dVF6M7ld1RaNUhtQWj/aW/K87wdTuK8ovyFFUtiH7eHfr7 3Ijfa/8CQt+FqBLL+jXkidQ= X-Received: by 2002:a7b:c44b:0:b0:401:b2c7:349d with SMTP id l11-20020a7bc44b000000b00401b2c7349dmr6696119wmi.29.1694964451804; Sun, 17 Sep 2023 08:27:31 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:31 -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 06/15] USB: typec: Clear dead battery flag Date: Sun, 17 Sep 2023 11:26:30 -0400 Message-Id: <20230917152639.21443-7-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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:30:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777319674083653680 X-GMAIL-MSGID: 1777319674083653680 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 --- 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 b3d4b2b5bf5f..3ad8112c78b6 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -933,6 +933,22 @@ static int tps25750_apply_patch(struct tps6598x *tps) } while (mode != 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, 1000, 0); + 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 5e942c089c27..362e1eca53ad 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 TPS25750_BOOT_STATUS_I2C_EEPROM_PRESENT BIT(3) #endif /* __TPS6598X_H__ */