Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2089445pxj; Sun, 13 Jun 2021 08:16:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydiw8AeIfDRc6rFnr8ApnFqfOG4/o+gZkUfFYn0AlxVamFeIX9k6ZBEfPZPo/x/cMgoV2t X-Received: by 2002:a17:906:128e:: with SMTP id k14mr11525099ejb.485.1623597374912; Sun, 13 Jun 2021 08:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623597374; cv=none; d=google.com; s=arc-20160816; b=ztMq9yCTvQWJyaMnGS38WY9NuoThhQpSAk88RTOWDJ+GP7fMfZOtwtH7MIHNUcDbia mRiz17DHQndAIjRB4A9LtFbpNEPwcFczQ9dbElCaBkMFM05GZvyORqjNYBTojdumT7su Lp1wWm7nmcep3tXX1W+EDl8jet0zLgkVGAqKrTQuxZ1Fm1GGyAUq8JIfNCV9ZApG9Zbf 4NUD2/ATB4c9vCWE2VbdZOb4/XkhQTSf9MZeHhZv2FfmSB6O8uvr9+iuHzLoJNasVsOR jGp9VzJEsvZkL68fHKAXwovKyl1NPlsTVQMXKbeLuGk4D8c6W5n5HZ2rULVWV3MPeWSk qeOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=TGzdE/APFAf/QMVTCv6KrvuvVJCn0wQ+q/HXZINXzWw=; b=wOU3HTT/msJ3MC73ecumTOFB0OpDrNgqUkgbCCGfDaArjXAO6OzuttIr88xehfKp9X zh/6ERQE5lezVwOskY/Q4uqgNj6QL8rAarudOWS+jO/LGn2BgL8sIet7F6wFoFY2FFhI 5Aqv/hiTBedECrpjboH88seKtcr/LEZ2liw3tumkrQzQO9Go5g5S7t/fNisg8p6RES16 xAsCw1suTOwuLXza3IFysjgumFqTtS1N6IdxVGXm+K1RxLjuZkTaV7mOHeI+fdTBTNJR geMYfXLxpZpI0P9a1NDdBOgRA2nGO1RCkYwFHbZPymp5hyxH48AI1NcHCOlrQOTLWXi+ WZxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TdETGPLO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 20si1527031ejj.661.2021.06.13.08.15.52; Sun, 13 Jun 2021 08:16:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TdETGPLO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231887AbhFMPQU (ORCPT + 99 others); Sun, 13 Jun 2021 11:16:20 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:42929 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231799AbhFMPQT (ORCPT ); Sun, 13 Jun 2021 11:16:19 -0400 Received: by mail-qk1-f202.google.com with SMTP id o14-20020a05620a0d4eb02903a5eee61155so3844347qkl.9 for ; Sun, 13 Jun 2021 08:14:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=TGzdE/APFAf/QMVTCv6KrvuvVJCn0wQ+q/HXZINXzWw=; b=TdETGPLOrdfX/voxN6D0z0R9BOc6lPsqTWQAO7iZBwfPPhUs++8SVMeICrH0N81BoR N2d2Z0+zvPp8zj8W2YWtnXA96JQu66axaQyVw1SJ32NoVwEMZ+x35u3tEVDThCeHv0wH ktu3TVENspFulSMLxqa+7TmdoOJJskLRWw9WwhspC8x5uvSfdYsnvO15Fnl05JXLPPnd h9uz9gYJOS8lTL1jDCmjiEc6qRjViLh9w/oXn7hu64XM01Vu3H1KODOnDzLUIVG0bL3i 6ynNOMpB5fQyCyDvDAa+36GzMBX78tuoCjAzZIDuhhfhOKOl2qCY/S2uibYTwlZFabFd lm0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=TGzdE/APFAf/QMVTCv6KrvuvVJCn0wQ+q/HXZINXzWw=; b=WmAicnbpgxiyjpoGZo9tmQG3BN5peHcaTB4NzHny9a3q+MZkgRqz6W/29hHwYaY698 7Sm7pyPp5+Um1q7Z8iGtxBXemnJcvAL7c1eyOVGA07zriBDm6ZHfa5G2S2C1UgvkSu5P XNZFH+V8M0/yDL3G7YkvMOvOwcLxjXyog4GAJEt+MaCuqUGMmPXvvDeKvtJQPFUEmKfj x4nvMVOvRp26wRDCs3qpYX8bvBqZTtLe/YuAo5+KIxuF6QVI05Xe/cyb8wEuZTYqyBPl KD1hNPq+KeUGxq5R5bkXaSbtt0kqxkh7jus7gioXYaARACsTTLZomZJ94ijCZQNroP5+ 4LOQ== X-Gm-Message-State: AOAM5324nK2ZtyERnPFDjfuX/zC/nq+5X/kYTN3uOOf/k68gLohAxjlJ PL2P6+aj1+zm2zbfkymyq6W6g8gsVN+v X-Received: from kyletso.ntc.corp.google.com ([2401:fa00:fc:202:e9e4:90ce:a18b:7097]) (user=kyletso job=sendgmr) by 2002:a05:6214:1cb:: with SMTP id c11mr2062240qvt.47.1623597188802; Sun, 13 Jun 2021 08:13:08 -0700 (PDT) Date: Sun, 13 Jun 2021 23:12:23 +0800 Message-Id: <20210613151223.563736-1-kyletso@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.272.g935e593368-goog Subject: [PATCH] usb: typec: tcpm: Relax disconnect threshold during power negotiation From: Kyle Tso To: linux@roeck-us.net, heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org Cc: badhri@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the voltage is being decreased in power negotiation, the Source will set the power supply to operate at the new voltage level before sending PS_RDY. Relax the disconnect threshold for Sink after receiving Accept Message to ensure the relaxed setting is enabled before the voltage collapse. And the real threshold will be set after Sink receives PS_RDY Message. Fixes: f321a02caebd ("usb: typec: tcpm: Implement enabling Auto Discharge disconnect support") Cc: Badhri Jagan Sridharan Signed-off-by: Kyle Tso --- drivers/usb/typec/tcpm/tcpm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 0db685d5d9c0..9f3f37da71b6 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -2646,6 +2646,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port, switch (port->state) { case SNK_NEGOTIATE_CAPABILITIES: port->pps_data.active = false; + /* Voltage is going to be at new level. Relax the threshold here. */ + tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB, false, 0); tcpm_set_state(port, SNK_TRANSITION_SINK, 0); break; case SNK_NEGOTIATE_PPS_CAPABILITIES: @@ -2656,6 +2658,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port, port->req_supply_voltage = port->pps_data.req_out_volt; port->req_current_limit = port->pps_data.req_op_curr; power_supply_changed(port->psy); + /* Voltage is going to be at new level. Relax the threshold here. */ + tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB, false, 0); tcpm_set_state(port, SNK_TRANSITION_SINK, 0); break; case SOFT_RESET_SEND: -- 2.32.0.272.g935e593368-goog