From patchwork Mon Sep 23 22:40:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Sunil Dhamne X-Patchwork-Id: 13809982 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A2B7128369 for ; Mon, 23 Sep 2024 22:41:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727131269; cv=none; b=JcdJfZcJMQ8iCk8eraog+PE9ClH/1aKkOtDvfLFeTN0B9nIIrzJoWnpnC4Y9GlDB+VgcaEjbJ7D+PJtvktmlgKXX8fnozo5+3eHjhbcJ4D5Qh/IG9RON6Y0l/kOsgCgAx4gGvcA1AaZWEJfwsZeZFQa4ZfNkcgAM587jzeFY+oI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727131269; c=relaxed/simple; bh=PS4BLuuHTqRfAsc6UJdp59YR5Wc8DDeE0Qb1w74bDi0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Eh5Zt/qSMmy6Hy7UHvY3lSUsMn2AjEfF9n+NygC9RNmdb4v55Dh3TDplzgg3HzLZoZFH0EbUHyPys0BmNzM6khAjfcSOwh/VpRfKFmSeIxoxLHC4eMN2vC5yQkRcmFxA4BQvK8Zb1jMODMX6Rq/KqG53wRYPCa0TuZMltI5686g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--amitsd.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2WVRiLxD; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--amitsd.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2WVRiLxD" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e20937a68bso7664467b3.3 for ; Mon, 23 Sep 2024 15:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727131267; x=1727736067; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=h0CyW1JtJfwLGoAAX+BVVApeoMCB4q+lbs8zs4x8alI=; b=2WVRiLxDW2ERc+ddNqTsBvG2XSMSCOp5TlN4/UJSKY6zKgUTnkvhocH136rj/4Fkzg XRp59ODCK1kv1T/HiAatc4SG5Sp/cEd5hiIjom/NCSV/a+reUOdQEOg+ck3DYL7EGsYV Mu3wzyX5/9WY1aaSzkBmerkZ3z1q9/lzIdEStK/0BZYKLkzafLPn9WLzmqMkHpgPNKcm iZCnE1/gf7B3uI6Zyasxd5pcm3WmUe6XEKWM29mnYEH9gUTcmKJUICrDFrB/V949+emt iXPDIkVANU5C3QJ9FZyGa9/HtxxAIir9g9N5rfp+uJWPAivdlSOyFBcxL0EwV/jrH62r E1Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727131267; x=1727736067; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h0CyW1JtJfwLGoAAX+BVVApeoMCB4q+lbs8zs4x8alI=; b=nJBMkpTICUdhtCqyJ5Cnq7ZJNvvY8gkfaVdyvokoukt9Z1bv6F3agfvAOAv53/kd+6 aZFK2wYBi5XWX+HCgaDoxDP5zqhp3G04cdK3nwrKTOzP6zqmTr3aEyOjyCtKtcYp/KrJ DNrGkQrD7ptcDKYvVUhIago8OTEtcMen1E/sfSUZAUIMXrmD5dGX4coaVfsaI9iagxrE VsXQ4TeHEEZ8QPzv1LsHG+9wyPnKQ+gI2X3zSDc3i/YsK3pSZ+Rf+Fd6exEfjMSsAxFV bF/VCdCyIw1kkKW7S5TRHOKlHJAGpps+E3kJoina5PHHDneHNob4Q8YzujG0AN1Yyekj Q4Bg== X-Forwarded-Encrypted: i=1; AJvYcCXi0avZnSItlyYaACtT9x7EhEp+w4LEpouspp1MusRQXOjbBi3RTyzX9alF9Htw3UGBCCzpOFX8XeY=@vger.kernel.org X-Gm-Message-State: AOJu0YxltN33wViLkcPGKYuJgDPqt8a2Ha3nSNf4408WnpmQvn7q3sEz uB6WwWT35SU0y96BxRukx+s3LEAHRxymaQFwZdReKs+1lnHiqpdNMKbn8gGVMshPZImVgvuIopT dDg== X-Google-Smtp-Source: AGHT+IGSjLQWmP851y1eVS2/hu9bUHsBbO9LVlRM6GryOZeP6D1cgOZJreq/N+ptQftupMuqBX9oaKMKBFo= X-Received: from amitsd-gti.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:827]) (user=amitsd job=sendgmr) by 2002:a05:690c:6d01:b0:6dd:dcf5:28ad with SMTP id 00721157ae682-6dfeea08a59mr2106147b3.0.1727131267372; Mon, 23 Sep 2024 15:41:07 -0700 (PDT) Date: Mon, 23 Sep 2024 15:40:50 -0700 In-Reply-To: <20240923224059.3674414-1-amitsd@google.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240923224059.3674414-1-amitsd@google.com> X-Mailer: git-send-email 2.46.0.792.g87dc391469-goog Message-ID: <20240923224059.3674414-2-amitsd@google.com> Subject: [RFC v3 1/2] dt-bindings: connector: Add properties to define time values From: Amit Sunil Dhamne To: gregkh@linuxfoundation.org, robh@kernel.org, dmitry.baryshkov@linaro.org, heikki.krogerus@linux.intel.com Cc: badhri@google.com, kyletso@google.com, rdbabiera@google.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, Amit Sunil Dhamne This commit adds the following properties: * sink-wait-cap-time-ms * ps-source-off-time-ms * cc-debounce-time-ms This is to enable setting of platform/board specific timer values as these timers have a range of acceptable values. Signed-off-by: Amit Sunil Dhamne Reviewed-by: Rob Herring (Arm) --- .../bindings/connector/usb-connector.yaml | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml index fb216ce68bb3..21a0c58c65cd 100644 --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml @@ -253,6 +253,36 @@ properties: additionalProperties: false + sink-wait-cap-time-ms: + description: Represents the max time in ms that USB Type-C port (in sink + role) should wait for the port partner (source role) to send source caps. + SinkWaitCap timer starts when port in sink role attaches to the source. + This timer will stop when sink receives PD source cap advertisement before + timeout in which case it'll move to capability negotiation stage. A + timeout leads to a hard reset message by the port. + minimum: 310 + maximum: 620 + default: 310 + + ps-source-off-time-ms: + description: Represents the max time in ms that a DRP in source role should + take to turn off power after the PsSourceOff timer starts. PsSourceOff + timer starts when a sink's PHY layer receives EOP of the GoodCRC message + (corresponding to an Accept message sent in response to a PR_Swap or a + FR_Swap request). This timer stops when last bit of GoodCRC EOP + corresponding to the received PS_RDY message is transmitted by the PHY + layer. A timeout shall lead to error recovery in the type-c port. + minimum: 750 + maximum: 920 + default: 920 + + cc-debounce-time-ms: + description: Represents the max time in ms that a port shall wait to + determine if it's attached to a partner. + minimum: 100 + maximum: 200 + default: 200 + dependencies: sink-vdos-v1: [ sink-vdos ] sink-vdos: [ sink-vdos-v1 ] @@ -380,7 +410,7 @@ examples: }; # USB-C connector attached to a typec port controller(ptn5110), which has - # power delivery support and enables drp. + # power delivery support, explicitly defines time properties and enables drp. - | #include typec: ptn5110 { @@ -393,6 +423,9 @@ examples: sink-pdos = ; op-sink-microwatt = <10000000>; + sink-wait-cap-time-ms = <465>; + ps-source-off-time-ms = <835>; + cc-debounce-time-ms = <101>; }; }; From patchwork Mon Sep 23 22:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Sunil Dhamne X-Patchwork-Id: 13809983 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D17912D1F1 for ; Mon, 23 Sep 2024 22:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727131273; cv=none; b=H70fG9057Ygcbcex36tIyg8frwSIUAIOw0uzJMfHlTUsHnLu517d+aqTefReGEC40Xzjnu87R2ymdbBiIRhpSRFdmtqx6q+0cooZxBR0cWzcumBcy0Hk5y92dApRC1pWRp4ceYOcEaOcsX6KZ0tNvUQf4DGSSzXg0oan5YQqD4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727131273; c=relaxed/simple; bh=Hodq5RHSLNvDU0kWQYUS5MtS4N/sAOd18eJkJzQy2yQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ndcI1Jr9mq0a0WCpei/yWTFWvCf1BPXO/l4Kgbkdd5KLupu2r1swSDCRBiz2A6EOfFxMCANDuy5kLmgwANy2obtOICAeR92s2spcIARc3bniQZCgB7k1TTyyo1yOURB64BbVXwKUHvKDRd9Rl78CkXaSbRSvWiShLxIBP5oYrRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--amitsd.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EQHKrq47; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--amitsd.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EQHKrq47" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6d470831e3aso83973107b3.3 for ; Mon, 23 Sep 2024 15:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727131270; x=1727736070; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=W2/5FoFqMYLDskw0LGckVxOOGoqnljVK4brc1RjW8hA=; b=EQHKrq47RxwZzq5fM8Dd5oH5b138vWPWZSFiHbliC3M0z5BHO1BbL7VWo/sTd6ubzo UZ6rFvkJ7Ja9HpCkytRW4m+R0H0JCvvVRSLsJWy9+SjLlDgsyFnO73QkbZPScGXo5eHy yv6ryfdf2wjGB+StlaPGZrNfS6XRwsp0Zc9PnzEtMhvNvCa5qIjglk5OzQYTGmKSrbda i/LZy+I1r/kHj68WYkIxYUxHxlIUg3B5En1s9+pApt19viD/fFUMaEEPYbEFvsN/KBtq 0iAPN1aJRjeJsjyp42JV3rbETKtJX6+ucL+S+gstu8pUdPghfTsr8SNxUPwIUZs8ZYoI YD/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727131270; x=1727736070; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=W2/5FoFqMYLDskw0LGckVxOOGoqnljVK4brc1RjW8hA=; b=j0OBwiTD1fbP6+vAKkd6zlUKF9SfVX4rWMsrNLKu4awWcwa6an0fJeGdwVgBhKBCiX NQ8iD/8UisqJSAVrAl0KIRbT/0Fn5FJIzdh+QyveeEkRbaMebqdZLPkoqoM2oS3faoYf rhebu7ZAWgN1FkyEyuJfTL7TmbX+laKRHm1rnwwNcac8Umf8Etm/AzyOVgwp6uTjSGal pAuXB1wgKCEw3TrJOz1SR4Jj9elSawGUyAwiXks3WTRa7AKDuhGzqka4E3WFSioZ2EC1 wu3YfUiaDdULH5nxDCL3xUzeY+bCcd/MJLteKqHfm3RxJL0ICuILo/z7qoCpDXj34Hvr Yslw== X-Forwarded-Encrypted: i=1; AJvYcCXVxwNVsKOzJlqd+QlJyeJu4okCWWAeM2SbgxIo3BxcvSlMmjDr2qSMYlQc+5N4wX7C48SCbdOWGbk=@vger.kernel.org X-Gm-Message-State: AOJu0YzjTFwM+2ZjBAnjDrXShJU33z6YKlTXkJ4OQb3Lp58X+3I3lpeM U7LjM3BOgc8gHOsa4m8jdj0BKqKzcXNAvE683MgluMiqEQDERwKkVrVI2auGLEefLTHE+T7CyXP HBw== X-Google-Smtp-Source: AGHT+IGwYdnk1TnkY48JqaPbWqa6BChs4EteYkdBZdEzxBAseTgJg9m141jE0iPjCxLnEZs9cqm88HIfO0s= X-Received: from amitsd-gti.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:827]) (user=amitsd job=sendgmr) by 2002:a25:6947:0:b0:e1c:ed3d:7bb7 with SMTP id 3f1490d57ef6-e2250c24e0dmr11268276.1.1727131270248; Mon, 23 Sep 2024 15:41:10 -0700 (PDT) Date: Mon, 23 Sep 2024 15:40:51 -0700 In-Reply-To: <20240923224059.3674414-1-amitsd@google.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240923224059.3674414-1-amitsd@google.com> X-Mailer: git-send-email 2.46.0.792.g87dc391469-goog Message-ID: <20240923224059.3674414-3-amitsd@google.com> Subject: [RFC v3 2/2] usb: typec: tcpm: Add support for parsing time dt properties From: Amit Sunil Dhamne To: gregkh@linuxfoundation.org, robh@kernel.org, dmitry.baryshkov@linaro.org, heikki.krogerus@linux.intel.com Cc: badhri@google.com, kyletso@google.com, rdbabiera@google.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, Amit Sunil Dhamne Add support for DT time properties to allow users to define platform specific timing deadlines of certain timers rather than using hardcoded ones. For values that have not been explicitly defined in DT using this property, default values will be set therefore, making this change backward compatible. Signed-off-by: Amit Sunil Dhamne Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tcpm/tcpm.c | 74 +++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 16 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 4b02d6474259..b06a4ff733bd 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -310,6 +310,17 @@ struct pd_data { unsigned int operating_snk_mw; }; +/* + * @sink_wait_cap_time: Deadline (in ms) for tTypeCSinkWaitCap timer + * @ps_src_wait_off_time: Deadline (in ms) for tPSSourceOff timer + * @cc_debounce_time: Deadline (in ms) for tCCDebounce timer + */ +struct pd_timings { + u32 sink_wait_cap_time; + u32 ps_src_off_time; + u32 cc_debounce_time; +}; + struct tcpm_port { struct device *dev; @@ -552,6 +563,9 @@ struct tcpm_port { */ unsigned int message_id_prime; unsigned int rx_msgid_prime; + + /* Timer deadline values configured at runtime */ + struct pd_timings timings; #ifdef CONFIG_DEBUG_FS struct dentry *dentry; struct mutex logbuffer_lock; /* log buffer access lock */ @@ -4639,15 +4653,15 @@ static void run_state_machine(struct tcpm_port *port) case SRC_ATTACH_WAIT: if (tcpm_port_is_debug(port)) tcpm_set_state(port, DEBUG_ACC_ATTACHED, - PD_T_CC_DEBOUNCE); + port->timings.cc_debounce_time); else if (tcpm_port_is_audio(port)) tcpm_set_state(port, AUDIO_ACC_ATTACHED, - PD_T_CC_DEBOUNCE); + port->timings.cc_debounce_time); else if (tcpm_port_is_source(port) && port->vbus_vsafe0v) tcpm_set_state(port, tcpm_try_snk(port) ? SNK_TRY : SRC_ATTACHED, - PD_T_CC_DEBOUNCE); + port->timings.cc_debounce_time); break; case SNK_TRY: @@ -4698,7 +4712,7 @@ static void run_state_machine(struct tcpm_port *port) } break; case SRC_TRYWAIT_DEBOUNCE: - tcpm_set_state(port, SRC_ATTACHED, PD_T_CC_DEBOUNCE); + tcpm_set_state(port, SRC_ATTACHED, port->timings.cc_debounce_time); break; case SRC_TRYWAIT_UNATTACHED: tcpm_set_state(port, SNK_UNATTACHED, 0); @@ -4901,7 +4915,7 @@ static void run_state_machine(struct tcpm_port *port) (port->cc1 != TYPEC_CC_OPEN && port->cc2 == TYPEC_CC_OPEN)) tcpm_set_state(port, SNK_DEBOUNCED, - PD_T_CC_DEBOUNCE); + port->timings.cc_debounce_time); else if (tcpm_port_is_disconnected(port)) tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE); @@ -4941,7 +4955,7 @@ static void run_state_machine(struct tcpm_port *port) break; case SNK_TRYWAIT: tcpm_set_cc(port, TYPEC_CC_RD); - tcpm_set_state(port, SNK_TRYWAIT_VBUS, PD_T_CC_DEBOUNCE); + tcpm_set_state(port, SNK_TRYWAIT_VBUS, port->timings.cc_debounce_time); break; case SNK_TRYWAIT_VBUS: /* @@ -5014,7 +5028,7 @@ static void run_state_machine(struct tcpm_port *port) break; case SNK_DISCOVERY_DEBOUNCE: tcpm_set_state(port, SNK_DISCOVERY_DEBOUNCE_DONE, - PD_T_CC_DEBOUNCE); + port->timings.cc_debounce_time); break; case SNK_DISCOVERY_DEBOUNCE_DONE: if (!tcpm_port_is_disconnected(port) && @@ -5041,10 +5055,10 @@ static void run_state_machine(struct tcpm_port *port) if (port->vbus_never_low) { port->vbus_never_low = false; tcpm_set_state(port, SNK_SOFT_RESET, - PD_T_SINK_WAIT_CAP); + port->timings.sink_wait_cap_time); } else { tcpm_set_state(port, SNK_WAIT_CAPABILITIES_TIMEOUT, - PD_T_SINK_WAIT_CAP); + port->timings.sink_wait_cap_time); } break; case SNK_WAIT_CAPABILITIES_TIMEOUT: @@ -5066,7 +5080,8 @@ static void run_state_machine(struct tcpm_port *port) if (tcpm_pd_send_control(port, PD_CTRL_GET_SOURCE_CAP, TCPC_TX_SOP)) tcpm_set_state_cond(port, hard_reset_state(port), 0); else - tcpm_set_state(port, hard_reset_state(port), PD_T_SINK_WAIT_CAP); + tcpm_set_state(port, hard_reset_state(port), + port->timings.sink_wait_cap_time); break; case SNK_NEGOTIATE_CAPABILITIES: port->pd_capable = true; @@ -5203,7 +5218,7 @@ static void run_state_machine(struct tcpm_port *port) tcpm_set_state(port, ACC_UNATTACHED, 0); break; case AUDIO_ACC_DEBOUNCE: - tcpm_set_state(port, ACC_UNATTACHED, PD_T_CC_DEBOUNCE); + tcpm_set_state(port, ACC_UNATTACHED, port->timings.cc_debounce_time); break; /* Hard_Reset states */ @@ -5420,7 +5435,7 @@ static void run_state_machine(struct tcpm_port *port) tcpm_set_state(port, ERROR_RECOVERY, 0); break; case FR_SWAP_SNK_SRC_TRANSITION_TO_OFF: - tcpm_set_state(port, ERROR_RECOVERY, PD_T_PS_SOURCE_OFF); + tcpm_set_state(port, ERROR_RECOVERY, port->timings.ps_src_off_time); break; case FR_SWAP_SNK_SRC_NEW_SINK_READY: if (port->vbus_source) @@ -5475,7 +5490,7 @@ static void run_state_machine(struct tcpm_port *port) tcpm_set_cc(port, TYPEC_CC_RD); /* allow CC debounce */ tcpm_set_state(port, PR_SWAP_SRC_SNK_SOURCE_OFF_CC_DEBOUNCED, - PD_T_CC_DEBOUNCE); + port->timings.cc_debounce_time); break; case PR_SWAP_SRC_SNK_SOURCE_OFF_CC_DEBOUNCED: /* @@ -5510,7 +5525,7 @@ static void run_state_machine(struct tcpm_port *port) port->pps_data.active, 0); tcpm_set_charge(port, false); tcpm_set_state(port, hard_reset_state(port), - PD_T_PS_SOURCE_OFF); + port->timings.ps_src_off_time); break; case PR_SWAP_SNK_SRC_SOURCE_ON: tcpm_enable_auto_vbus_discharge(port, true); @@ -5666,7 +5681,7 @@ static void run_state_machine(struct tcpm_port *port) case PORT_RESET_WAIT_OFF: tcpm_set_state(port, tcpm_default_state(port), - port->vbus_present ? PD_T_PS_SOURCE_OFF : 0); + port->vbus_present ? port->timings.ps_src_off_time : 0); break; /* AMS intermediate state */ @@ -6157,7 +6172,7 @@ static void _tcpm_pd_vbus_vsafe0v(struct tcpm_port *port) case SRC_ATTACH_WAIT: if (tcpm_port_is_source(port)) tcpm_set_state(port, tcpm_try_snk(port) ? SNK_TRY : SRC_ATTACHED, - PD_T_CC_DEBOUNCE); + port->timings.cc_debounce_time); break; case SRC_STARTUP: case SRC_SEND_CAPABILITIES: @@ -7053,6 +7068,30 @@ static int tcpm_port_register_pd(struct tcpm_port *port) return ret; } +static void tcpm_fw_get_timings(struct tcpm_port *port, struct fwnode_handle *fwnode) +{ + int ret; + u32 val; + + ret = fwnode_property_read_u32(fwnode, "sink-wait-cap-time-ms", &val); + if (!ret) + port->timings.sink_wait_cap_time = val; + else + port->timings.sink_wait_cap_time = PD_T_SINK_WAIT_CAP; + + ret = fwnode_property_read_u32(fwnode, "ps-source-off-time-ms", &val); + if (!ret) + port->timings.ps_src_off_time = val; + else + port->timings.ps_src_off_time = PD_T_PS_SOURCE_OFF; + + ret = fwnode_property_read_u32(fwnode, "cc-debounce-time-ms", &val); + if (!ret) + port->timings.cc_debounce_time = val; + else + port->timings.cc_debounce_time = PD_T_CC_DEBOUNCE; +} + static int tcpm_fw_get_caps(struct tcpm_port *port, struct fwnode_handle *fwnode) { struct fwnode_handle *capabilities, *child, *caps = NULL; @@ -7611,10 +7650,13 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) err = tcpm_fw_get_caps(port, tcpc->fwnode); if (err < 0) goto out_destroy_wq; + err = tcpm_fw_get_snk_vdos(port, tcpc->fwnode); if (err < 0) goto out_destroy_wq; + tcpm_fw_get_timings(port, tcpc->fwnode); + port->try_role = port->typec_caps.prefer_role; port->typec_caps.revision = 0x0120; /* Type-C spec release 1.2 */