* [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
[not found] <20240911000715.554184-1-amitsd@google.com>
@ 2024-09-11 0:07 ` Amit Sunil Dhamne
2024-09-12 10:05 ` Dmitry Baryshkov
2024-09-16 16:05 ` Krzysztof Kozlowski
2024-09-11 0:07 ` [RFC 2/2] usb: typec: tcpm: Add support for pd-timers DT property Amit Sunil Dhamne
1 sibling, 2 replies; 12+ messages in thread
From: Amit Sunil Dhamne @ 2024-09-11 0:07 UTC (permalink / raw)
To: robh+dt, krzysztof.kozlowski+dt, conor+dt, heikki.krogerus,
gregkh
Cc: linux-kernel, kyletso, rdbabiera, Amit Sunil Dhamne,
Badhri Jagan Sridharan, linux-usb, devicetree
This commit adds a new property "pd-timers" to enable setting of
platform/board specific pd timer values for timers that have a range of
acceptable values.
Cc: Badhri Jagan Sridharan <badhri@google.com>
Cc: linux-usb@vger.kernel.org
Cc: devicetree@vger.kernel.org
Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
---
.../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
include/dt-bindings/usb/pd.h | 8 +++++++
2 files changed, 31 insertions(+)
diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
index fb216ce68bb3..9be4ed12f13c 100644
--- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
+++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
@@ -253,6 +253,16 @@ properties:
additionalProperties: false
+ pd-timers:
+ description: An array of u32 integers, where an even index (i) is the timer (referenced in
+ dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
+ "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
+ the appropriate value). For certain timers the PD spec defines a range rather than a fixed
+ value. The timers may need to be tuned based on the platform. This dt property allows the user
+ to assign specific values based on the platform. If these values are not explicitly defined,
+ TCPM will use a valid default value for such timers.
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+
dependencies:
sink-vdos-v1: [ sink-vdos ]
sink-vdos: [ sink-vdos-v1 ]
@@ -478,3 +488,16 @@ examples:
};
};
};
+
+ # USB-C connector with PD timers
+ - |
+ #include <dt-bindings/usb/pd.h>
+ usb {
+ connector {
+ compatible = "usb-c-connector";
+ label = "USB-C";
+ pd-timers =
+ <PD_TIMER_SINK_WAIT_CAP 600>,
+ <PD_TIMER_CC_DEBOUNCE 170>;
+ };
+ };
diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
index e6526b138174..6c58c30f3f39 100644
--- a/include/dt-bindings/usb/pd.h
+++ b/include/dt-bindings/usb/pd.h
@@ -465,4 +465,12 @@
| ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \
| ((gi) & 0x3f) << 1 | (ct))
+/* PD Timer definitions */
+/* tTypeCSinkWaitCap (Table 6-68 Time Values, USB PD3.1 Spec) */
+#define PD_TIMER_SINK_WAIT_CAP 0
+/* tPSSourceOff (Table 6-68 Time Values, USB PD3.1 Spec) */
+#define PD_TIMER_PS_SOURCE_OFF 1
+/* tCCDebounce (Table 4-33 CC Timing, USB Type-C Cable & Connector Spec Rel2.2) */
+#define PD_TIMER_CC_DEBOUNCE 2
+
#endif /* __DT_POWER_DELIVERY_H */
--
2.46.0.598.g6f2099f65c-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC 2/2] usb: typec: tcpm: Add support for pd-timers DT property
[not found] <20240911000715.554184-1-amitsd@google.com>
2024-09-11 0:07 ` [RFC 1/2] dt-bindings: connector: Add property to set pd timer values Amit Sunil Dhamne
@ 2024-09-11 0:07 ` Amit Sunil Dhamne
1 sibling, 0 replies; 12+ messages in thread
From: Amit Sunil Dhamne @ 2024-09-11 0:07 UTC (permalink / raw)
To: robh+dt, krzysztof.kozlowski+dt, conor+dt, heikki.krogerus,
gregkh
Cc: linux-kernel, kyletso, rdbabiera, Amit Sunil Dhamne,
Badhri Jagan Sridharan, linux-usb, devicetree
Add support for DT property "pd-timers" to allow users to define
platform specific values. For values that have not been explicitly
defined in DT using this attribute, default values will be set.
Therefore making this change backward compatible.
Cc: Badhri Jagan Sridharan <badhri@google.com>
Cc: linux-usb@vger.kernel.org
Cc: devicetree@vger.kernel.org
Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
---
drivers/usb/typec/tcpm/tcpm.c | 110 ++++++++++++++++++++++++++++------
1 file changed, 92 insertions(+), 18 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 4b02d6474259..596d19ff85ac 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -574,6 +574,31 @@ static const char * const pd_rev[] = {
[PD_REV30] = "rev3",
};
+/*
+ * Though "pd-timers" is a 1D array, it can be imagined as a table with 2
+ * columns, key at even index (that represents timer definition) & value
+ * at odd index (that represents timer values in ms).
+ */
+#define NUM_TIMER_TABLE_COLS 2
+
+/*
+ * PD Timer definitions for timers that can be tuned based on platform/board via DT.
+ * The timer definition value should always match that of macros defined in
+ * dt-bindings/usb/pd.h.
+ */
+enum pd_timer {
+ PD_TIMER_SINK_WAIT_CAP,
+ PD_TIMER_PS_SOURCE_OFF,
+ PD_TIMER_CC_DEBOUNCE,
+ PD_NUM_TIMERS
+};
+
+static u32 pd_timers[PD_NUM_TIMERS] = {
+ [PD_TIMER_SINK_WAIT_CAP] = PD_T_SINK_WAIT_CAP,
+ [PD_TIMER_PS_SOURCE_OFF] = PD_T_PS_SOURCE_OFF,
+ [PD_TIMER_CC_DEBOUNCE] = PD_T_CC_DEBOUNCE,
+};
+
#define tcpm_cc_is_sink(cc) \
((cc) == TYPEC_CC_RP_DEF || (cc) == TYPEC_CC_RP_1_5 || \
(cc) == TYPEC_CC_RP_3_0)
@@ -4601,7 +4626,7 @@ static void run_state_machine(struct tcpm_port *port)
{
int ret;
enum typec_pwr_opmode opmode;
- unsigned int msecs;
+ unsigned int msecs, timer_val_msecs;
enum tcpm_state upcoming_state;
if (port->tcpc->check_contaminant && port->state != CHECK_CONTAMINANT)
@@ -4637,17 +4662,18 @@ static void run_state_machine(struct tcpm_port *port)
tcpm_set_state(port, SNK_UNATTACHED, PD_T_DRP_SNK);
break;
case SRC_ATTACH_WAIT:
+ timer_val_msecs = pd_timers[PD_TIMER_CC_DEBOUNCE];
if (tcpm_port_is_debug(port))
tcpm_set_state(port, DEBUG_ACC_ATTACHED,
- PD_T_CC_DEBOUNCE);
+ timer_val_msecs);
else if (tcpm_port_is_audio(port))
tcpm_set_state(port, AUDIO_ACC_ATTACHED,
- PD_T_CC_DEBOUNCE);
+ timer_val_msecs);
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);
+ timer_val_msecs);
break;
case SNK_TRY:
@@ -4698,7 +4724,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, pd_timers[PD_TIMER_CC_DEBOUNCE]);
break;
case SRC_TRYWAIT_UNATTACHED:
tcpm_set_state(port, SNK_UNATTACHED, 0);
@@ -4896,12 +4922,13 @@ static void run_state_machine(struct tcpm_port *port)
tcpm_set_state(port, SRC_UNATTACHED, PD_T_DRP_SRC);
break;
case SNK_ATTACH_WAIT:
+ timer_val_msecs = pd_timers[PD_TIMER_CC_DEBOUNCE];
if ((port->cc1 == TYPEC_CC_OPEN &&
port->cc2 != TYPEC_CC_OPEN) ||
(port->cc1 != TYPEC_CC_OPEN &&
port->cc2 == TYPEC_CC_OPEN))
tcpm_set_state(port, SNK_DEBOUNCED,
- PD_T_CC_DEBOUNCE);
+ timer_val_msecs);
else if (tcpm_port_is_disconnected(port))
tcpm_set_state(port, SNK_UNATTACHED,
PD_T_PD_DEBOUNCE);
@@ -4941,7 +4968,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, pd_timers[PD_TIMER_CC_DEBOUNCE]);
break;
case SNK_TRYWAIT_VBUS:
/*
@@ -5014,7 +5041,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);
+ pd_timers[PD_TIMER_CC_DEBOUNCE]);
break;
case SNK_DISCOVERY_DEBOUNCE_DONE:
if (!tcpm_port_is_disconnected(port) &&
@@ -5032,6 +5059,7 @@ static void run_state_machine(struct tcpm_port *port)
tcpm_set_state(port, SNK_READY, 0);
break;
}
+ timer_val_msecs = pd_timers[PD_TIMER_SINK_WAIT_CAP];
/*
* If VBUS has never been low, and we time out waiting
* for source cap, try a soft reset first, in case we
@@ -5041,10 +5069,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);
+ timer_val_msecs);
} else {
tcpm_set_state(port, SNK_WAIT_CAPABILITIES_TIMEOUT,
- PD_T_SINK_WAIT_CAP);
+ timer_val_msecs);
}
break;
case SNK_WAIT_CAPABILITIES_TIMEOUT:
@@ -5054,7 +5082,7 @@ static void run_state_machine(struct tcpm_port *port)
* sending Source Capability messages after a soft reset. The
* specification suggests to do a hard reset when no Source
* capability message is received within PD_T_SINK_WAIT_CAP,
- * but that might effectively kil the machine's power source.
+ * but that might effectively kill the machine's power source.
*
* This slightly diverges from the specification and tries to
* recover from this by explicitly asking for the capabilities
@@ -5066,7 +5094,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),
+ pd_timers[PD_TIMER_SINK_WAIT_CAP]);
break;
case SNK_NEGOTIATE_CAPABILITIES:
port->pd_capable = true;
@@ -5203,7 +5232,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, pd_timers[PD_TIMER_CC_DEBOUNCE]);
break;
/* Hard_Reset states */
@@ -5420,7 +5449,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, pd_timers[PD_TIMER_PS_SOURCE_OFF]);
break;
case FR_SWAP_SNK_SRC_NEW_SINK_READY:
if (port->vbus_source)
@@ -5475,7 +5504,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);
+ pd_timers[PD_TIMER_CC_DEBOUNCE]);
break;
case PR_SWAP_SRC_SNK_SOURCE_OFF_CC_DEBOUNCED:
/*
@@ -5510,7 +5539,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);
+ pd_timers[PD_TIMER_PS_SOURCE_OFF]);
break;
case PR_SWAP_SNK_SRC_SOURCE_ON:
tcpm_enable_auto_vbus_discharge(port, true);
@@ -5666,7 +5695,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 ? pd_timers[PD_TIMER_PS_SOURCE_OFF] : 0);
break;
/* AMS intermediate state */
@@ -6157,7 +6186,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);
+ pd_timers[PD_TIMER_CC_DEBOUNCE]);
break;
case SRC_STARTUP:
case SRC_SEND_CAPABILITIES:
@@ -7273,6 +7302,47 @@ static int tcpm_fw_get_snk_vdos(struct tcpm_port *port, struct fwnode_handle *fw
return 0;
}
+static int tcpm_fw_get_pd_timers(struct tcpm_port *port, struct fwnode_handle *fwnode)
+{
+ int ret, i, len;
+ u32 *buf;
+
+ /* pd-timers is an optional property */
+ ret = fwnode_property_count_u32(fwnode, "pd-timers");
+ if (ret < 0) {
+ tcpm_log(port, "Unable to locate 'pd-timers' connector property (%d)", ret);
+ return 0;
+ }
+
+ if (ret % NUM_TIMER_TABLE_COLS || ret == 0) {
+ tcpm_log(port, "Incorrect 'pd-timers' value. Found %d u32 elements in array", ret);
+ return 0;
+ }
+
+ len = min(ret, PD_NUM_TIMERS * NUM_TIMER_TABLE_COLS);
+
+ buf = kcalloc(len, sizeof(*buf), GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ ret = fwnode_property_read_u32_array(fwnode, "pd-timers", buf, len);
+ if (ret) {
+ dev_err(port->dev, "Unable to read pd-timers property (%d)", ret);
+ goto done;
+ }
+
+ for (i = 0; i < len - 1; i += NUM_TIMER_TABLE_COLS) {
+ if (buf[i] >= PD_NUM_TIMERS)
+ tcpm_log(port, "Unable to find timer index %d, skipping.", buf[i]);
+ else
+ pd_timers[buf[i]] = buf[i + 1];
+ }
+
+done:
+ kfree(buf);
+ return ret;
+}
+
/* Power Supply access to expose source power information */
enum tcpm_psy_online_states {
TCPM_PSY_OFFLINE = 0,
@@ -7608,6 +7678,10 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
init_completion(&port->pps_complete);
tcpm_debugfs_init(port);
+ err = tcpm_fw_get_pd_timers(port, tcpc->fwnode);
+ if (err)
+ goto out_destroy_wq;
+
err = tcpm_fw_get_caps(port, tcpc->fwnode);
if (err < 0)
goto out_destroy_wq;
--
2.46.0.598.g6f2099f65c-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
2024-09-11 0:07 ` [RFC 1/2] dt-bindings: connector: Add property to set pd timer values Amit Sunil Dhamne
@ 2024-09-12 10:05 ` Dmitry Baryshkov
2024-09-12 23:26 ` Amit Sunil Dhamne
2024-09-16 16:05 ` Krzysztof Kozlowski
1 sibling, 1 reply; 12+ messages in thread
From: Dmitry Baryshkov @ 2024-09-12 10:05 UTC (permalink / raw)
To: Amit Sunil Dhamne
Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, heikki.krogerus,
gregkh, linux-kernel, kyletso, rdbabiera, Badhri Jagan Sridharan,
linux-usb, devicetree
On Tue, Sep 10, 2024 at 05:07:05PM GMT, Amit Sunil Dhamne wrote:
> This commit adds a new property "pd-timers" to enable setting of
> platform/board specific pd timer values for timers that have a range of
> acceptable values.
>
> Cc: Badhri Jagan Sridharan <badhri@google.com>
> Cc: linux-usb@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
> ---
> .../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
> include/dt-bindings/usb/pd.h | 8 +++++++
> 2 files changed, 31 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> index fb216ce68bb3..9be4ed12f13c 100644
> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> @@ -253,6 +253,16 @@ properties:
>
> additionalProperties: false
>
> + pd-timers:
> + description: An array of u32 integers, where an even index (i) is the timer (referenced in
> + dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
> + "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
> + the appropriate value). For certain timers the PD spec defines a range rather than a fixed
> + value. The timers may need to be tuned based on the platform. This dt property allows the user
> + to assign specific values based on the platform. If these values are not explicitly defined,
> + TCPM will use a valid default value for such timers.
> + $ref: /schemas/types.yaml#/definitions/uint32-array
Is it really necessary to use the array property? I think it's easier
and more logical to define corresponding individual properties, one per
the timer.
> +
> dependencies:
> sink-vdos-v1: [ sink-vdos ]
> sink-vdos: [ sink-vdos-v1 ]
> @@ -478,3 +488,16 @@ examples:
> };
> };
> };
> +
> + # USB-C connector with PD timers
> + - |
> + #include <dt-bindings/usb/pd.h>
> + usb {
> + connector {
> + compatible = "usb-c-connector";
> + label = "USB-C";
> + pd-timers =
> + <PD_TIMER_SINK_WAIT_CAP 600>,
> + <PD_TIMER_CC_DEBOUNCE 170>;
> + };
> + };
> diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
> index e6526b138174..6c58c30f3f39 100644
> --- a/include/dt-bindings/usb/pd.h
> +++ b/include/dt-bindings/usb/pd.h
> @@ -465,4 +465,12 @@
> | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \
> | ((gi) & 0x3f) << 1 | (ct))
>
> +/* PD Timer definitions */
> +/* tTypeCSinkWaitCap (Table 6-68 Time Values, USB PD3.1 Spec) */
> +#define PD_TIMER_SINK_WAIT_CAP 0
> +/* tPSSourceOff (Table 6-68 Time Values, USB PD3.1 Spec) */
> +#define PD_TIMER_PS_SOURCE_OFF 1
> +/* tCCDebounce (Table 4-33 CC Timing, USB Type-C Cable & Connector Spec Rel2.2) */
> +#define PD_TIMER_CC_DEBOUNCE 2
> +
> #endif /* __DT_POWER_DELIVERY_H */
> --
> 2.46.0.598.g6f2099f65c-goog
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
2024-09-12 10:05 ` Dmitry Baryshkov
@ 2024-09-12 23:26 ` Amit Sunil Dhamne
2024-09-13 4:34 ` Dmitry Baryshkov
2024-09-16 16:05 ` Krzysztof Kozlowski
0 siblings, 2 replies; 12+ messages in thread
From: Amit Sunil Dhamne @ 2024-09-12 23:26 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, heikki.krogerus,
gregkh, linux-kernel, kyletso, rdbabiera, Badhri Jagan Sridharan,
linux-usb, devicetree
Hi Dmitry,
On 9/12/24 3:05 AM, Dmitry Baryshkov wrote:
> On Tue, Sep 10, 2024 at 05:07:05PM GMT, Amit Sunil Dhamne wrote:
>> This commit adds a new property "pd-timers" to enable setting of
>> platform/board specific pd timer values for timers that have a range of
>> acceptable values.
>>
>> Cc: Badhri Jagan Sridharan <badhri@google.com>
>> Cc: linux-usb@vger.kernel.org
>> Cc: devicetree@vger.kernel.org
>> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
>> ---
>> .../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
>> include/dt-bindings/usb/pd.h | 8 +++++++
>> 2 files changed, 31 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>> index fb216ce68bb3..9be4ed12f13c 100644
>> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
>> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>> @@ -253,6 +253,16 @@ properties:
>>
>> additionalProperties: false
>>
>> + pd-timers:
>> + description: An array of u32 integers, where an even index (i) is the timer (referenced in
>> + dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
>> + "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
>> + the appropriate value). For certain timers the PD spec defines a range rather than a fixed
>> + value. The timers may need to be tuned based on the platform. This dt property allows the user
>> + to assign specific values based on the platform. If these values are not explicitly defined,
>> + TCPM will use a valid default value for such timers.
>> + $ref: /schemas/types.yaml#/definitions/uint32-array
> Is it really necessary to use the array property? I think it's easier
> and more logical to define corresponding individual properties, one per
> the timer.
Thanks for the review. The reason I did it this way was for
convenience. If in the future someone else wants add a new timer,
it'd be convenient to just add it as a new macro definition in pd.h
rather than having to define a new property each time, especially
if folks want to add more timers (scales better).
There are 3 timers already and I am working to add a fourth in a
follow up patch if the current RFC gets accepted.
Please let me know what do you think?
Regards,
Amit
>> +
>> dependencies:
>> sink-vdos-v1: [ sink-vdos ]
>> sink-vdos: [ sink-vdos-v1 ]
>> @@ -478,3 +488,16 @@ examples:
>> };
>> };
>> };
>> +
>> + # USB-C connector with PD timers
>> + - |
>> + #include <dt-bindings/usb/pd.h>
>> + usb {
>> + connector {
>> + compatible = "usb-c-connector";
>> + label = "USB-C";
>> + pd-timers =
>> + <PD_TIMER_SINK_WAIT_CAP 600>,
>> + <PD_TIMER_CC_DEBOUNCE 170>;
>> + };
>> + };
>> diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
>> index e6526b138174..6c58c30f3f39 100644
>> --- a/include/dt-bindings/usb/pd.h
>> +++ b/include/dt-bindings/usb/pd.h
>> @@ -465,4 +465,12 @@
>> | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \
>> | ((gi) & 0x3f) << 1 | (ct))
>>
>> +/* PD Timer definitions */
>> +/* tTypeCSinkWaitCap (Table 6-68 Time Values, USB PD3.1 Spec) */
>> +#define PD_TIMER_SINK_WAIT_CAP 0
>> +/* tPSSourceOff (Table 6-68 Time Values, USB PD3.1 Spec) */
>> +#define PD_TIMER_PS_SOURCE_OFF 1
>> +/* tCCDebounce (Table 4-33 CC Timing, USB Type-C Cable & Connector Spec Rel2.2) */
>> +#define PD_TIMER_CC_DEBOUNCE 2
>> +
>> #endif /* __DT_POWER_DELIVERY_H */
>> --
>> 2.46.0.598.g6f2099f65c-goog
>>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
2024-09-12 23:26 ` Amit Sunil Dhamne
@ 2024-09-13 4:34 ` Dmitry Baryshkov
2024-09-16 16:33 ` Rob Herring
2024-09-16 16:05 ` Krzysztof Kozlowski
1 sibling, 1 reply; 12+ messages in thread
From: Dmitry Baryshkov @ 2024-09-13 4:34 UTC (permalink / raw)
To: Amit Sunil Dhamne
Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, heikki.krogerus,
gregkh, linux-kernel, kyletso, rdbabiera, Badhri Jagan Sridharan,
linux-usb, devicetree
On Thu, Sep 12, 2024 at 04:26:25PM GMT, Amit Sunil Dhamne wrote:
> Hi Dmitry,
>
> On 9/12/24 3:05 AM, Dmitry Baryshkov wrote:
> > On Tue, Sep 10, 2024 at 05:07:05PM GMT, Amit Sunil Dhamne wrote:
> > > This commit adds a new property "pd-timers" to enable setting of
> > > platform/board specific pd timer values for timers that have a range of
> > > acceptable values.
> > >
> > > Cc: Badhri Jagan Sridharan <badhri@google.com>
> > > Cc: linux-usb@vger.kernel.org
> > > Cc: devicetree@vger.kernel.org
> > > Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
> > > ---
> > > .../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
> > > include/dt-bindings/usb/pd.h | 8 +++++++
> > > 2 files changed, 31 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> > > index fb216ce68bb3..9be4ed12f13c 100644
> > > --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
> > > +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> > > @@ -253,6 +253,16 @@ properties:
> > > additionalProperties: false
> > > + pd-timers:
> > > + description: An array of u32 integers, where an even index (i) is the timer (referenced in
> > > + dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
> > > + "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
> > > + the appropriate value). For certain timers the PD spec defines a range rather than a fixed
> > > + value. The timers may need to be tuned based on the platform. This dt property allows the user
> > > + to assign specific values based on the platform. If these values are not explicitly defined,
> > > + TCPM will use a valid default value for such timers.
> > > + $ref: /schemas/types.yaml#/definitions/uint32-array
> > Is it really necessary to use the array property? I think it's easier
> > and more logical to define corresponding individual properties, one per
> > the timer.
>
> Thanks for the review. The reason I did it this way was for
> convenience. If in the future someone else wants add a new timer,
> it'd be convenient to just add it as a new macro definition in pd.h
> rather than having to define a new property each time, especially
> if folks want to add more timers (scales better).
> There are 3 timers already and I am working to add a fourth in a
> follow up patch if the current RFC gets accepted.
>
> Please let me know what do you think?
I'd leave the decision to DT maintainers, but in my opinion multiple
properties scale better. Having a single value per property is easier to
handle rather than changing the tagged array.
>
> Regards,
>
> Amit
>
> > > +
> > > dependencies:
> > > sink-vdos-v1: [ sink-vdos ]
> > > sink-vdos: [ sink-vdos-v1 ]
> > > @@ -478,3 +488,16 @@ examples:
> > > };
> > > };
> > > };
> > > +
> > > + # USB-C connector with PD timers
> > > + - |
> > > + #include <dt-bindings/usb/pd.h>
> > > + usb {
> > > + connector {
> > > + compatible = "usb-c-connector";
> > > + label = "USB-C";
> > > + pd-timers =
> > > + <PD_TIMER_SINK_WAIT_CAP 600>,
> > > + <PD_TIMER_CC_DEBOUNCE 170>;
> > > + };
> > > + };
> > > diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
> > > index e6526b138174..6c58c30f3f39 100644
> > > --- a/include/dt-bindings/usb/pd.h
> > > +++ b/include/dt-bindings/usb/pd.h
> > > @@ -465,4 +465,12 @@
> > > | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \
> > > | ((gi) & 0x3f) << 1 | (ct))
> > > +/* PD Timer definitions */
> > > +/* tTypeCSinkWaitCap (Table 6-68 Time Values, USB PD3.1 Spec) */
> > > +#define PD_TIMER_SINK_WAIT_CAP 0
> > > +/* tPSSourceOff (Table 6-68 Time Values, USB PD3.1 Spec) */
> > > +#define PD_TIMER_PS_SOURCE_OFF 1
> > > +/* tCCDebounce (Table 4-33 CC Timing, USB Type-C Cable & Connector Spec Rel2.2) */
> > > +#define PD_TIMER_CC_DEBOUNCE 2
> > > +
> > > #endif /* __DT_POWER_DELIVERY_H */
> > > --
> > > 2.46.0.598.g6f2099f65c-goog
> > >
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
2024-09-11 0:07 ` [RFC 1/2] dt-bindings: connector: Add property to set pd timer values Amit Sunil Dhamne
2024-09-12 10:05 ` Dmitry Baryshkov
@ 2024-09-16 16:05 ` Krzysztof Kozlowski
2024-09-17 1:59 ` Amit Sunil Dhamne
1 sibling, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-16 16:05 UTC (permalink / raw)
To: Amit Sunil Dhamne, robh+dt, krzysztof.kozlowski+dt, conor+dt,
heikki.krogerus, gregkh
Cc: linux-kernel, kyletso, rdbabiera, Badhri Jagan Sridharan,
linux-usb, devicetree
On 11/09/2024 02:07, Amit Sunil Dhamne wrote:
> This commit adds a new property "pd-timers" to enable setting of
> platform/board specific pd timer values for timers that have a range of
> acceptable values.
>
> Cc: Badhri Jagan Sridharan <badhri@google.com>
> Cc: linux-usb@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
Please work on mainline, not ancient tree. You cannot get my CC address
like that from mainline. It's not possible. So either you don't develop
on mainline or you don't use get_maintainers.pl/b4/patman.
> ---
> .../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
> include/dt-bindings/usb/pd.h | 8 +++++++
> 2 files changed, 31 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> index fb216ce68bb3..9be4ed12f13c 100644
> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> @@ -253,6 +253,16 @@ properties:
>
> additionalProperties: false
>
> + pd-timers:
> + description: An array of u32 integers, where an even index (i) is the timer (referenced in
> + dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
timer of what? OS behavior?
> + "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
> + the appropriate value). For certain timers the PD spec defines a range rather than a fixed
> + value. The timers may need to be tuned based on the platform. This dt property allows the user
Do not describe what DT is. We all know what DT properties allow.
Instead describe how this relates to hardware or boards.
All this is wrongly wrapped. See Coding style (and I am not telling you
the value on purpose, so you will read the coding style) .
> + to assign specific values based on the platform. If these values are not explicitly defined,
> + TCPM will use a valid default value for such timers.
And what is the default?
> + $ref: /schemas/types.yaml#/definitions/uint32-array
I guess you want matrix here.
> +
> dependencies:
> sink-vdos-v1: [ sink-vdos ]
> sink-vdos: [ sink-vdos-v1 ]
> @@ -478,3 +488,16 @@ examples:
> };
> };
> };
> +
> + # USB-C connector with PD timers
> + - |
> + #include <dt-bindings/usb/pd.h>
> + usb {
> + connector {
> + compatible = "usb-c-connector";
> + label = "USB-C";
> + pd-timers =
> + <PD_TIMER_SINK_WAIT_CAP 600>,
> + <PD_TIMER_CC_DEBOUNCE 170>;
Incorporate it into existing example.
> + };
> + };
> diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
> index e6526b138174..6c58c30f3f39 100644
> --- a/include/dt-bindings/usb/pd.h
> +++ b/include/dt-bindings/usb/pd.h
> @@ -465,4 +465,12 @@
> | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \
> | ((gi) & 0x3f) << 1 | (ct))
>
> +/* PD Timer definitions */
> +/* tTypeCSinkWaitCap (Table 6-68 Time Values, USB PD3.1 Spec) */
Please expand this a bit, so we won't have to reach to external sources.
> +#define PD_TIMER_SINK_WAIT_CAP 0
> +/* tPSSourceOff (Table 6-68 Time Values, USB PD3.1 Spec) */
> +#define PD_TIMER_PS_SOURCE_OFF 1
> +/* tCCDebounce (Table 4-33 CC Timing, USB Type-C Cable & Connector Spec Rel2.2) */
> +#define PD_TIMER_CC_DEBOUNCE 2
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
2024-09-12 23:26 ` Amit Sunil Dhamne
2024-09-13 4:34 ` Dmitry Baryshkov
@ 2024-09-16 16:05 ` Krzysztof Kozlowski
1 sibling, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-16 16:05 UTC (permalink / raw)
To: Amit Sunil Dhamne, Dmitry Baryshkov
Cc: robh+dt, krzysztof.kozlowski+dt, conor+dt, heikki.krogerus,
gregkh, linux-kernel, kyletso, rdbabiera, Badhri Jagan Sridharan,
linux-usb, devicetree
On 13/09/2024 01:26, Amit Sunil Dhamne wrote:
> Hi Dmitry,
>
> On 9/12/24 3:05 AM, Dmitry Baryshkov wrote:
>> On Tue, Sep 10, 2024 at 05:07:05PM GMT, Amit Sunil Dhamne wrote:
>>> This commit adds a new property "pd-timers" to enable setting of
>>> platform/board specific pd timer values for timers that have a range of
>>> acceptable values.
>>>
>>> Cc: Badhri Jagan Sridharan <badhri@google.com>
>>> Cc: linux-usb@vger.kernel.org
>>> Cc: devicetree@vger.kernel.org
>>> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
>>> ---
>>> .../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
>>> include/dt-bindings/usb/pd.h | 8 +++++++
>>> 2 files changed, 31 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>> index fb216ce68bb3..9be4ed12f13c 100644
>>> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>> @@ -253,6 +253,16 @@ properties:
>>>
>>> additionalProperties: false
>>>
>>> + pd-timers:
>>> + description: An array of u32 integers, where an even index (i) is the timer (referenced in
>>> + dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
>>> + "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
>>> + the appropriate value). For certain timers the PD spec defines a range rather than a fixed
>>> + value. The timers may need to be tuned based on the platform. This dt property allows the user
>>> + to assign specific values based on the platform. If these values are not explicitly defined,
>>> + TCPM will use a valid default value for such timers.
>>> + $ref: /schemas/types.yaml#/definitions/uint32-array
>> Is it really necessary to use the array property? I think it's easier
>> and more logical to define corresponding individual properties, one per
>> the timer.
>
> Thanks for the review. The reason I did it this way was for
> convenience. If in the future someone else wants add a new timer,
> it'd be convenient to just add it as a new macro definition in pd.h
> rather than having to define a new property each time, especially
> if folks want to add more timers (scales better).
> There are 3 timers already and I am working to add a fourth in a
> follow up patch if the current RFC gets accepted.
>
> Please let me know what do you think?
Binding is supposed to be complete. You already know this is not complete...
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
2024-09-13 4:34 ` Dmitry Baryshkov
@ 2024-09-16 16:33 ` Rob Herring
2024-09-16 23:52 ` Amit Sunil Dhamne
0 siblings, 1 reply; 12+ messages in thread
From: Rob Herring @ 2024-09-16 16:33 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Amit Sunil Dhamne, krzysztof.kozlowski+dt, conor+dt,
heikki.krogerus, gregkh, linux-kernel, kyletso, rdbabiera,
Badhri Jagan Sridharan, linux-usb, devicetree
On Fri, Sep 13, 2024 at 07:34:27AM +0300, Dmitry Baryshkov wrote:
> On Thu, Sep 12, 2024 at 04:26:25PM GMT, Amit Sunil Dhamne wrote:
> > Hi Dmitry,
> >
> > On 9/12/24 3:05 AM, Dmitry Baryshkov wrote:
> > > On Tue, Sep 10, 2024 at 05:07:05PM GMT, Amit Sunil Dhamne wrote:
> > > > This commit adds a new property "pd-timers" to enable setting of
> > > > platform/board specific pd timer values for timers that have a range of
> > > > acceptable values.
> > > >
> > > > Cc: Badhri Jagan Sridharan <badhri@google.com>
> > > > Cc: linux-usb@vger.kernel.org
> > > > Cc: devicetree@vger.kernel.org
> > > > Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
> > > > ---
> > > > .../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
> > > > include/dt-bindings/usb/pd.h | 8 +++++++
> > > > 2 files changed, 31 insertions(+)
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> > > > index fb216ce68bb3..9be4ed12f13c 100644
> > > > --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
> > > > +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
> > > > @@ -253,6 +253,16 @@ properties:
> > > > additionalProperties: false
> > > > + pd-timers:
> > > > + description: An array of u32 integers, where an even index (i) is the timer (referenced in
> > > > + dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
> > > > + "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
> > > > + the appropriate value). For certain timers the PD spec defines a range rather than a fixed
> > > > + value. The timers may need to be tuned based on the platform. This dt property allows the user
> > > > + to assign specific values based on the platform. If these values are not explicitly defined,
> > > > + TCPM will use a valid default value for such timers.
> > > > + $ref: /schemas/types.yaml#/definitions/uint32-array
> > > Is it really necessary to use the array property? I think it's easier
> > > and more logical to define corresponding individual properties, one per
> > > the timer.
> >
> > Thanks for the review. The reason I did it this way was for
> > convenience. If in the future someone else wants add a new timer,
> > it'd be convenient to just add it as a new macro definition in pd.h
> > rather than having to define a new property each time, especially
> > if folks want to add more timers (scales better).
> > There are 3 timers already and I am working to add a fourth in a
> > follow up patch if the current RFC gets accepted.
> >
> > Please let me know what do you think?
>
> I'd leave the decision to DT maintainers, but in my opinion multiple
> properties scale better. Having a single value per property is easier to
> handle rather than changing the tagged array.
I agree. And it avoids what looks like a made up number space with the
defines.
And note that an array of tuples is a matrix in DT defined types, not
an array.
Rob
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
2024-09-16 16:33 ` Rob Herring
@ 2024-09-16 23:52 ` Amit Sunil Dhamne
0 siblings, 0 replies; 12+ messages in thread
From: Amit Sunil Dhamne @ 2024-09-16 23:52 UTC (permalink / raw)
To: Rob Herring, Dmitry Baryshkov
Cc: krzysztof.kozlowski+dt, conor+dt, heikki.krogerus, gregkh,
linux-kernel, kyletso, rdbabiera, Badhri Jagan Sridharan,
linux-usb, devicetree
Hi Rob,
On 9/16/24 9:33 AM, Rob Herring wrote:
> On Fri, Sep 13, 2024 at 07:34:27AM +0300, Dmitry Baryshkov wrote:
>> On Thu, Sep 12, 2024 at 04:26:25PM GMT, Amit Sunil Dhamne wrote:
>>> Hi Dmitry,
>>>
>>> On 9/12/24 3:05 AM, Dmitry Baryshkov wrote:
>>>> On Tue, Sep 10, 2024 at 05:07:05PM GMT, Amit Sunil Dhamne wrote:
>>>>> This commit adds a new property "pd-timers" to enable setting of
>>>>> platform/board specific pd timer values for timers that have a range of
>>>>> acceptable values.
>>>>>
>>>>> Cc: Badhri Jagan Sridharan <badhri@google.com>
>>>>> Cc: linux-usb@vger.kernel.org
>>>>> Cc: devicetree@vger.kernel.org
>>>>> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
>>>>> ---
>>>>> .../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
>>>>> include/dt-bindings/usb/pd.h | 8 +++++++
>>>>> 2 files changed, 31 insertions(+)
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>>>> index fb216ce68bb3..9be4ed12f13c 100644
>>>>> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>>>> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>>>> @@ -253,6 +253,16 @@ properties:
>>>>> additionalProperties: false
>>>>> + pd-timers:
>>>>> + description: An array of u32 integers, where an even index (i) is the timer (referenced in
>>>>> + dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
>>>>> + "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
>>>>> + the appropriate value). For certain timers the PD spec defines a range rather than a fixed
>>>>> + value. The timers may need to be tuned based on the platform. This dt property allows the user
>>>>> + to assign specific values based on the platform. If these values are not explicitly defined,
>>>>> + TCPM will use a valid default value for such timers.
>>>>> + $ref: /schemas/types.yaml#/definitions/uint32-array
>>>> Is it really necessary to use the array property? I think it's easier
>>>> and more logical to define corresponding individual properties, one per
>>>> the timer.
>>> Thanks for the review. The reason I did it this way was for
>>> convenience. If in the future someone else wants add a new timer,
>>> it'd be convenient to just add it as a new macro definition in pd.h
>>> rather than having to define a new property each time, especially
>>> if folks want to add more timers (scales better).
>>> There are 3 timers already and I am working to add a fourth in a
>>> follow up patch if the current RFC gets accepted.
>>>
>>> Please let me know what do you think?
>> I'd leave the decision to DT maintainers, but in my opinion multiple
>> properties scale better. Having a single value per property is easier to
>> handle rather than changing the tagged array.
> I agree. And it avoids what looks like a made up number space with the
> defines.
>
> And note that an array of tuples is a matrix in DT defined types, not
> an array.
Thanks for the review! I will incorporate the suggested comments in the
next revision by creating a "single value per timer" property.
Regards,
Amit
>
> Rob
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
2024-09-16 16:05 ` Krzysztof Kozlowski
@ 2024-09-17 1:59 ` Amit Sunil Dhamne
2024-09-27 7:48 ` Krzysztof Kozlowski
0 siblings, 1 reply; 12+ messages in thread
From: Amit Sunil Dhamne @ 2024-09-17 1:59 UTC (permalink / raw)
To: Krzysztof Kozlowski, robh+dt, krzysztof.kozlowski+dt, conor+dt,
heikki.krogerus, gregkh
Cc: linux-kernel, kyletso, rdbabiera, Badhri Jagan Sridharan,
linux-usb, devicetree
Hi Krzysztof,
Thanks for the review!
On 9/16/24 9:05 AM, Krzysztof Kozlowski wrote:
> On 11/09/2024 02:07, Amit Sunil Dhamne wrote:
>> This commit adds a new property "pd-timers" to enable setting of
>> platform/board specific pd timer values for timers that have a range of
>> acceptable values.
>>
>> Cc: Badhri Jagan Sridharan <badhri@google.com>
>> Cc: linux-usb@vger.kernel.org
>> Cc: devicetree@vger.kernel.org
>> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
> Please work on mainline, not ancient tree. You cannot get my CC address
> like that from mainline.
I was working off gregkh's tree on usb-next branch as that's suggested
for USB development.
> It's not possible. So either you don't develop
> on mainline or you don't use get_maintainers.pl/b4/patman.
>
The above branch and even the tree on Linus' master branch has you
listed as a maintainer
(https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/MAINTAINERS#n17181).
I guess that's why the get_maintainers script probably returned your
email id when I ran it. Please let me know if I missed something :).
>> ---
>> .../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
>> include/dt-bindings/usb/pd.h | 8 +++++++
>> 2 files changed, 31 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>> index fb216ce68bb3..9be4ed12f13c 100644
>> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
>> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>> @@ -253,6 +253,16 @@ properties:
>>
>> additionalProperties: false
>>
>> + pd-timers:
>> + description: An array of u32 integers, where an even index (i) is the timer (referenced in
>> + dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
> timer of what? OS behavior?
In the context of USB Type C Power Delivery (PD), timers are run on the
typec protocol driver
(usb/typec/tcpm/tcpm.c).
These are used to keep track of min/max or range of time required to
enter a PD state with the
goal of a successful USB typec capabilities negotiation. Eg., the timer
PD_TIMER_SINK_WAIT_CAP (referred to as SinkWaitCapTimer in spec)would be
responsible to keep track of whether a power source sent us (as sink) PD
source capabilities pkts within 600ms (say), if yes, then we would
transition to the next state or do a state machine reset. USB PD 3.1
spec refers to these elements as timers and therefore referred to as
such here.
>> + "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
>> + the appropriate value). For certain timers the PD spec defines a range rather than a fixed
>> + value. The timers may need to be tuned based on the platform. This dt property allows the user
> Do not describe what DT is. We all know what DT properties allow.
> Instead describe how this relates to hardware or boards.
>
> All this is wrongly wrapped. See Coding style (and I am not telling you
> the value on purpose, so you will read the coding style) .
Ack. Thanks for pointing it out, I will fix both the above in the next
revision.
>
>> + to assign specific values based on the platform. If these values are not explicitly defined,
>> + TCPM will use a valid default value for such timers.
> And what is the default?
Defaults are given in (include/linux/usb/pd.h). But I guess I should
have probably mentioned
that here.
>
>> + $ref: /schemas/types.yaml#/definitions/uint32-array
> I guess you want matrix here.
Yes, I should have. Though, I will be re-implementing this such that
each timer is represented
as a separate property based on Rob and Dmitry's suggestion in
https://lore.kernel.org/lkml/20240916163328.GA394032-robh@kernel.org/ .
>> +
>> dependencies:
>> sink-vdos-v1: [ sink-vdos ]
>> sink-vdos: [ sink-vdos-v1 ]
>> @@ -478,3 +488,16 @@ examples:
>> };
>> };
>> };
>> +
>> + # USB-C connector with PD timers
>> + - |
>> + #include <dt-bindings/usb/pd.h>
>> + usb {
>> + connector {
>> + compatible = "usb-c-connector";
>> + label = "USB-C";
>> + pd-timers =
>> + <PD_TIMER_SINK_WAIT_CAP 600>,
>> + <PD_TIMER_CC_DEBOUNCE 170>;
> Incorporate it into existing example.
>
Ack.
>> + };
>> + };
>> diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
>> index e6526b138174..6c58c30f3f39 100644
>> --- a/include/dt-bindings/usb/pd.h
>> +++ b/include/dt-bindings/usb/pd.h
>> @@ -465,4 +465,12 @@
>> | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \
>> | ((gi) & 0x3f) << 1 | (ct))
>>
>> +/* PD Timer definitions */
>> +/* tTypeCSinkWaitCap (Table 6-68 Time Values, USB PD3.1 Spec) */
> Please expand this a bit, so we won't have to reach to external sources.
Ack.
I will incorporate all of your review comments.
Since you are no longer maintaining the
"OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" component, please let
me know
if you'd still like to be CC'ed in the subsequent revisions.
Thanks,
Amit
>> +#define PD_TIMER_SINK_WAIT_CAP 0
>> +/* tPSSourceOff (Table 6-68 Time Values, USB PD3.1 Spec) */
>> +#define PD_TIMER_PS_SOURCE_OFF 1
>> +/* tCCDebounce (Table 4-33 CC Timing, USB Type-C Cable & Connector Spec Rel2.2) */
>> +#define PD_TIMER_CC_DEBOUNCE 2
>
> Best regards,
> Krzysztof
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
2024-09-17 1:59 ` Amit Sunil Dhamne
@ 2024-09-27 7:48 ` Krzysztof Kozlowski
2024-10-07 19:45 ` Amit Sunil Dhamne
0 siblings, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-09-27 7:48 UTC (permalink / raw)
To: Amit Sunil Dhamne, robh+dt, krzysztof.kozlowski+dt, conor+dt,
heikki.krogerus, gregkh
Cc: linux-kernel, kyletso, rdbabiera, Badhri Jagan Sridharan,
linux-usb, devicetree
On 17/09/2024 03:59, Amit Sunil Dhamne wrote:
> Hi Krzysztof,
>
> Thanks for the review!
>
> On 9/16/24 9:05 AM, Krzysztof Kozlowski wrote:
>> On 11/09/2024 02:07, Amit Sunil Dhamne wrote:
>>> This commit adds a new property "pd-timers" to enable setting of
>>> platform/board specific pd timer values for timers that have a range of
>>> acceptable values.
>>>
>>> Cc: Badhri Jagan Sridharan <badhri@google.com>
>>> Cc: linux-usb@vger.kernel.org
>>> Cc: devicetree@vger.kernel.org
>>> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
>> Please work on mainline, not ancient tree. You cannot get my CC address
>> like that from mainline.
> I was working off gregkh's tree on usb-next branch as that's suggested
> for USB development.
>
>
>> It's not possible. So either you don't develop
>> on mainline or you don't use get_maintainers.pl/b4/patman.
>>
> The above branch and even the tree on Linus' master branch has you
> listed as a maintainer
> (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/MAINTAINERS#n17181).
> I guess that's why the get_maintainers script probably returned your
> email id when I ran it. Please let me know if I missed something :).
You really just skimmed over my email... I know how maintainers work.
So I REPEAT: You cannot get this email address you Cced. Point me to the
line in your tree having such email. The one here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/MAINTAINERS#n17181
does not have it.
>
>
>>> ---
>>> .../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
>>> include/dt-bindings/usb/pd.h | 8 +++++++
>>> 2 files changed, 31 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>> index fb216ce68bb3..9be4ed12f13c 100644
>>> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>> @@ -253,6 +253,16 @@ properties:
>>>
>>> additionalProperties: false
>>>
>>> + pd-timers:
>>> + description: An array of u32 integers, where an even index (i) is the timer (referenced in
>>> + dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
>> timer of what? OS behavior?
> In the context of USB Type C Power Delivery (PD), timers are run on the
> typec protocol driver
> (usb/typec/tcpm/tcpm.c).
> These are used to keep track of min/max or range of time required to
> enter a PD state with the
> goal of a successful USB typec capabilities negotiation. Eg., the timer
> PD_TIMER_SINK_WAIT_CAP (referred to as SinkWaitCapTimer in spec)would be
> responsible to keep track of whether a power source sent us (as sink) PD
> source capabilities pkts within 600ms (say), if yes, then we would
> transition to the next state or do a state machine reset. USB PD 3.1
> spec refers to these elements as timers and therefore referred to as
> such here.
>
>
>>> + "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
>>> + the appropriate value). For certain timers the PD spec defines a range rather than a fixed
>>> + value. The timers may need to be tuned based on the platform. This dt property allows the user
>> Do not describe what DT is. We all know what DT properties allow.
>> Instead describe how this relates to hardware or boards.
>>
>> All this is wrongly wrapped. See Coding style (and I am not telling you
>> the value on purpose, so you will read the coding style) .
>
>
> Ack. Thanks for pointing it out, I will fix both the above in the next
> revision.
>
>
>>
>>> + to assign specific values based on the platform. If these values are not explicitly defined,
>>> + TCPM will use a valid default value for such timers.
>> And what is the default?
>
> Defaults are given in (include/linux/usb/pd.h). But I guess I should
> have probably mentioned
> that here.
>
>
>>
>>> + $ref: /schemas/types.yaml#/definitions/uint32-array
>> I guess you want matrix here.
>
> Yes, I should have. Though, I will be re-implementing this such that
> each timer is represented
> as a separate property based on Rob and Dmitry's suggestion in
> https://lore.kernel.org/lkml/20240916163328.GA394032-robh@kernel.org/ .
>
>>> +
>>> dependencies:
>>> sink-vdos-v1: [ sink-vdos ]
>>> sink-vdos: [ sink-vdos-v1 ]
>>> @@ -478,3 +488,16 @@ examples:
>>> };
>>> };
>>> };
>>> +
>>> + # USB-C connector with PD timers
>>> + - |
>>> + #include <dt-bindings/usb/pd.h>
>>> + usb {
>>> + connector {
>>> + compatible = "usb-c-connector";
>>> + label = "USB-C";
>>> + pd-timers =
>>> + <PD_TIMER_SINK_WAIT_CAP 600>,
>>> + <PD_TIMER_CC_DEBOUNCE 170>;
>> Incorporate it into existing example.
>>
> Ack.
>
>
>>> + };
>>> + };
>>> diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
>>> index e6526b138174..6c58c30f3f39 100644
>>> --- a/include/dt-bindings/usb/pd.h
>>> +++ b/include/dt-bindings/usb/pd.h
>>> @@ -465,4 +465,12 @@
>>> | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \
>>> | ((gi) & 0x3f) << 1 | (ct))
>>>
>>> +/* PD Timer definitions */
>>> +/* tTypeCSinkWaitCap (Table 6-68 Time Values, USB PD3.1 Spec) */
>> Please expand this a bit, so we won't have to reach to external sources.
>
> Ack.
>
> I will incorporate all of your review comments.
>
> Since you are no longer maintaining the
> "OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" component, please let
Who said that? You CC wrong emails because either you work on ancient
tree or you do not use tools like get_maintainers.pl or b4. You cannot
get this email from proper process. It is not physically possible
because that email is nowhere mentioned.
> me know
> if you'd still like to be CC'ed in the subsequent revisions.
Damn, just use standard tools. You are not supposed to invent maintainers.
<form letter>
Please use scripts/get_maintainers.pl to get a list of necessary people
and lists to CC (and consider --no-git-fallback argument). It might
happen, that command when run on an older kernel, gives you outdated
entries. Therefore please be sure you base your patches on recent Linux
kernel.
Tools like b4 or scripts/get_maintainer.pl provide you proper list of
people, so fix your workflow. Tools might also fail if you work on some
ancient tree (don't, instead use mainline) or work on fork of kernel
(don't, instead use mainline). Just use b4 and everything should be
fine, although remember about `b4 prep --auto-to-cc` if you added new
patches to the patchset.
</form letter>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC 1/2] dt-bindings: connector: Add property to set pd timer values
2024-09-27 7:48 ` Krzysztof Kozlowski
@ 2024-10-07 19:45 ` Amit Sunil Dhamne
0 siblings, 0 replies; 12+ messages in thread
From: Amit Sunil Dhamne @ 2024-10-07 19:45 UTC (permalink / raw)
To: Krzysztof Kozlowski, robh+dt, krzysztof.kozlowski+dt, conor+dt,
heikki.krogerus, gregkh
Cc: linux-kernel, kyletso, rdbabiera, Badhri Jagan Sridharan,
linux-usb, devicetree
Hi Krzysztof,
On 9/27/24 12:48 AM, Krzysztof Kozlowski wrote:
> On 17/09/2024 03:59, Amit Sunil Dhamne wrote:
>> Hi Krzysztof,
>>
>> Thanks for the review!
>>
>> On 9/16/24 9:05 AM, Krzysztof Kozlowski wrote:
>>> On 11/09/2024 02:07, Amit Sunil Dhamne wrote:
>>>> This commit adds a new property "pd-timers" to enable setting of
>>>> platform/board specific pd timer values for timers that have a range of
>>>> acceptable values.
>>>>
>>>> Cc: Badhri Jagan Sridharan <badhri@google.com>
>>>> Cc: linux-usb@vger.kernel.org
>>>> Cc: devicetree@vger.kernel.org
>>>> Signed-off-by: Amit Sunil Dhamne <amitsd@google.com>
>>> Please work on mainline, not ancient tree. You cannot get my CC address
>>> like that from mainline.
>> I was working off gregkh's tree on usb-next branch as that's suggested
>> for USB development.
>>
>>
>>> It's not possible. So either you don't develop
>>> on mainline or you don't use get_maintainers.pl/b4/patman.
>>>
>> The above branch and even the tree on Linus' master branch has you
>> listed as a maintainer
>> (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/MAINTAINERS#n17181).
>> I guess that's why the get_maintainers script probably returned your
>> email id when I ran it. Please let me know if I missed something :).
> You really just skimmed over my email... I know how maintainers work.
>
> So I REPEAT: You cannot get this email address you Cced. Point me to the
> line in your tree having such email. The one here:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/MAINTAINERS#n17181
>
> does not have it.
Sorry I misunderstood. Will fix it henceforth in subsequent work.
>>
>>>> ---
>>>> .../bindings/connector/usb-connector.yaml | 23 +++++++++++++++++++
>>>> include/dt-bindings/usb/pd.h | 8 +++++++
>>>> 2 files changed, 31 insertions(+)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>>> index fb216ce68bb3..9be4ed12f13c 100644
>>>> --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>>> +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml
>>>> @@ -253,6 +253,16 @@ properties:
>>>>
>>>> additionalProperties: false
>>>>
>>>> + pd-timers:
>>>> + description: An array of u32 integers, where an even index (i) is the timer (referenced in
>>>> + dt-bindings/usb/pd.h) and the odd index (i+1) is the timer value in ms (refer
>>> timer of what? OS behavior?
>> In the context of USB Type C Power Delivery (PD), timers are run on the
>> typec protocol driver
>> (usb/typec/tcpm/tcpm.c).
>> These are used to keep track of min/max or range of time required to
>> enter a PD state with the
>> goal of a successful USB typec capabilities negotiation. Eg., the timer
>> PD_TIMER_SINK_WAIT_CAP (referred to as SinkWaitCapTimer in spec)would be
>> responsible to keep track of whether a power source sent us (as sink) PD
>> source capabilities pkts within 600ms (say), if yes, then we would
>> transition to the next state or do a state machine reset. USB PD 3.1
>> spec refers to these elements as timers and therefore referred to as
>> such here.
>>
>>
>>>> + "Table 6-68 Time Values" of "USB Power Delivery Specification Revision 3.0, Version 1.2 " for
>>>> + the appropriate value). For certain timers the PD spec defines a range rather than a fixed
>>>> + value. The timers may need to be tuned based on the platform. This dt property allows the user
>>> Do not describe what DT is. We all know what DT properties allow.
>>> Instead describe how this relates to hardware or boards.
>>>
>>> All this is wrongly wrapped. See Coding style (and I am not telling you
>>> the value on purpose, so you will read the coding style) .
>>
>> Ack. Thanks for pointing it out, I will fix both the above in the next
>> revision.
>>
>>
>>>> + to assign specific values based on the platform. If these values are not explicitly defined,
>>>> + TCPM will use a valid default value for such timers.
>>> And what is the default?
>> Defaults are given in (include/linux/usb/pd.h). But I guess I should
>> have probably mentioned
>> that here.
>>
>>
>>>> + $ref: /schemas/types.yaml#/definitions/uint32-array
>>> I guess you want matrix here.
>> Yes, I should have. Though, I will be re-implementing this such that
>> each timer is represented
>> as a separate property based on Rob and Dmitry's suggestion in
>> https://lore.kernel.org/lkml/20240916163328.GA394032-robh@kernel.org/ .
>>
>>>> +
>>>> dependencies:
>>>> sink-vdos-v1: [ sink-vdos ]
>>>> sink-vdos: [ sink-vdos-v1 ]
>>>> @@ -478,3 +488,16 @@ examples:
>>>> };
>>>> };
>>>> };
>>>> +
>>>> + # USB-C connector with PD timers
>>>> + - |
>>>> + #include <dt-bindings/usb/pd.h>
>>>> + usb {
>>>> + connector {
>>>> + compatible = "usb-c-connector";
>>>> + label = "USB-C";
>>>> + pd-timers =
>>>> + <PD_TIMER_SINK_WAIT_CAP 600>,
>>>> + <PD_TIMER_CC_DEBOUNCE 170>;
>>> Incorporate it into existing example.
>>>
>> Ack.
>>
>>
>>>> + };
>>>> + };
>>>> diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h
>>>> index e6526b138174..6c58c30f3f39 100644
>>>> --- a/include/dt-bindings/usb/pd.h
>>>> +++ b/include/dt-bindings/usb/pd.h
>>>> @@ -465,4 +465,12 @@
>>>> | ((vbm) & 0x3) << 15 | (curr) << 14 | ((vbi) & 0x3f) << 7 \
>>>> | ((gi) & 0x3f) << 1 | (ct))
>>>>
>>>> +/* PD Timer definitions */
>>>> +/* tTypeCSinkWaitCap (Table 6-68 Time Values, USB PD3.1 Spec) */
>>> Please expand this a bit, so we won't have to reach to external sources.
>> Ack.
>>
>> I will incorporate all of your review comments.
>>
>> Since you are no longer maintaining the
>> "OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" component, please let
> Who said that? You CC wrong emails because either you work on ancient
> tree or you do not use tools like get_maintainers.pl or b4. You cannot
> get this email from proper process. It is not physically possible
> because that email is nowhere mentioned.
>
>> me know
>> if you'd still like to be CC'ed in the subsequent revisions.
>
> Damn, just use standard tools. You are not supposed to invent maintainers.
>
> <form letter>
> Please use scripts/get_maintainers.pl to get a list of necessary people
> and lists to CC (and consider --no-git-fallback argument). It might
> happen, that command when run on an older kernel, gives you outdated
> entries. Therefore please be sure you base your patches on recent Linux
> kernel.
>
> Tools like b4 or scripts/get_maintainer.pl provide you proper list of
> people, so fix your workflow. Tools might also fail if you work on some
> ancient tree (don't, instead use mainline) or work on fork of kernel
> (don't, instead use mainline). Just use b4 and everything should be
> fine, although remember about `b4 prep --auto-to-cc` if you added new
> patches to the patchset.
> </form letter>
>
> Best regards,
> Krzysztof
Thanks for the tips! I will make sure to follow these henceforth.
Regards,
Amit
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-10-07 19:45 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240911000715.554184-1-amitsd@google.com>
2024-09-11 0:07 ` [RFC 1/2] dt-bindings: connector: Add property to set pd timer values Amit Sunil Dhamne
2024-09-12 10:05 ` Dmitry Baryshkov
2024-09-12 23:26 ` Amit Sunil Dhamne
2024-09-13 4:34 ` Dmitry Baryshkov
2024-09-16 16:33 ` Rob Herring
2024-09-16 23:52 ` Amit Sunil Dhamne
2024-09-16 16:05 ` Krzysztof Kozlowski
2024-09-16 16:05 ` Krzysztof Kozlowski
2024-09-17 1:59 ` Amit Sunil Dhamne
2024-09-27 7:48 ` Krzysztof Kozlowski
2024-10-07 19:45 ` Amit Sunil Dhamne
2024-09-11 0:07 ` [RFC 2/2] usb: typec: tcpm: Add support for pd-timers DT property Amit Sunil Dhamne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).