Re: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* properties
On 04/13/2018 08:42 PM, Jun Li wrote: Hi Guenter, -Original Message- From: Guenter Roeck [mailto:groe...@gmail.com] On Behalf Of Guenter Roeck Sent: 2018年4月14日 11:03 To: Jun LiCc: gre...@linuxfoundation.org; robh...@kernel.org; heikki.kroge...@linux.intel.com; hdego...@redhat.com; rmf...@gmail.com; yueyao@gmail.com; linux-usb@vger.kernel.org; dl-linux-imx Subject: Re: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* properties On 04/13/2018 04:31 PM, Jun Li wrote: -Original Message- From: Guenter Roeck [mailto:li...@roeck-us.net] Sent: 2018年4月14日 0:04 To: Jun Li Cc: gre...@linuxfoundation.org; robh...@kernel.org; heikki.kroge...@linux.intel.com; hdego...@redhat.com; rmf...@gmail.com; yueyao@gmail.com; linux-usb@vger.kernel.org; dl-linux-imx Subject: Re: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* properties On Fri, Apr 13, 2018 at 10:18:43PM +0800, Li Jun wrote: Remove max-sink-* properties since they are deprecated. Reviewed-by: Rob Herring Reviewed-by: Hans de Goede Signed-off-by: Li Jun --- Documentation/devicetree/bindings/usb/fcs,fusb302.txt | 6 -- 1 file changed, 6 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt index 472facf..6087dc7 100644 --- a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt +++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt @@ -6,12 +6,6 @@ Required properties : - interrupts : Interrupt specifier Optional properties : -- fcs,max-sink-microvolt : Maximum voltage to negotiate when configured as sink -- fcs,max-sink-microamp : Maximum current to negotiate when configured as sink -- fcs,max-sink-microwatt : Maximum power to negotiate when configured as sink - If this is less then max-sink-microvolt * - max-sink-microamp then the configured current will - be clamped. Is it acceptable to just remove properties ? What else you suggest I should do? also add document here to explain why remove them? I would suggest to either wait for Rob's feedback or check how other bindings handle deprecated properties. Rob already reviewed this patch and gave his reviewed-by[1], you can see it in the patch tags. [1]https://www.spinics.net/lists/devicetree/msg221601.html Ah, ok. Guess you are ok then. Sorry, should have noticed. Guenter -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* properties
Hi Guenter, > -Original Message- > From: Guenter Roeck [mailto:groe...@gmail.com] On Behalf Of Guenter Roeck > Sent: 2018年4月14日 11:03 > To: Jun Li> Cc: gre...@linuxfoundation.org; robh...@kernel.org; > heikki.kroge...@linux.intel.com; hdego...@redhat.com; rmf...@gmail.com; > yueyao@gmail.com; linux-usb@vger.kernel.org; dl-linux-imx > > Subject: Re: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* > properties > > On 04/13/2018 04:31 PM, Jun Li wrote: > > > >> -Original Message- > >> From: Guenter Roeck [mailto:li...@roeck-us.net] > >> Sent: 2018年4月14日 0:04 > >> To: Jun Li > >> Cc: gre...@linuxfoundation.org; robh...@kernel.org; > >> heikki.kroge...@linux.intel.com; hdego...@redhat.com; > >> rmf...@gmail.com; yueyao@gmail.com; linux-usb@vger.kernel.org; > >> dl-linux-imx > >> Subject: Re: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove > >> max-sink-* properties > >> > >> On Fri, Apr 13, 2018 at 10:18:43PM +0800, Li Jun wrote: > >>> Remove max-sink-* properties since they are deprecated. > >>> > >>> Reviewed-by: Rob Herring > >>> Reviewed-by: Hans de Goede > >>> Signed-off-by: Li Jun > >>> --- > >>> Documentation/devicetree/bindings/usb/fcs,fusb302.txt | 6 -- > >>> 1 file changed, 6 deletions(-) > >>> > >>> diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > >> b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > >>> index 472facf..6087dc7 100644 > >>> --- a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > >>> +++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > >>> @@ -6,12 +6,6 @@ Required properties : > >>> - interrupts : Interrupt specifier > >>> > >>> Optional properties : > >>> -- fcs,max-sink-microvolt : Maximum voltage to negotiate when > >>> configured as > >> sink > >>> -- fcs,max-sink-microamp : Maximum current to negotiate when > >>> configured > >> as sink > >>> -- fcs,max-sink-microwatt : Maximum power to negotiate when > >>> configured as > >> sink > >>> -If this is less then max-sink-microvolt * > >>> -max-sink-microamp then the configured current will > >>> -be clamped. > >> > >> Is it acceptable to just remove properties ? > > > > What else you suggest I should do? also add document here to explain > > why remove them? > > > I would suggest to either wait for Rob's feedback or check how other bindings > handle deprecated properties. Rob already reviewed this patch and gave his reviewed-by[1], you can see it in the patch tags. [1]https://www.spinics.net/lists/devicetree/msg221601.html Thanks Jun > > Guenter
Re: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* properties
On 04/13/2018 04:31 PM, Jun Li wrote: -Original Message- From: Guenter Roeck [mailto:li...@roeck-us.net] Sent: 2018年4月14日 0:04 To: Jun LiCc: gre...@linuxfoundation.org; robh...@kernel.org; heikki.kroge...@linux.intel.com; hdego...@redhat.com; rmf...@gmail.com; yueyao@gmail.com; linux-usb@vger.kernel.org; dl-linux-imx Subject: Re: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* properties On Fri, Apr 13, 2018 at 10:18:43PM +0800, Li Jun wrote: Remove max-sink-* properties since they are deprecated. Reviewed-by: Rob Herring Reviewed-by: Hans de Goede Signed-off-by: Li Jun --- Documentation/devicetree/bindings/usb/fcs,fusb302.txt | 6 -- 1 file changed, 6 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt index 472facf..6087dc7 100644 --- a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt +++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt @@ -6,12 +6,6 @@ Required properties : - interrupts : Interrupt specifier Optional properties : -- fcs,max-sink-microvolt : Maximum voltage to negotiate when configured as sink -- fcs,max-sink-microamp : Maximum current to negotiate when configured as sink -- fcs,max-sink-microwatt : Maximum power to negotiate when configured as sink - If this is less then max-sink-microvolt * - max-sink-microamp then the configured current will - be clamped. Is it acceptable to just remove properties ? What else you suggest I should do? also add document here to explain why remove them? I would suggest to either wait for Rob's feedback or check how other bindings handle deprecated properties. Guenter -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v4 1/5] usb: typec: tcpm: pdo matching optimization
> -Original Message- > From: Hans de Goede [mailto:hdego...@redhat.com] > Sent: 2018年4月14日 0:54 > To: Guenter Roeck; Jun Li > Cc: gre...@linuxfoundation.org; robh...@kernel.org; > heikki.kroge...@linux.intel.com; rmf...@gmail.com; yueyao@gmail.com; > linux-usb@vger.kernel.org; dl-linux-imx > Subject: Re: [PATCH v4 1/5] usb: typec: tcpm: pdo matching optimization > > Hi, > > On 13-04-18 17:58, Guenter Roeck wrote: > > On Fri, Apr 13, 2018 at 10:18:41PM +0800, Li Jun wrote: > >> This patch is a combination of commit 57e6f0d7b804 > >> ("typec: tcpm: Only request matching pdos") and source pdo selection > >> optimization based on it, instead of only compare between the same > >> pdo type of sink and source, we should check source pdo voltage range > >> is within the voltage range of one sink pdo. > >> > >> Reviewed-by: Hans de Goede > >> Signed-off-by: Li Jun > >> --- > >> drivers/usb/typec/tcpm.c | 102 > ++- > >> 1 file changed, 65 insertions(+), 37 deletions(-) > >> > >> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c > >> index 677d121..c127339 100644 > >> --- a/drivers/usb/typec/tcpm.c > >> +++ b/drivers/usb/typec/tcpm.c > >> @@ -1772,40 +1772,65 @@ static int tcpm_pd_check_request(struct > tcpm_port *port) > >>return 0; > >> } > >> > >> -static int tcpm_pd_select_pdo(struct tcpm_port *port) > >> +#define min_power(x, y) min(pdo_max_power(x), pdo_max_power(y)) > >> +#define min_current(x, y) min(pdo_max_current(x), > >> +pdo_max_current(y)) > >> + > >> +static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, > >> +int *src_pdo) > >> { > >> - unsigned int i, max_mw = 0, max_mv = 0; > >> + unsigned int i, j, max_src_mv = 0, min_src_mv = 0, max_mw = 0, > >> + max_mv = 0, src_mw = 0, src_ma = 0, max_snk_mv = 0, > >> + min_snk_mv = 0; > >>int ret = -EINVAL; > >> > >>/* > >> - * Select the source PDO providing the most power while staying within > >> - * the board's voltage limits. Prefer PDO providing exp > >> + * Select the source PDO providing the most power which has a > >> + * matchig sink cap. > >> */ > >>for (i = 0; i < port->nr_source_caps; i++) { > >>u32 pdo = port->source_caps[i]; > >>enum pd_pdo_type type = pdo_type(pdo); > >> - unsigned int mv, ma, mw; > >> > >> - if (type == PDO_TYPE_FIXED) > >> - mv = pdo_fixed_voltage(pdo); > >> - else > >> - mv = pdo_min_voltage(pdo); > >> + if (type == PDO_TYPE_FIXED) { > >> + max_src_mv = pdo_fixed_voltage(pdo); > >> + min_src_mv = max_src_mv; > >> + } else { > >> + max_src_mv = pdo_max_voltage(pdo); > >> + min_src_mv = pdo_min_voltage(pdo); > >> + } > >> > >>if (type == PDO_TYPE_BATT) { > >> - mw = pdo_max_power(pdo); > >> + src_mw = pdo_max_power(pdo); > >>} else { > >> - ma = min(pdo_max_current(pdo), > >> - port->max_snk_ma); > >> - mw = ma * mv / 1000; > >> + src_ma = pdo_max_current(pdo); > >> + src_mw = src_ma * min_src_mv / 1000; > >>} > >> > >> - /* Perfer higher voltages if available */ > >> - if ((mw > max_mw || (mw == max_mw && mv > max_mv)) && > >> - mv <= port->max_snk_mv) { > >> - ret = i; > >> - max_mw = mw; > >> - max_mv = mv; > >> + for (j = 0; j < port->nr_snk_pdo; j++) { > >> + pdo = port->snk_pdo[j]; > >> + > >> + if (pdo_type(pdo) == PDO_TYPE_FIXED) { > >> + min_snk_mv = pdo_fixed_voltage(pdo); > >> + max_snk_mv = pdo_fixed_voltage(pdo); > >> + } else { > >> + min_snk_mv = pdo_min_voltage(pdo); > >> + max_snk_mv = pdo_max_voltage(pdo); > >> + } > >> + > >> + if (max_src_mv <= max_snk_mv && > >> + min_src_mv >= min_snk_mv) { > >> + /* Prefer higher voltages if available */ > >> + if ((src_mw == max_mw && min_src_mv > max_mv) || > >> + src_mw > max_mw) { > >> + *src_pdo = i; > >> + *sink_pdo = j; > >> + max_mw = src_mw; > >> + max_mv = min_src_mv; > >> + } > >> + break; > >> + } > >>} > >> + > > > > Nitpick, but that added empty
RE: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* properties
> -Original Message- > From: Guenter Roeck [mailto:li...@roeck-us.net] > Sent: 2018年4月14日 0:04 > To: Jun Li> Cc: gre...@linuxfoundation.org; robh...@kernel.org; > heikki.kroge...@linux.intel.com; hdego...@redhat.com; rmf...@gmail.com; > yueyao@gmail.com; linux-usb@vger.kernel.org; dl-linux-imx > > Subject: Re: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* > properties > > On Fri, Apr 13, 2018 at 10:18:43PM +0800, Li Jun wrote: > > Remove max-sink-* properties since they are deprecated. > > > > Reviewed-by: Rob Herring > > Reviewed-by: Hans de Goede > > Signed-off-by: Li Jun > > --- > > Documentation/devicetree/bindings/usb/fcs,fusb302.txt | 6 -- > > 1 file changed, 6 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > > index 472facf..6087dc7 100644 > > --- a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > > +++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > > @@ -6,12 +6,6 @@ Required properties : > > - interrupts : Interrupt specifier > > > > Optional properties : > > -- fcs,max-sink-microvolt : Maximum voltage to negotiate when configured as > sink > > -- fcs,max-sink-microamp : Maximum current to negotiate when configured > as sink > > -- fcs,max-sink-microwatt : Maximum power to negotiate when configured as > sink > > - If this is less then max-sink-microvolt * > > - max-sink-microamp then the configured current will > > - be clamped. > > Is it acceptable to just remove properties ? What else you suggest I should do? also add document here to explain why remove them? Thanks Jun > > > - fcs,operating-sink-microwatt : > >Minimum amount of power accepted from a sink > >when negotiating > > -- > > 2.7.4 > > N�Р骒r��yb�X�肚�v�^�)藓{.n�+�伐�{焙柒��^n�r■�z���h�ㄨ��&Ⅷ�G���h�(�茛j"���m赇z罐��帼f"�h���~�m�
RE: [PATCH v4 2/5] usb: typec: fusb302: remove max_snk_* for sink config
Hi > -Original Message- > From: Guenter Roeck [mailto:li...@roeck-us.net] > Sent: 2018年4月14日 0:03 > To: Jun Li> Cc: gre...@linuxfoundation.org; robh...@kernel.org; > heikki.kroge...@linux.intel.com; hdego...@redhat.com; rmf...@gmail.com; > yueyao@gmail.com; linux-usb@vger.kernel.org; dl-linux-imx > > Subject: Re: [PATCH v4 2/5] usb: typec: fusb302: remove max_snk_* for sink > config > > On Fri, Apr 13, 2018 at 10:18:42PM +0800, Li Jun wrote: > > Since max_snk_* is to be deprecated, so remove max_snk_* by adding a > > variable PDO for sink config. > > max_snk or max_sink ? .max_snk_ma/mv/mw > > > > > Reviewed-by: Hans de Goede > > Signed-off-by: Li Jun > > --- > > drivers/usb/typec/fusb302/fusb302.c | 34 > > -- > > 1 file changed, 20 insertions(+), 14 deletions(-) > > > > diff --git a/drivers/usb/typec/fusb302/fusb302.c > > b/drivers/usb/typec/fusb302/fusb302.c > > index 7036171..893f9e5 100644 > > --- a/drivers/usb/typec/fusb302/fusb302.c > > +++ b/drivers/usb/typec/fusb302/fusb302.c > > @@ -120,6 +120,7 @@ struct fusb302_chip { > > enum typec_cc_polarity cc_polarity; > > enum typec_cc_status cc1; > > enum typec_cc_status cc2; > > + u32 snk_pdo[PDO_MAX_OBJECTS]; > > > > #ifdef CONFIG_DEBUG_FS > > struct dentry *dentry; > > @@ -1212,11 +1213,6 @@ static const u32 snk_pdo[] = { static const > > struct tcpc_config fusb302_tcpc_config = { > > .src_pdo = src_pdo, > > .nr_src_pdo = ARRAY_SIZE(src_pdo), > > - .snk_pdo = snk_pdo, > > - .nr_snk_pdo = ARRAY_SIZE(snk_pdo), > > - .max_snk_mv = 5000, > > - .max_snk_ma = 3000, > > - .max_snk_mw = 15000, > > .operating_snk_mw = 2500, > > .type = TYPEC_PORT_DRP, > > .data = TYPEC_PORT_DRD, > > @@ -1756,6 +1752,21 @@ static int init_gpio(struct fusb302_chip *chip) > > return 0; > > } > > > > +static int fusb302_composite_snk_pdo_array(struct fusb302_chip *chip) > > +{ > > + struct device *dev = chip->dev; > > + u32 max_uv, max_ua; > > + > > + chip->snk_pdo[0] = PDO_FIXED(5000, 400, PDO_FIXED_FLAGS); > > + > > + if (device_property_read_u32(dev, "fcs,max-sink-microvolt", _uv) || > > + device_property_read_u32(dev, "fcs,max-sink-microamp", _ua)) > > + return 1; > > Aren't those properties removed in the next patch ? If this is on purpose, it > should be documented. I will add comment to explain those properties are no longer needed, but to preserve compatibility, we covert it to be a var pdo for existing user. Thanks Jun > > > + > > + chip->snk_pdo[1] = PDO_VAR(5000, max_uv / 1000, max_ua / 1000); > > + return 2; > > +} > > + > > static int fusb302_probe(struct i2c_client *client, > > const struct i2c_device_id *id) > > { > > @@ -1784,18 +1795,13 @@ static int fusb302_probe(struct i2c_client *client, > > chip->tcpc_dev.config = >tcpc_config; > > mutex_init(>lock); > > > > - if (!device_property_read_u32(dev, "fcs,max-sink-microvolt", )) > > - chip->tcpc_config.max_snk_mv = v / 1000; > > - > > - if (!device_property_read_u32(dev, "fcs,max-sink-microamp", )) > > - chip->tcpc_config.max_snk_ma = v / 1000; > > - > > - if (!device_property_read_u32(dev, "fcs,max-sink-microwatt", )) > > - chip->tcpc_config.max_snk_mw = v / 1000; > > - > > if (!device_property_read_u32(dev, "fcs,operating-sink-microwatt", )) > > chip->tcpc_config.operating_snk_mw = v / 1000; > > > > + /* Composite sink PDO */ > > + chip->tcpc_config.nr_snk_pdo = fusb302_composite_snk_pdo_array(chip); > > + chip->tcpc_config.snk_pdo = chip->snk_pdo; > > + > > /* > > * Devicetree platforms should get extcon via phandle (not yet > > * supported). On ACPI platforms, we get the name from a device prop. > > -- > > 2.7.4 > > N�Р骒r��yb�X�肚�v�^�)藓{.n�+�伐�{焙柒��^n�r■�z���h�ㄨ��&Ⅷ�G���h�(�茛j"���m赇z罐��帼f"�h���~�m�
RE: [PATCH v4 1/5] usb: typec: tcpm: pdo matching optimization
Hi > -Original Message- > From: Guenter Roeck [mailto:li...@roeck-us.net] > Sent: 2018年4月13日 23:58 > To: Jun Li> Cc: gre...@linuxfoundation.org; robh...@kernel.org; > heikki.kroge...@linux.intel.com; hdego...@redhat.com; rmf...@gmail.com; > yueyao@gmail.com; linux-usb@vger.kernel.org; dl-linux-imx > > Subject: Re: [PATCH v4 1/5] usb: typec: tcpm: pdo matching optimization > > On Fri, Apr 13, 2018 at 10:18:41PM +0800, Li Jun wrote: > > This patch is a combination of commit 57e6f0d7b804 > > ("typec: tcpm: Only request matching pdos") and source pdo selection > > optimization based on it, instead of only compare between the same pdo > > type of sink and source, we should check source pdo voltage range is > > within the voltage range of one sink pdo. > > > > Reviewed-by: Hans de Goede > > Signed-off-by: Li Jun > > --- > > drivers/usb/typec/tcpm.c | 102 > > ++- > > 1 file changed, 65 insertions(+), 37 deletions(-) > > > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index > > 677d121..c127339 100644 > > --- a/drivers/usb/typec/tcpm.c > > +++ b/drivers/usb/typec/tcpm.c > > @@ -1772,40 +1772,65 @@ static int tcpm_pd_check_request(struct > tcpm_port *port) > > return 0; > > } > > > > -static int tcpm_pd_select_pdo(struct tcpm_port *port) > > +#define min_power(x, y) min(pdo_max_power(x), pdo_max_power(y)) > > +#define min_current(x, y) min(pdo_max_current(x), pdo_max_current(y)) > > + > > +static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, > > + int *src_pdo) > > { > > - unsigned int i, max_mw = 0, max_mv = 0; > > + unsigned int i, j, max_src_mv = 0, min_src_mv = 0, max_mw = 0, > > +max_mv = 0, src_mw = 0, src_ma = 0, max_snk_mv = 0, > > +min_snk_mv = 0; > > int ret = -EINVAL; > > > > /* > > -* Select the source PDO providing the most power while staying within > > -* the board's voltage limits. Prefer PDO providing exp > > +* Select the source PDO providing the most power which has a > > +* matchig sink cap. > > */ > > for (i = 0; i < port->nr_source_caps; i++) { > > u32 pdo = port->source_caps[i]; > > enum pd_pdo_type type = pdo_type(pdo); > > - unsigned int mv, ma, mw; > > > > - if (type == PDO_TYPE_FIXED) > > - mv = pdo_fixed_voltage(pdo); > > - else > > - mv = pdo_min_voltage(pdo); > > + if (type == PDO_TYPE_FIXED) { > > + max_src_mv = pdo_fixed_voltage(pdo); > > + min_src_mv = max_src_mv; > > + } else { > > + max_src_mv = pdo_max_voltage(pdo); > > + min_src_mv = pdo_min_voltage(pdo); > > + } > > > > if (type == PDO_TYPE_BATT) { > > - mw = pdo_max_power(pdo); > > + src_mw = pdo_max_power(pdo); > > } else { > > - ma = min(pdo_max_current(pdo), > > -port->max_snk_ma); > > - mw = ma * mv / 1000; > > + src_ma = pdo_max_current(pdo); > > + src_mw = src_ma * min_src_mv / 1000; > > } > > > > - /* Perfer higher voltages if available */ > > - if ((mw > max_mw || (mw == max_mw && mv > max_mv)) && > > - mv <= port->max_snk_mv) { > > - ret = i; > > - max_mw = mw; > > - max_mv = mv; > > + for (j = 0; j < port->nr_snk_pdo; j++) { > > + pdo = port->snk_pdo[j]; > > + > > + if (pdo_type(pdo) == PDO_TYPE_FIXED) { > > + min_snk_mv = pdo_fixed_voltage(pdo); > > + max_snk_mv = pdo_fixed_voltage(pdo); > > + } else { > > + min_snk_mv = pdo_min_voltage(pdo); > > + max_snk_mv = pdo_max_voltage(pdo); > > + } > > + > > + if (max_src_mv <= max_snk_mv && > > + min_src_mv >= min_snk_mv) { > > + /* Prefer higher voltages if available */ > > + if ((src_mw == max_mw && min_src_mv > max_mv) || > > + src_mw > max_mw) { > > + *src_pdo = i; > > + *sink_pdo = j; > > + max_mw = src_mw; > > + max_mv = min_src_mv; > > + } > > + break; > > + } > > } > > + > > Nitpick, but that added empty line is uneceessary. Will remove it. > > > } > > > > return ret; > > @@ -1816,13 +1841,14 @@ static
Re: [PATCH 1/3] USB: musb: dsps: drop duplicate phy initialisation
On Fri, Apr 13, 2018 at 05:15:03PM +0200, Johan Hovold wrote: > Since commit 39cee200c23e ("usb: musb: core: call init and shutdown for > the usb phy") the musb USB phy is initialised by musb_core, but the > original initialisation in the dsps-glue init callback was left in > place resulting in two calls to phy init during probe (and similarly, > two shutdowns on remove). > > Drop the duplicate phy init and shutdown calls from the dsps glue in > favour of the ones in musb core, which other glue drivers rely on. Hmm, I don't remember the details of my debug session that led to 39cee200c23e, and I don't have access to the hardware in question any more. But your commit logs makes sense, so Acked-by: Uwe Kleine-KönigGiven that it took 2+ years to find this, backporting to stable and a Fixes: line are probably not necessary. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König| Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] usb: dwc3: Add Qualcomm DWC3 glue driver
On Fri, Apr 13, 2018 at 11:32:04PM +0530, Manu Gautam wrote: > On 4/13/2018 11:03 PM, Jack Pham wrote: > > Are the extcon phandles bound to the glue node? I don't see the > > description in the bindings doc in PATCH 1/3. And if so, would it be > > a duplicate of the child node's extcon binding? Then again, the > > alternative would be to grab it directly from the child (i.e. > > qcom->dwc3->dev.of_node) which I'm not sure is ok to do or not. > > > > Yes these are bound to glue node. I missed to add it to documentation, will do > so. Ok thanks. > I kept it separate for couple of reasons - one is to not peek too-much into > child > node. Another reason is that doing so allows to have extcon in "peripheral" > only mode as well (not just drd mode which is the case with dwc3 core). > It allows to notify h/w when vbus is not there in device mode which IMO is > right thing to do. Ah, makes sense. extcon for the child is only needed for dual-role. Jack -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] usb: dwc3: Add Qualcomm DWC3 glue driver
Hi Jack, On 4/13/2018 11:03 PM, Jack Pham wrote: > Hi Manu, > > On Fri, Apr 13, 2018 at 10:21:23PM +0530, Manu Gautam wrote: >> DWC3 controller on Qualcomm SOCs has a Qscratch wrapper. >> Some of its uses are described below resulting in need to >> have a separate glue driver instead of using dwc3-of-simple: >> - It exposes register interface to override vbus-override >>and lane0-pwr-present signals going to hardware. These >>must be updated in peripheral mode for DWC3 if vbus lines >>are not connected to hardware block. Otherwise RX termination >>in SS mode or DP pull-up is not applied by device controller. >> - pwr_events_irq_stat support to check if USB2 PHY is in L2 state >>before glue driver proceeds with suspend. >> - Support for wakeup interrupts lines that are asserted whenever >>there is any wakeup event on USB3 or USB2 bus. >> - Support to replace pip3 clock going to DWC3 with utmi clock >>for hardware configuration where SSPHY is not used with DWC3. >> >> Signed-off-by: Manu Gautam> > >> +static int dwc3_qcom_register_extcon(struct dwc3_qcom *qcom) >> +{ >> +struct device *dev = qcom->dev; >> +struct extcon_dev *host_edev; >> +int ret; >> + >> +if (!of_property_read_bool(dev->of_node, "extcon")) >> +return 0; >> + >> +qcom->edev = extcon_get_edev_by_phandle(dev, 0); > Are the extcon phandles bound to the glue node? I don't see the > description in the bindings doc in PATCH 1/3. And if so, would it be > a duplicate of the child node's extcon binding? Then again, the > alternative would be to grab it directly from the child (i.e. > qcom->dwc3->dev.of_node) which I'm not sure is ok to do or not. > Yes these are bound to glue node. I missed to add it to documentation, will do so. I kept it separate for couple of reasons - one is to not peek too-much into child node. Another reason is that doing so allows to have extcon in "peripheral" only mode as well (not just drd mode which is the case with dwc3 core). It allows to notify h/w when vbus is not there in device mode which IMO is right thing to do. -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 1/1] usb: hub: Don't wait for connect state at resume for powered-off ports
From: Dominik Bozekwait_for_connected() wait till a port change status to USB_PORT_STAT_CONNECTION, but this is not possible if the port is unpowered. The loop will only exit at timeout. Such case take place if an over-current incident happen while system is in S3. Then during resume wait_for_connected() will wait 2s, which may be noticeable by the user. Signed-off-by: Dominik Bozek Signed-off-by: Kuppuswamy Sathyanarayanan --- drivers/usb/core/hub.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index c5c1f6c..bd2b136 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3367,6 +3367,10 @@ static int wait_for_connected(struct usb_device *udev, while (delay_ms < 2000) { if (status || *portstatus & USB_PORT_STAT_CONNECTION) break; + if (!port_is_power_on(hub, *portstatus)) { + status = -ENODEV; + break; + } msleep(20); delay_ms += 20; status = hub_port_status(hub, *port1, portstatus, portchange); -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 1/1] usb: core: Add quirk for HP v222w 16GB Mini
From: Kamil LulkoAdd DELAY_INIT quirk to fix the following problem with HP v222w 16GB Mini: usb 1-3: unable to read config index 0 descriptor/start: -110 usb 1-3: can't read configurations, error -110 usb 1-3: can't set config #1, error -110 Signed-off-by: Kamil Lulko Signed-off-by: Kuppuswamy Sathyanarayanan --- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 54b019e..f2ef913 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -40,6 +40,9 @@ static const struct usb_device_id usb_quirk_list[] = { { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 }, +/* HP v222w 16GB Mini USB Drive */ +{ USB_DEVICE(0x03f0, 0x3f40), .driver_info = USB_QUIRK_DELAY_INIT }, + /* Creative SB Audigy 2 NX */ { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] usb: dwc3: Add Qualcomm DWC3 glue driver
Hi Manu, On Fri, Apr 13, 2018 at 10:21:23PM +0530, Manu Gautam wrote: > DWC3 controller on Qualcomm SOCs has a Qscratch wrapper. > Some of its uses are described below resulting in need to > have a separate glue driver instead of using dwc3-of-simple: > - It exposes register interface to override vbus-override >and lane0-pwr-present signals going to hardware. These >must be updated in peripheral mode for DWC3 if vbus lines >are not connected to hardware block. Otherwise RX termination >in SS mode or DP pull-up is not applied by device controller. > - pwr_events_irq_stat support to check if USB2 PHY is in L2 state >before glue driver proceeds with suspend. > - Support for wakeup interrupts lines that are asserted whenever >there is any wakeup event on USB3 or USB2 bus. > - Support to replace pip3 clock going to DWC3 with utmi clock >for hardware configuration where SSPHY is not used with DWC3. > > Signed-off-by: Manu Gautam> +static int dwc3_qcom_register_extcon(struct dwc3_qcom *qcom) > +{ > + struct device *dev = qcom->dev; > + struct extcon_dev *host_edev; > + int ret; > + > + if (!of_property_read_bool(dev->of_node, "extcon")) > + return 0; > + > + qcom->edev = extcon_get_edev_by_phandle(dev, 0); Are the extcon phandles bound to the glue node? I don't see the description in the bindings doc in PATCH 1/3. And if so, would it be a duplicate of the child node's extcon binding? Then again, the alternative would be to grab it directly from the child (i.e. qcom->dwc3->dev.of_node) which I'm not sure is ok to do or not. Jack -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 2/2] dt-bindings: usb: rt1711h device tree binding document
On Mon, Apr 09, 2018 at 10:11:35AM +0800, ShuFan Lee wrote: > From: ShuFan Lee> > Add device tree binding document for Richtek RT1711H Type-C chip driver > > Signed-off-by: ShuFan Lee > --- > .../devicetree/bindings/usb/richtek,rt1711h.txt | 17 > + > 1 file changed, 17 insertions(+) > create mode 100644 Documentation/devicetree/bindings/usb/richtek,rt1711h.txt Reviewed-by: Rob Herring -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/5] usb: typec: tcpm: pdo matching optimization
On Fri, Apr 13, 2018 at 10:18:41PM +0800, Li Jun wrote: > This patch is a combination of commit 57e6f0d7b804 > ("typec: tcpm: Only request matching pdos") and source > pdo selection optimization based on it, instead of only > compare between the same pdo type of sink and source, > we should check source pdo voltage range is within the > voltage range of one sink pdo. > > Reviewed-by: Hans de Goede> Signed-off-by: Li Jun > --- > drivers/usb/typec/tcpm.c | 102 > ++- > 1 file changed, 65 insertions(+), 37 deletions(-) > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c > index 677d121..c127339 100644 > --- a/drivers/usb/typec/tcpm.c > +++ b/drivers/usb/typec/tcpm.c > @@ -1772,40 +1772,65 @@ static int tcpm_pd_check_request(struct tcpm_port > *port) > return 0; > } > > -static int tcpm_pd_select_pdo(struct tcpm_port *port) > +#define min_power(x, y) min(pdo_max_power(x), pdo_max_power(y)) > +#define min_current(x, y) min(pdo_max_current(x), pdo_max_current(y)) > + > +static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, > + int *src_pdo) > { > - unsigned int i, max_mw = 0, max_mv = 0; > + unsigned int i, j, max_src_mv = 0, min_src_mv = 0, max_mw = 0, > + max_mv = 0, src_mw = 0, src_ma = 0, max_snk_mv = 0, > + min_snk_mv = 0; > int ret = -EINVAL; > > /* > - * Select the source PDO providing the most power while staying within > - * the board's voltage limits. Prefer PDO providing exp > + * Select the source PDO providing the most power which has a > + * matchig sink cap. >*/ > for (i = 0; i < port->nr_source_caps; i++) { > u32 pdo = port->source_caps[i]; > enum pd_pdo_type type = pdo_type(pdo); > - unsigned int mv, ma, mw; > > - if (type == PDO_TYPE_FIXED) > - mv = pdo_fixed_voltage(pdo); > - else > - mv = pdo_min_voltage(pdo); > + if (type == PDO_TYPE_FIXED) { > + max_src_mv = pdo_fixed_voltage(pdo); > + min_src_mv = max_src_mv; > + } else { > + max_src_mv = pdo_max_voltage(pdo); > + min_src_mv = pdo_min_voltage(pdo); > + } > > if (type == PDO_TYPE_BATT) { > - mw = pdo_max_power(pdo); > + src_mw = pdo_max_power(pdo); > } else { > - ma = min(pdo_max_current(pdo), > - port->max_snk_ma); > - mw = ma * mv / 1000; > + src_ma = pdo_max_current(pdo); > + src_mw = src_ma * min_src_mv / 1000; > } > > - /* Perfer higher voltages if available */ > - if ((mw > max_mw || (mw == max_mw && mv > max_mv)) && > - mv <= port->max_snk_mv) { > - ret = i; > - max_mw = mw; > - max_mv = mv; > + for (j = 0; j < port->nr_snk_pdo; j++) { > + pdo = port->snk_pdo[j]; > + > + if (pdo_type(pdo) == PDO_TYPE_FIXED) { > + min_snk_mv = pdo_fixed_voltage(pdo); > + max_snk_mv = pdo_fixed_voltage(pdo); > + } else { > + min_snk_mv = pdo_min_voltage(pdo); > + max_snk_mv = pdo_max_voltage(pdo); > + } > + > + if (max_src_mv <= max_snk_mv && > + min_src_mv >= min_snk_mv) { > + /* Prefer higher voltages if available */ > + if ((src_mw == max_mw && min_src_mv > max_mv) || > + src_mw > max_mw) { > + *src_pdo = i; > + *sink_pdo = j; > + max_mw = src_mw; > + max_mv = min_src_mv; > + } > + break; > + } > } > + Nitpick, but that added empty line is uneceessary. > } > > return ret; > @@ -1816,13 +1841,14 @@ static int tcpm_pd_build_request(struct tcpm_port > *port, u32 *rdo) > unsigned int mv, ma, mw, flags; > unsigned int max_ma, max_mw; > enum pd_pdo_type type; > - int index; > - u32 pdo; > + int src_pdo_index, snk_pdo_index; > + u32 pdo, matching_snk_pdo; > > - index = tcpm_pd_select_pdo(port); > - if (index < 0) > + if (tcpm_pd_select_pdo(port, _pdo_index, _pdo_index) < 0) > return -EINVAL; This may save you a variable, but tcpm_pd_select_pdo()
Re: [PATCH v4 2/5] usb: typec: fusb302: remove max_snk_* for sink config
On Fri, Apr 13, 2018 at 10:18:42PM +0800, Li Jun wrote: > Since max_snk_* is to be deprecated, so remove max_snk_* by adding a > variable PDO for sink config. max_snk or max_sink ? > > Reviewed-by: Hans de Goede> Signed-off-by: Li Jun > --- > drivers/usb/typec/fusb302/fusb302.c | 34 -- > 1 file changed, 20 insertions(+), 14 deletions(-) > > diff --git a/drivers/usb/typec/fusb302/fusb302.c > b/drivers/usb/typec/fusb302/fusb302.c > index 7036171..893f9e5 100644 > --- a/drivers/usb/typec/fusb302/fusb302.c > +++ b/drivers/usb/typec/fusb302/fusb302.c > @@ -120,6 +120,7 @@ struct fusb302_chip { > enum typec_cc_polarity cc_polarity; > enum typec_cc_status cc1; > enum typec_cc_status cc2; > + u32 snk_pdo[PDO_MAX_OBJECTS]; > > #ifdef CONFIG_DEBUG_FS > struct dentry *dentry; > @@ -1212,11 +1213,6 @@ static const u32 snk_pdo[] = { > static const struct tcpc_config fusb302_tcpc_config = { > .src_pdo = src_pdo, > .nr_src_pdo = ARRAY_SIZE(src_pdo), > - .snk_pdo = snk_pdo, > - .nr_snk_pdo = ARRAY_SIZE(snk_pdo), > - .max_snk_mv = 5000, > - .max_snk_ma = 3000, > - .max_snk_mw = 15000, > .operating_snk_mw = 2500, > .type = TYPEC_PORT_DRP, > .data = TYPEC_PORT_DRD, > @@ -1756,6 +1752,21 @@ static int init_gpio(struct fusb302_chip *chip) > return 0; > } > > +static int fusb302_composite_snk_pdo_array(struct fusb302_chip *chip) > +{ > + struct device *dev = chip->dev; > + u32 max_uv, max_ua; > + > + chip->snk_pdo[0] = PDO_FIXED(5000, 400, PDO_FIXED_FLAGS); > + > + if (device_property_read_u32(dev, "fcs,max-sink-microvolt", _uv) || > + device_property_read_u32(dev, "fcs,max-sink-microamp", _ua)) > + return 1; Aren't those properties removed in the next patch ? If this is on purpose, it should be documented. > + > + chip->snk_pdo[1] = PDO_VAR(5000, max_uv / 1000, max_ua / 1000); > + return 2; > +} > + > static int fusb302_probe(struct i2c_client *client, >const struct i2c_device_id *id) > { > @@ -1784,18 +1795,13 @@ static int fusb302_probe(struct i2c_client *client, > chip->tcpc_dev.config = >tcpc_config; > mutex_init(>lock); > > - if (!device_property_read_u32(dev, "fcs,max-sink-microvolt", )) > - chip->tcpc_config.max_snk_mv = v / 1000; > - > - if (!device_property_read_u32(dev, "fcs,max-sink-microamp", )) > - chip->tcpc_config.max_snk_ma = v / 1000; > - > - if (!device_property_read_u32(dev, "fcs,max-sink-microwatt", )) > - chip->tcpc_config.max_snk_mw = v / 1000; > - > if (!device_property_read_u32(dev, "fcs,operating-sink-microwatt", )) > chip->tcpc_config.operating_snk_mw = v / 1000; > > + /* Composite sink PDO */ > + chip->tcpc_config.nr_snk_pdo = fusb302_composite_snk_pdo_array(chip); > + chip->tcpc_config.snk_pdo = chip->snk_pdo; > + > /* >* Devicetree platforms should get extcon via phandle (not yet >* supported). On ACPI platforms, we get the name from a device prop. > -- > 2.7.4 > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/5] usb: typec: tcpm: pdo matching optimization
Hi, On 13-04-18 17:58, Guenter Roeck wrote: On Fri, Apr 13, 2018 at 10:18:41PM +0800, Li Jun wrote: This patch is a combination of commit 57e6f0d7b804 ("typec: tcpm: Only request matching pdos") and source pdo selection optimization based on it, instead of only compare between the same pdo type of sink and source, we should check source pdo voltage range is within the voltage range of one sink pdo. Reviewed-by: Hans de GoedeSigned-off-by: Li Jun --- drivers/usb/typec/tcpm.c | 102 ++- 1 file changed, 65 insertions(+), 37 deletions(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 677d121..c127339 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -1772,40 +1772,65 @@ static int tcpm_pd_check_request(struct tcpm_port *port) return 0; } -static int tcpm_pd_select_pdo(struct tcpm_port *port) +#define min_power(x, y) min(pdo_max_power(x), pdo_max_power(y)) +#define min_current(x, y) min(pdo_max_current(x), pdo_max_current(y)) + +static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, + int *src_pdo) { - unsigned int i, max_mw = 0, max_mv = 0; + unsigned int i, j, max_src_mv = 0, min_src_mv = 0, max_mw = 0, +max_mv = 0, src_mw = 0, src_ma = 0, max_snk_mv = 0, +min_snk_mv = 0; int ret = -EINVAL; /* -* Select the source PDO providing the most power while staying within -* the board's voltage limits. Prefer PDO providing exp +* Select the source PDO providing the most power which has a +* matchig sink cap. */ for (i = 0; i < port->nr_source_caps; i++) { u32 pdo = port->source_caps[i]; enum pd_pdo_type type = pdo_type(pdo); - unsigned int mv, ma, mw; - if (type == PDO_TYPE_FIXED) - mv = pdo_fixed_voltage(pdo); - else - mv = pdo_min_voltage(pdo); + if (type == PDO_TYPE_FIXED) { + max_src_mv = pdo_fixed_voltage(pdo); + min_src_mv = max_src_mv; + } else { + max_src_mv = pdo_max_voltage(pdo); + min_src_mv = pdo_min_voltage(pdo); + } if (type == PDO_TYPE_BATT) { - mw = pdo_max_power(pdo); + src_mw = pdo_max_power(pdo); } else { - ma = min(pdo_max_current(pdo), -port->max_snk_ma); - mw = ma * mv / 1000; + src_ma = pdo_max_current(pdo); + src_mw = src_ma * min_src_mv / 1000; } - /* Perfer higher voltages if available */ - if ((mw > max_mw || (mw == max_mw && mv > max_mv)) && - mv <= port->max_snk_mv) { - ret = i; - max_mw = mw; - max_mv = mv; + for (j = 0; j < port->nr_snk_pdo; j++) { + pdo = port->snk_pdo[j]; + + if (pdo_type(pdo) == PDO_TYPE_FIXED) { + min_snk_mv = pdo_fixed_voltage(pdo); + max_snk_mv = pdo_fixed_voltage(pdo); + } else { + min_snk_mv = pdo_min_voltage(pdo); + max_snk_mv = pdo_max_voltage(pdo); + } + + if (max_src_mv <= max_snk_mv && + min_src_mv >= min_snk_mv) { + /* Prefer higher voltages if available */ + if ((src_mw == max_mw && min_src_mv > max_mv) || + src_mw > max_mw) { + *src_pdo = i; + *sink_pdo = j; + max_mw = src_mw; + max_mv = min_src_mv; + } + break; + } } + Nitpick, but that added empty line is uneceessary. } return ret; @@ -1816,13 +1841,14 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo) unsigned int mv, ma, mw, flags; unsigned int max_ma, max_mw; enum pd_pdo_type type; - int index; - u32 pdo; + int src_pdo_index, snk_pdo_index; + u32 pdo, matching_snk_pdo; - index = tcpm_pd_select_pdo(port); - if (index < 0) + if (tcpm_pd_select_pdo(port, _pdo_index, _pdo_index) < 0) return -EINVAL; This may save you a variable, but tcpm_pd_select_pdo() may at some point return a different error. Either case, this
[PATCH v2 1/3] dt-bindings: usb: Update documentation for Qualcomm DWC3 driver
Existing documentation has lot of incorrect information as it was originally added for a driver that no longer exists. Signed-off-by: Manu Gautam--- .../devicetree/bindings/usb/qcom,dwc3.txt | 78 -- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt index bc8a2fa..fdc574a 100644 --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt @@ -1,54 +1,90 @@ Qualcomm SuperSpeed DWC3 USB SoC controller Required properties: -- compatible: should contain "qcom,dwc3" +- compatible: should contain "qcom,dwc3" +- reg: offset and length of register set for QSCRATCH wrapper +- power-domains: specifies a phandle to PM domain provider node - clocks: A list of phandle + clock-specifier pairs for the clocks listed in clock-names -- clock-names: Should contain the following: +- clock-names: Should contain the following: "core" Master/Core clock, have to be >= 125 MHz for SS operation and >= 60MHz for HS operation + "mock_utmi" Mock utmi clock needed for ITP/SOF generation in + host mode. Its frequency should be 19.2MHz. + "sleep" Sleep clock, used for wakeup when USB3 core goes + into low power mode (U3). Optional clocks: "iface" System bus AXI clock. Not present on all platforms - "sleep" Sleep clock, used when USB3 core goes into low - power mode (U3). + "cfg_noc"System Config NOC clock. Not present on all platforms +- assigned-clocks: should be: + MOCK_UTMI_CLK + MASTER_CLK +- assigned-clock-rates: should be: +19.2Mhz (19200) for MOCK_UTMI_CLK +>=125Mhz (12500) for MASTER_CLK in SS mode +>=60Mhz (6000) for MASTER_CLK in HS mode + +Optional properties: +- resets: list of phandle and reset specifier pairs +- interrupts: specifies interrupts from controller wrapper used + to wakeup from low power/susepnd state. Must contain + one or more entry for interrupt-names property +- interrupt-names: Must include the following entries: + - "hs_phy_irq": The interrupt that is asserted when a + wakeup event is received on USB2 bus + - "ss_phy_irq": The interrupt that is asserted when a + wakeup event is received on USB3 bus + - "dm_hs_phy_irq" and "dp_hs_phy_irq": Separate + interrupts for any wakeup event on DM and DP lines +- qcom,select-utmi-as-pipe-clk: if present, disable USB3 pipe_clk requirement. + Used when dwc3 operates without SSPHY and only + HS/FS/LS modes are supported. Required child node: A child node must exist to represent the core DWC3 IP block. The name of the node is not important. The content of the node is defined in dwc3.txt. Phy documentation is provided in the following places: -Documentation/devicetree/bindings/phy/qcom-dwc3-usb-phy.txt +Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt - USB3 QMP PHY +Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt - USB2 QUSB2 PHY Example device nodes: hs_phy: phy@100f8800 { - compatible = "qcom,dwc3-hs-usb-phy"; - reg = <0x100f8800 0x30>; - clocks = < USB30_0_UTMI_CLK>; - clock-names = "ref"; - #phy-cells = <0>; - + compatible = "qcom,qusb2-v2-phy"; + ... }; ss_phy: phy@100f8830 { - compatible = "qcom,dwc3-ss-usb-phy"; - reg = <0x100f8830 0x30>; - clocks = < USB30_0_MASTER_CLK>; - clock-names = "ref"; - #phy-cells = <0>; - + compatible = "qcom,qmp-v3-usb3-phy"; + ... }; - usb3_0: usb30@0 { + usb3_0: usb30@a6f8800 { compatible = "qcom,dwc3"; + reg = <0xa6f8800 0x400>; #address-cells = <1>; #size-cells = <1>; - clocks = < USB30_0_MASTER_CLK>; - clock-names = "core"; - ranges; + interrupts = <0 131 0>, <0
[PATCH v2 0/3] usb: dwc3: support for Qualcomm DWC3 glue
Add separate dwc3-qcom glue driver for Qualcomm SOCs having dwc3 core. It is needed to support peripheral mode. Patches also add support to invoke PHY runtime PM functions on host mode bus-suspend. Changes since v1: - Move dwc3 core register accesses from glue driver to dwc3 core as per review comment from Felipe. - Addressed other review comments from Felipe and Rob. - Some other minor code changes related to redability. - Add reset_control assert in driver probe to ensure core registers are reset to POR value in case of any initalization by boot code. Manu Gautam (3): dt-bindings: usb: Update documentation for Qualcomm DWC3 driver usb: dwc3: Add Qualcomm DWC3 glue driver usb: dwc3: core: Suspend PHYs on runtime suspend in host mode .../devicetree/bindings/usb/qcom,dwc3.txt | 78 ++- drivers/usb/dwc3/Kconfig | 12 + drivers/usb/dwc3/Makefile | 1 + drivers/usb/dwc3/core.c| 36 +- drivers/usb/dwc3/dwc3-of-simple.c | 1 - drivers/usb/dwc3/dwc3-qcom.c | 618 + 6 files changed, 721 insertions(+), 25 deletions(-) create mode 100644 drivers/usb/dwc3/dwc3-qcom.c -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/3] usb: dwc3: Add Qualcomm DWC3 glue driver
DWC3 controller on Qualcomm SOCs has a Qscratch wrapper. Some of its uses are described below resulting in need to have a separate glue driver instead of using dwc3-of-simple: - It exposes register interface to override vbus-override and lane0-pwr-present signals going to hardware. These must be updated in peripheral mode for DWC3 if vbus lines are not connected to hardware block. Otherwise RX termination in SS mode or DP pull-up is not applied by device controller. - pwr_events_irq_stat support to check if USB2 PHY is in L2 state before glue driver proceeds with suspend. - Support for wakeup interrupts lines that are asserted whenever there is any wakeup event on USB3 or USB2 bus. - Support to replace pip3 clock going to DWC3 with utmi clock for hardware configuration where SSPHY is not used with DWC3. Signed-off-by: Manu Gautam--- drivers/usb/dwc3/Kconfig | 12 + drivers/usb/dwc3/Makefile | 1 + drivers/usb/dwc3/dwc3-of-simple.c | 1 - drivers/usb/dwc3/dwc3-qcom.c | 618 ++ 4 files changed, 631 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/dwc3/dwc3-qcom.c diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index ab8c0e0..451012e 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -106,4 +106,16 @@ config USB_DWC3_ST inside (i.e. STiH407). Say 'Y' or 'M' if you have one such device. +config USB_DWC3_QCOM + tristate "Qualcomm Platform" + depends on ARCH_QCOM || COMPILE_TEST + depends on OF + default USB_DWC3 + help + Some Qualcomm SoCs use DesignWare Core IP for USB2/3 + functionality. + This driver also handles Qscratch wrapper which is needed + for peripheral mode support. + Say 'Y' or 'M' if you have one such device. + endif diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index 025bc68..5c07d8f 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -48,3 +48,4 @@ obj-$(CONFIG_USB_DWC3_PCI)+= dwc3-pci.o obj-$(CONFIG_USB_DWC3_KEYSTONE)+= dwc3-keystone.o obj-$(CONFIG_USB_DWC3_OF_SIMPLE) += dwc3-of-simple.o obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o +obj-$(CONFIG_USB_DWC3_QCOM)+= dwc3-qcom.o diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index cb2ee96..0fd0e8e 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c @@ -208,7 +208,6 @@ static int dwc3_of_simple_runtime_resume(struct device *dev) }; static const struct of_device_id of_dwc3_simple_match[] = { - { .compatible = "qcom,dwc3" }, { .compatible = "rockchip,rk3399-dwc3" }, { .compatible = "xlnx,zynqmp-dwc3" }, { .compatible = "cavium,octeon-7130-usb-uctl" }, diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c new file mode 100644 index 000..ecb2218 --- /dev/null +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -0,0 +1,618 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2018, The Linux Foundation. All rights reserved. + * + * Inspired by dwc3-of-simple.c + */ +#define DEBUG + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core.h" + +/* USB QSCRATCH Hardware registers */ +#define QSCRATCH_HS_PHY_CTRL 0x10 +#define UTMI_OTG_VBUS_VALIDBIT(20) +#define SW_SESSVLD_SEL BIT(28) + +#define QSCRATCH_SS_PHY_CTRL 0x30 +#define LANE0_PWR_PRESENT BIT(24) + +#define QSCRATCH_GENERAL_CFG 0x08 +#define PIPE_UTMI_CLK_SEL BIT(0) +#define PIPE3_PHYSTATUS_SW BIT(3) +#define PIPE_UTMI_CLK_DIS BIT(8) + +#define PWR_EVNT_IRQ_STAT_REG 0x58 +#define PWR_EVNT_LPM_IN_L2_MASKBIT(4) +#define PWR_EVNT_LPM_OUT_L2_MASK BIT(5) + +struct dwc3_qcom { + struct device *dev; + void __iomem*qscratch_base; + struct platform_device *dwc3; + struct clk **clks; + int num_clocks; + struct reset_control*resets; + + int hs_phy_irq; + int dp_hs_phy_irq; + int dm_hs_phy_irq; + int ss_phy_irq; + + struct extcon_dev *edev; + struct extcon_dev *host_edev; + struct notifier_block vbus_nb; + struct notifier_block host_nb; + + enum usb_dr_modemode; + boolis_suspended; + boolpm_suspended; +}; + +static inline void dwc3_qcom_setbits(void __iomem *base, u32 offset, u32 val) +{ +
[PATCH v2 3/3] usb: dwc3: core: Suspend PHYs on runtime suspend in host mode
Some PHY drivers (e.g. for Qualcomm QUSB2 and QMP PHYs) support runtime PM to reduce PHY power consumption during bus_suspend. Add changes to let core auto-suspend PHYs on host bus-suspend using GUSB2PHYCFG register if needed for a platform. Also perform PHYs runtime suspend/resume and let platform glue drivers e.g. dwc3-qcom handle remote wakeup during bus suspend by waking up devices on receiving wakeup event from PHY. Signed-off-by: Manu Gautam--- drivers/usb/dwc3/core.c | 36 +--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a15648d..449a098 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1394,6 +1394,7 @@ static int dwc3_remove(struct platform_device *pdev) static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) { unsigned long flags; + u32 reg; switch (dwc->current_dr_role) { case DWC3_GCTL_PRTCAP_DEVICE: @@ -1403,9 +1404,25 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) dwc3_core_exit(dwc); break; case DWC3_GCTL_PRTCAP_HOST: - /* do nothing during host runtime_suspend */ - if (!PMSG_IS_AUTO(msg)) + if (!PMSG_IS_AUTO(msg)) { dwc3_core_exit(dwc); + break; + } + + /* Let controller to suspend HSPHY before PHY driver suspends */ + if (dwc->dis_u2_susphy_quirk || + dwc->dis_enblslpm_quirk) { + reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); + reg |= DWC3_GUSB2PHYCFG_ENBLSLPM | + DWC3_GUSB2PHYCFG_SUSPHY; + dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); + + /* Give some time for USB2 PHY to suspend */ + usleep_range(5000, 6000); + } + + phy_pm_runtime_put_sync(dwc->usb2_generic_phy); + phy_pm_runtime_put_sync(dwc->usb3_generic_phy); break; case DWC3_GCTL_PRTCAP_OTG: /* do nothing during runtime_suspend */ @@ -1433,6 +1450,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) { unsigned long flags; int ret; + u32 reg; switch (dwc->current_dr_role) { case DWC3_GCTL_PRTCAP_DEVICE: @@ -1446,13 +1464,25 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) spin_unlock_irqrestore(>lock, flags); break; case DWC3_GCTL_PRTCAP_HOST: - /* nothing to do on host runtime_resume */ if (!PMSG_IS_AUTO(msg)) { ret = dwc3_core_init(dwc); if (ret) return ret; dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST); + break; } + /* Restore GUSB2PHYCFG bits that were modified in suspend */ + reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); + if (dwc->dis_u2_susphy_quirk) + reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; + + if (dwc->dis_enblslpm_quirk) + reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM; + + dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); + + phy_pm_runtime_get_sync(dwc->usb2_generic_phy); + phy_pm_runtime_get_sync(dwc->usb3_generic_phy); break; case DWC3_GCTL_PRTCAP_OTG: /* nothing to do on runtime_resume */ -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* properties
On Fri, Apr 13, 2018 at 10:18:43PM +0800, Li Jun wrote: > Remove max-sink-* properties since they are deprecated. > > Reviewed-by: Rob Herring> Reviewed-by: Hans de Goede > Signed-off-by: Li Jun > --- > Documentation/devicetree/bindings/usb/fcs,fusb302.txt | 6 -- > 1 file changed, 6 deletions(-) > > diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > index 472facf..6087dc7 100644 > --- a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > +++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt > @@ -6,12 +6,6 @@ Required properties : > - interrupts : Interrupt specifier > > Optional properties : > -- fcs,max-sink-microvolt : Maximum voltage to negotiate when configured as > sink > -- fcs,max-sink-microamp : Maximum current to negotiate when configured as > sink > -- fcs,max-sink-microwatt : Maximum power to negotiate when configured as sink > -If this is less then max-sink-microvolt * > -max-sink-microamp then the configured current will > -be clamped. Is it acceptable to just remove properties ? > - fcs,operating-sink-microwatt : > Minimum amount of power accepted from a sink > when negotiating > -- > 2.7.4 > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] USB: musb: dsps: drop duplicate phy initialisation
Since commit 39cee200c23e ("usb: musb: core: call init and shutdown for the usb phy") the musb USB phy is initialised by musb_core, but the original initialisation in the dsps-glue init callback was left in place resulting in two calls to phy init during probe (and similarly, two shutdowns on remove). Drop the duplicate phy init and shutdown calls from the dsps glue in favour of the ones in musb core, which other glue drivers rely on. Note however that any generic phy is still initialised in the glue init callback (just as for the other drivers). Cc: Uwe Kleine-KönigSigned-off-by: Johan Hovold --- drivers/usb/musb/musb_dsps.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 05a679d5e3a2..6a60bc0490c5 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -451,7 +451,6 @@ static int dsps_musb_init(struct musb *musb) if (!rev) return -ENODEV; - usb_phy_init(musb->xceiv); if (IS_ERR(musb->phy)) { musb->phy = NULL; } else { @@ -501,7 +500,6 @@ static int dsps_musb_exit(struct musb *musb) struct dsps_glue *glue = dev_get_drvdata(dev->parent); del_timer_sync(>dev_timer); - usb_phy_shutdown(musb->xceiv); phy_power_off(musb->phy); phy_exit(musb->phy); debugfs_remove_recursive(glue->dbgfs_root); -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] USB: musb: dsps: phy fix and DT-topology support
I've been carrying a patch out-of-tree since my work on improving the USB device-tree support which is needed to be able to describe USB topologies for musb based controllers. This patch, which associates the platform controller device with the glue device device-tree node, did not play well with the recent changes which added generic phy support to USB core however. Like the recent dwc2 regression fixed by Arnd after the device-tree #phy-cell changes, the generic phy code in USB core can now also fail indefinitly with -EPROBE_DEFER when the controller uses a legacy USB phy. The second patch addresses this for musb, which handles its own (legacy and generic) phys, but something more may possibly now be needed for other platforms with legacy phys. In the process of debugging this, I stumbled over another issue which caused the dsps legacy phy init two be called twice on every probe and which is fixed by the first patch. Johan Johan Hovold (3): USB: musb: dsps: drop duplicate phy initialisation USB: musb: host: prevent core phy initialisation USB: musb: dsps: propagate device-tree node drivers/usb/musb/musb_dsps.c | 3 +-- drivers/usb/musb/musb_host.c | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] USB: musb: dsps: propagate device-tree node
To be able to use DSPS-based controllers with device-tree descriptions of the USB topology, we need to associate the glue device's device-tree node with the child controller device. Note that this can also be used to eventually let USB core manage generic phys. Also note that the other glue drivers will require similar changes to be able to describe their buses in DT. Signed-off-by: Johan Hovold--- drivers/usb/musb/musb_dsps.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 6a60bc0490c5..23dba59045a7 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -786,6 +786,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, musb->dev.parent= dev; musb->dev.dma_mask = _dmamask; musb->dev.coherent_dma_mask = musb_dmamask; + device_set_of_node_from_dev(>dev, >dev); glue->musb = musb; -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] USB: musb: host: prevent core phy initialisation
Set the new HCD flag which prevents USB core from trying to manage our phys. This is needed to be able to associate the controller platform device with the glue device device-tree node on the BBB which uses legacy USB phys. Otherwise, the generic phy lookup in usb_phy_roothub_init() and thus HCD registration fails repeatedly with -EPROBE_DEFER (see commit 178a0bce05cb ("usb: core: hcd: integrate the PHY wrapper into the HCD core")). Note that a related phy-lookup issue was recently worked around in the phy core by commit b7563e2796f8 ("phy: work around 'phys' references to usb-nop-xceiv devices"). Something similar may now be needed for other USB phys, and in particular if we eventually want to let USB core manage musb generic phys. Cc: Arnd BergmannCc: Martin Blumenstingl Signed-off-by: Johan Hovold --- drivers/usb/musb/musb_host.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 3a8451a15f7f..4fa372c845e1 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -2754,6 +2754,7 @@ int musb_host_setup(struct musb *musb, int power_budget) hcd->self.otg_port = 1; musb->xceiv->otg->host = >self; hcd->power_budget = 2 * (power_budget ? : 250); + hcd->skip_phy_initialization = 1; ret = usb_add_hcd(hcd, 0, 0); if (ret < 0) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 5/5] usb: typec: tcpm: remove max_snk_mv/ma/mw
Since there is no user of max_snk_*, so we can remove them from tcpm. Reviewed-by: Hans de GoedeSigned-off-by: Li Jun --- drivers/usb/typec/tcpm.c | 12 include/linux/usb/tcpm.h | 9 - 2 files changed, 21 deletions(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index c127339..3d9cfd6 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -257,9 +257,6 @@ struct tcpm_port { u32 snk_vdo[VDO_MAX_OBJECTS]; unsigned int nr_snk_vdo; - unsigned int max_snk_mv; - unsigned int max_snk_ma; - unsigned int max_snk_mw; unsigned int operating_snk_mw; /* Requested current / voltage */ @@ -3597,9 +3594,6 @@ EXPORT_SYMBOL_GPL(tcpm_update_source_capabilities); int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, unsigned int nr_pdo, - unsigned int max_snk_mv, - unsigned int max_snk_ma, - unsigned int max_snk_mw, unsigned int operating_snk_mw) { if (tcpm_validate_caps(port, pdo, nr_pdo)) @@ -3607,9 +3601,6 @@ int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, mutex_lock(>lock); port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, pdo, nr_pdo); - port->max_snk_mv = max_snk_mv; - port->max_snk_ma = max_snk_ma; - port->max_snk_mw = max_snk_mw; port->operating_snk_mw = operating_snk_mw; switch (port->state) { @@ -3675,9 +3666,6 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo, tcpc->config->nr_snk_vdo); - port->max_snk_mv = tcpc->config->max_snk_mv; - port->max_snk_ma = tcpc->config->max_snk_ma; - port->max_snk_mw = tcpc->config->max_snk_mw; port->operating_snk_mw = tcpc->config->operating_snk_mw; if (!tcpc->config->try_role_hw) port->try_role = tcpc->config->default_role; diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index f0d839d..f5bda9a 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -62,9 +62,6 @@ enum tcpm_transmit_type { * @snk_pdo: PDO parameters sent to partner as response to * PD_CTRL_GET_SINK_CAP message * @nr_snk_pdo:Number of entries in @snk_pdo - * @max_snk_mv:Maximum acceptable sink voltage in mV - * @max_snk_ma:Maximum sink current in mA - * @max_snk_mw:Maximum required sink power in mW * @operating_snk_mw: * Required operating sink power in mW * @type: Port type (TYPEC_PORT_DFP, TYPEC_PORT_UFP, or @@ -85,9 +82,6 @@ struct tcpc_config { const u32 *snk_vdo; unsigned int nr_snk_vdo; - unsigned int max_snk_mv; - unsigned int max_snk_ma; - unsigned int max_snk_mw; unsigned int operating_snk_mw; enum typec_port_type type; @@ -174,9 +168,6 @@ int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, unsigned int nr_pdo); int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, unsigned int nr_pdo, - unsigned int max_snk_mv, - unsigned int max_snk_ma, - unsigned int max_snk_mw, unsigned int operating_snk_mw); void tcpm_vbus_change(struct tcpm_port *port); -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 3/5] dt-bindings: usb: fusb302: remove max-sink-* properties
Remove max-sink-* properties since they are deprecated. Reviewed-by: Rob HerringReviewed-by: Hans de Goede Signed-off-by: Li Jun --- Documentation/devicetree/bindings/usb/fcs,fusb302.txt | 6 -- 1 file changed, 6 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt index 472facf..6087dc7 100644 --- a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt +++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt @@ -6,12 +6,6 @@ Required properties : - interrupts : Interrupt specifier Optional properties : -- fcs,max-sink-microvolt : Maximum voltage to negotiate when configured as sink -- fcs,max-sink-microamp : Maximum current to negotiate when configured as sink -- fcs,max-sink-microwatt : Maximum power to negotiate when configured as sink - If this is less then max-sink-microvolt * - max-sink-microamp then the configured current will - be clamped. - fcs,operating-sink-microwatt : Minimum amount of power accepted from a sink when negotiating -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 4/5] usb: typec: wcove: remove max_snk_* for sink config
Since max_snk_* is to be deprecated, so remove max_snk_* by adding a variable PDO for sink config. Reviewed-by: Hans de GoedeSigned-off-by: Li Jun --- drivers/usb/typec/typec_wcove.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/typec/typec_wcove.c b/drivers/usb/typec/typec_wcove.c index 19cca7f..39cff11 100644 --- a/drivers/usb/typec/typec_wcove.c +++ b/drivers/usb/typec/typec_wcove.c @@ -558,6 +558,7 @@ static const u32 src_pdo[] = { static const u32 snk_pdo[] = { PDO_FIXED(5000, 500, PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP | PDO_FIXED_USB_COMM), + PDO_VAR(5000, 12000, 3000), }; static struct tcpc_config wcove_typec_config = { @@ -566,9 +567,6 @@ static struct tcpc_config wcove_typec_config = { .snk_pdo = snk_pdo, .nr_snk_pdo = ARRAY_SIZE(snk_pdo), - .max_snk_mv = 12000, - .max_snk_ma = 3000, - .max_snk_mw = 36000, .operating_snk_mw = 15000, .type = TYPEC_PORT_DRP, -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 1/5] usb: typec: tcpm: pdo matching optimization
This patch is a combination of commit 57e6f0d7b804 ("typec: tcpm: Only request matching pdos") and source pdo selection optimization based on it, instead of only compare between the same pdo type of sink and source, we should check source pdo voltage range is within the voltage range of one sink pdo. Reviewed-by: Hans de GoedeSigned-off-by: Li Jun --- drivers/usb/typec/tcpm.c | 102 ++- 1 file changed, 65 insertions(+), 37 deletions(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 677d121..c127339 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -1772,40 +1772,65 @@ static int tcpm_pd_check_request(struct tcpm_port *port) return 0; } -static int tcpm_pd_select_pdo(struct tcpm_port *port) +#define min_power(x, y) min(pdo_max_power(x), pdo_max_power(y)) +#define min_current(x, y) min(pdo_max_current(x), pdo_max_current(y)) + +static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, + int *src_pdo) { - unsigned int i, max_mw = 0, max_mv = 0; + unsigned int i, j, max_src_mv = 0, min_src_mv = 0, max_mw = 0, +max_mv = 0, src_mw = 0, src_ma = 0, max_snk_mv = 0, +min_snk_mv = 0; int ret = -EINVAL; /* -* Select the source PDO providing the most power while staying within -* the board's voltage limits. Prefer PDO providing exp +* Select the source PDO providing the most power which has a +* matchig sink cap. */ for (i = 0; i < port->nr_source_caps; i++) { u32 pdo = port->source_caps[i]; enum pd_pdo_type type = pdo_type(pdo); - unsigned int mv, ma, mw; - if (type == PDO_TYPE_FIXED) - mv = pdo_fixed_voltage(pdo); - else - mv = pdo_min_voltage(pdo); + if (type == PDO_TYPE_FIXED) { + max_src_mv = pdo_fixed_voltage(pdo); + min_src_mv = max_src_mv; + } else { + max_src_mv = pdo_max_voltage(pdo); + min_src_mv = pdo_min_voltage(pdo); + } if (type == PDO_TYPE_BATT) { - mw = pdo_max_power(pdo); + src_mw = pdo_max_power(pdo); } else { - ma = min(pdo_max_current(pdo), -port->max_snk_ma); - mw = ma * mv / 1000; + src_ma = pdo_max_current(pdo); + src_mw = src_ma * min_src_mv / 1000; } - /* Perfer higher voltages if available */ - if ((mw > max_mw || (mw == max_mw && mv > max_mv)) && - mv <= port->max_snk_mv) { - ret = i; - max_mw = mw; - max_mv = mv; + for (j = 0; j < port->nr_snk_pdo; j++) { + pdo = port->snk_pdo[j]; + + if (pdo_type(pdo) == PDO_TYPE_FIXED) { + min_snk_mv = pdo_fixed_voltage(pdo); + max_snk_mv = pdo_fixed_voltage(pdo); + } else { + min_snk_mv = pdo_min_voltage(pdo); + max_snk_mv = pdo_max_voltage(pdo); + } + + if (max_src_mv <= max_snk_mv && + min_src_mv >= min_snk_mv) { + /* Prefer higher voltages if available */ + if ((src_mw == max_mw && min_src_mv > max_mv) || + src_mw > max_mw) { + *src_pdo = i; + *sink_pdo = j; + max_mw = src_mw; + max_mv = min_src_mv; + } + break; + } } + } return ret; @@ -1816,13 +1841,14 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo) unsigned int mv, ma, mw, flags; unsigned int max_ma, max_mw; enum pd_pdo_type type; - int index; - u32 pdo; + int src_pdo_index, snk_pdo_index; + u32 pdo, matching_snk_pdo; - index = tcpm_pd_select_pdo(port); - if (index < 0) + if (tcpm_pd_select_pdo(port, _pdo_index, _pdo_index) < 0) return -EINVAL; - pdo = port->source_caps[index]; + + pdo = port->source_caps[src_pdo_index]; + matching_snk_pdo = port->snk_pdo[snk_pdo_index]; type = pdo_type(pdo); if (type == PDO_TYPE_FIXED) @@ -1830,26 +1856,28 @@
[PATCH v4 0/5] usb: typec: remove max_snk_mv/ma/mw
This patch set is to remove max_snk_mv/ma/mw configs, as we should define the sink capability by sink PDOs, the first patch update the source PDO match policy by compare the voltage range between source and sink PDOs no matter what type they are, the following patchs remove those 3 variables from 2 existing users by adding a variable PDO, then finial patch remove the max_snk_* from tcpm. Change for v4: - Add Hans's reviewed-by tag for the whole patch set. Changes for v3: - Remove 3 variables: nr_fxied, nr_var and nr_batt from tcpm_port; so nr_type_pdos() is not needed and removed. - Simplify fusb302_composite_snk_pdo_array() by only considering existing setting as Hans suggested. - Add Rob's reviewed-by for dt-binding patch. Changes for v2: - rebase the 1st patch to be based on commit 6f566af34628 ("Revert "typec: tcpm: Only request matching pdos""). - Convert the device properties passing max_snk_* to be a variable sink pdo for fusb302. Li Jun (5): usb: typec: tcpm: pdo matching optimization usb: typec: fusb302: remove max_snk_* for sink config dt-bindings: usb: fusb302: remove max-sink-* properties usb: typec: wcove: remove max_snk_* for sink config usb: typec: tcpm: remove max_snk_mv/ma/mw .../devicetree/bindings/usb/fcs,fusb302.txt| 6 -- drivers/usb/typec/fusb302/fusb302.c| 34 +++--- drivers/usb/typec/tcpm.c | 114 - drivers/usb/typec/typec_wcove.c| 4 +- include/linux/usb/tcpm.h | 9 -- 5 files changed, 86 insertions(+), 81 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 2/5] usb: typec: fusb302: remove max_snk_* for sink config
Since max_snk_* is to be deprecated, so remove max_snk_* by adding a variable PDO for sink config. Reviewed-by: Hans de GoedeSigned-off-by: Li Jun --- drivers/usb/typec/fusb302/fusb302.c | 34 -- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c index 7036171..893f9e5 100644 --- a/drivers/usb/typec/fusb302/fusb302.c +++ b/drivers/usb/typec/fusb302/fusb302.c @@ -120,6 +120,7 @@ struct fusb302_chip { enum typec_cc_polarity cc_polarity; enum typec_cc_status cc1; enum typec_cc_status cc2; + u32 snk_pdo[PDO_MAX_OBJECTS]; #ifdef CONFIG_DEBUG_FS struct dentry *dentry; @@ -1212,11 +1213,6 @@ static const u32 snk_pdo[] = { static const struct tcpc_config fusb302_tcpc_config = { .src_pdo = src_pdo, .nr_src_pdo = ARRAY_SIZE(src_pdo), - .snk_pdo = snk_pdo, - .nr_snk_pdo = ARRAY_SIZE(snk_pdo), - .max_snk_mv = 5000, - .max_snk_ma = 3000, - .max_snk_mw = 15000, .operating_snk_mw = 2500, .type = TYPEC_PORT_DRP, .data = TYPEC_PORT_DRD, @@ -1756,6 +1752,21 @@ static int init_gpio(struct fusb302_chip *chip) return 0; } +static int fusb302_composite_snk_pdo_array(struct fusb302_chip *chip) +{ + struct device *dev = chip->dev; + u32 max_uv, max_ua; + + chip->snk_pdo[0] = PDO_FIXED(5000, 400, PDO_FIXED_FLAGS); + + if (device_property_read_u32(dev, "fcs,max-sink-microvolt", _uv) || + device_property_read_u32(dev, "fcs,max-sink-microamp", _ua)) + return 1; + + chip->snk_pdo[1] = PDO_VAR(5000, max_uv / 1000, max_ua / 1000); + return 2; +} + static int fusb302_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1784,18 +1795,13 @@ static int fusb302_probe(struct i2c_client *client, chip->tcpc_dev.config = >tcpc_config; mutex_init(>lock); - if (!device_property_read_u32(dev, "fcs,max-sink-microvolt", )) - chip->tcpc_config.max_snk_mv = v / 1000; - - if (!device_property_read_u32(dev, "fcs,max-sink-microamp", )) - chip->tcpc_config.max_snk_ma = v / 1000; - - if (!device_property_read_u32(dev, "fcs,max-sink-microwatt", )) - chip->tcpc_config.max_snk_mw = v / 1000; - if (!device_property_read_u32(dev, "fcs,operating-sink-microwatt", )) chip->tcpc_config.operating_snk_mw = v / 1000; + /* Composite sink PDO */ + chip->tcpc_config.nr_snk_pdo = fusb302_composite_snk_pdo_array(chip); + chip->tcpc_config.snk_pdo = chip->snk_pdo; + /* * Devicetree platforms should get extcon via phandle (not yet * supported). On ACPI platforms, we get the name from a device prop. -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: patch 8466489ef5ba48272ba4fa4ea9f8f403306de4c7 breaks Renesas USB3 controller functionality
On Thu, 2018-04-12 at 07:20 +0200, Ard Biesheuvel wrote: > On 12 April 2018 at 07:05, Bockholdt Arne >wrote: > > > > On Wed, 2018-04-11 at 15:02 +0100, Marc Zyngier wrote: > > > > On Wed, 11 Apr 2018 14:11:52 +0100, > > Bockholdt Arne wrote: > > > > > > Hi all, > > > > is there anything new, I've just tried the new stable 4.16.1 kernel > > without any change. The Renesys USB3 controller is still not > > functional. I'm willing to test any patch that is based on a stable > > kernel version because the machine is in production use. > > > > > > Have you tested the branch[1] I mentioned in my previous email? > > Without your feedback, I cannot really make much progress on this. > > > > Thanks, > > > > M. > > > > [1] https://www.spinics.net/lists/linux-usb/msg167301.html > > > > > > It seems the repo is based on 3.9 kernel and not on a current > > stable branch, > > isn't it? It's rather old, I'm not sure my setup will work with > > this old > > kernel. > > > > Are you sure you pulled the correct branch? usb/uPD720202-reset has > the following on top of *v4.16-rc6* > > Revert "xhci: Reset Renesas uPD72020x USB controller for 32-bit DMA > issue" > xhci: Add quirk to zero 64bit registers on Renesas PCIe controllers > > (https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm- > platforms.git/log/?h=usb/uPD720202-reset) I've tested the kernel from your git repo and it works. I've booted the kernel, attached an USB3.0 disk and copied some GBs from it without any problems. Here's the dmesg XHCI output. [1.567220] xhci_hcd :03:00.0: xHCI Host Controller [1.567238] xhci_hcd :03:00.0: new USB bus registered, assigned bus number 2 [1.567264] xhci_hcd :03:00.0: Zeroing 64bit base registers, expecting fault [1.609421] xhci_hcd :03:00.0: hcc params 0x014051cf hci version 0x100 quirks 0x8410 [1.609931] usb usb2: Manufacturer: Linux 4.16.0-rc6-serverv4+ xhci- hcd [1.610469] xhci_hcd :03:00.0: xHCI Host Controller [1.610479] xhci_hcd :03:00.0: new USB bus registered, assigned bus number 3 [1.613068] usb usb3: Manufacturer: Linux 4.16.0-rc6-serverv4+ xhc i-hcd Thanks, Arne N�r��yb�X��ǧv�^�){.n�+{��^n�r���z���h�&���G���h�(�階�ݢj"���m��z�ޖ���f���h���~�m�
[PATCH] xhci: Fix Kernel oops in xhci dbgtty
From: Zhengjun Xingtty_unregister_driver may be called more than 1 time in some hotplug cases,it will cause the kernel oops. This patch checked dbc_tty_driver to make sure it is unregistered only 1 time. [ 175.741404] BUG: unable to handle kernel NULL pointer dereference at 0034 [ 175.742309] IP: tty_unregister_driver+0x9/0x70 [ 175.743148] PGD 0 P4D 0 [ 175.743981] Oops: [#1] SMP PTI [ 175.753904] RIP: 0010:tty_unregister_driver+0x9/0x70 [ 175.754817] RSP: 0018:a8ff831d3bb0 EFLAGS: 00010246 [ 175.755753] RAX: RBX: RCX: [ 175.756685] RDX: 92089c616000 RSI: e64fe1b26080 RDI: [ 175.757608] RBP: 92086c988230 R08: 6c982701 R09: 0001801e0016 [ 175.758533] R10: a8ff831d3b48 R11: 92086c982100 R12: 92086c98827c [ 175.759462] R13: 92086c988398 R14: 0060 R15: 92089c5e9b40 [ 175.760401] FS: () GS:9208a010() knlGS: [ 175.761334] CS: 0010 DS: ES: CR0: 80050033 [ 175.762270] CR2: 0034 CR3: 00011800a003 CR4: 003606e0 [ 175.763225] DR0: DR1: DR2: [ 175.764164] DR3: DR6: fffe0ff0 DR7: 0400 [ 175.765091] Call Trace: [ 175.766014] xhci_dbc_tty_unregister_driver+0x11/0x30 [ 175.766960] xhci_dbc_exit+0x2a/0x40 [ 175.767889] xhci_stop+0x57/0x1c0 [ 175.768824] usb_remove_hcd+0x100/0x250 [ 175.769708] usb_hcd_pci_remove+0x68/0x130 [ 175.770574] pci_device_remove+0x3b/0xc0 [ 175.771435] device_release_driver_internal+0x157/0x230 [ 175.772343] pci_stop_bus_device+0x74/0xa0 [ 175.773205] pci_stop_bus_device+0x2b/0xa0 [ 175.774061] pci_stop_bus_device+0x2b/0xa0 [ 175.774907] pci_stop_bus_device+0x2b/0xa0 [ 175.775741] pci_stop_bus_device+0x2b/0xa0 [ 175.776618] pci_stop_bus_device+0x2b/0xa0 [ 175.777452] pci_stop_bus_device+0x2b/0xa0 [ 175.778273] pci_stop_bus_device+0x2b/0xa0 [ 175.779092] pci_stop_bus_device+0x2b/0xa0 [ 175.779908] pci_stop_bus_device+0x2b/0xa0 [ 175.780750] pci_stop_bus_device+0x2b/0xa0 [ 175.781543] pci_stop_and_remove_bus_device+0xe/0x20 [ 175.782338] pciehp_unconfigure_device+0xb8/0x160 [ 175.783128] pciehp_disable_slot+0x4f/0xd0 [ 175.783920] pciehp_power_thread+0x82/0xa0 [ 175.784766] process_one_work+0x147/0x3c0 [ 175.785564] worker_thread+0x4a/0x440 [ 175.786376] kthread+0xf8/0x130 [ 175.787174] ? rescuer_thread+0x360/0x360 [ 175.787964] ? kthread_associate_blkcg+0x90/0x90 [ 175.788798] ret_from_fork+0x35/0x40 Cc: # 4.16 Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver") Signed-off-by: Zhengjun Xing Tested-by: Christian Kellner Reviewed-by: Christian Kellner Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-dbgtty.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 48779c4..eb494ec5 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -320,9 +320,11 @@ int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci) void xhci_dbc_tty_unregister_driver(void) { - tty_unregister_driver(dbc_tty_driver); - put_tty_driver(dbc_tty_driver); - dbc_tty_driver = NULL; + if (dbc_tty_driver) { + tty_unregister_driver(dbc_tty_driver); + put_tty_driver(dbc_tty_driver); + dbc_tty_driver = NULL; + } } static void dbc_rx_push(unsigned long _port) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 01/13] dt-bindings: connector: add properties for typec
2018-04-03 16:29 GMT+08:00 Andrzej Hajda: > > On 28.03.2018 18:06, Li Jun wrote: > > Add bingdings supported by current typec driver, so user can pass > > all those properties via dt. > > > > Signed-off-by: Li Jun > > --- > > .../bindings/connector/usb-connector.txt | 39 > > ++ > > 1 file changed, 39 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/connector/usb-connector.txt > > b/Documentation/devicetree/bindings/connector/usb-connector.txt > > index e1463f1..922f22b 100644 > > --- a/Documentation/devicetree/bindings/connector/usb-connector.txt > > +++ b/Documentation/devicetree/bindings/connector/usb-connector.txt > > @@ -15,6 +15,29 @@ Optional properties: > > - type: size of the connector, should be specified in case of USB-A, USB-B > >non-fullsize connectors: "mini", "micro". > > > > +Optional properties for usb-c-connector: > > +- power-type: should be one of "source", "sink" or "dual"(DRP) if typec > > + connector has power support. > > +- try-power-role: preferred power role if "dual"(DRP) can support Try.SNK > > + or Try.SRC, should be "sink" for Try.SNK or "source" for Try.SRC. > > +- data-type: should be one of "host", "device", "dual"(DRD) if typec > > + connector supports USB data. > > + > > +Required properties for usb-c-connector with power delivery support: > > +- source-pdos: An array of u32 with each entry providing supported power > > + source data object(PDO), the detailed bit definitions of PDO can be found > > + in "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.2 > > + Source_Capabilities Message, the order of each entry(PDO) should follow > > + the PD spec chapter 6.4.1. Required for power source and power dual role. > > +- sink-pdos: An array of u32 with each entry providing supported power > > + sink data object(PDO), the detailed bit definitions of PDO can be found > > + in "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.3 > > + Sink Capabilities Message, the order of each entry(PDO) should follow > > + the PD spec chapter 6.4.1. Required for power sink and power dual role. > > +- op-sink-microwatt-hours: Sink required operating power in micro > > + watt-hours, if source offered power is less then it, Capability Mismatch > > + is set, required for power sink and power dual role. > > I have lurked into specs and I am not sure what is the relation of this > field with PD protocol, there is Minimum Operating Power, Maximum > Operating Power and Operating Power present in different RDOs, there are > also similar fields in sink PDOs. > I guess it can be one of them, which one? Per current usage of op-sink-microwatt(operating_snk_mw in tcpm), this property is actually for max operating power, which is only used to judge capability mismatch, i.e. the required max current/power is larger than the selected source PDO can provide. After checking the PD spec about this, basically I think this property also can be removed, we can judge the capability mismatch by compare the selected source pdo and sink pdo, considering there are existing users of this field(operating_snk_mw in tcpm), I will check how this can be done. I am removing the other 3 max_snk_*, see [1] [1] https://www.spinics.net/lists/linux-usb/msg167262.html > why other ones are not > provided? What if this or any other property can be calculated only in > runtime? > I am not sure if any of them should be marked "required". > > > + > > Required nodes: > > - any data bus to the connector should be modeled using the OF graph > > bindings > >specified in bindings/graph.txt, unless the bus is between parent node > > and > > @@ -73,3 +96,19 @@ ccic: s2mm005@33 { > > }; > > }; > > }; > > + > > +3. USB-C connector attached to a typec port controller(ptn5110), which has > > +power delivery support and enables drp. > > + > > +typec: ptn5110@50 { > > + ... > > + usb_con: connector { > > + compatible = "usb-c-connector"; > > + label = "USB-C"; > > + power-type = "dual"; > > + try-power-role = "sink"; > > + source-pdos = <0x380190c8>; > > I understand from DT specification point of view cryptic numbers are OK, > but for sake of readability I strongly suggest use/define macros similar > to the ones present already in kernel: > source-pdos = < PDO_FIXED(5000, 400, PDO_FIXED_FLAGS) >; I agree it's easier to read, so with the proposed way, we need maintain a copy of those macros for dts(e.g. under dt-binding/usb/pd.h), right? thanks Jun > > It much less error prone, and makes review process much more easier. > > Regards > Andrzej > > > + sink-pdos = <0x380190c8 0x3802d0c8>; > > + op-sink-microwatt-hours = <900>; > > + }; > > +}; > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majord...@vger.kernel.org
Re: [PATCH v3 0/5] usb: typec: remove max_snk_mv/ma/mw
Hi, On 13-04-18 07:55, Li Jun wrote: This patch set is to remove max_snk_mv/ma/mw configs, as we should define the sink capability by sink PDOs, the first patch update the source PDO match policy by compare the voltage range between source and sink PDOs no matter what type they are, the following patchs remove those 3 variables from 2 existing users by adding a variable PDO, then finial patch remove the max_snk_* from tcpm. Changes for v3: - Remove 3 variables: nr_fxied, nr_var and nr_batt from tcpm_port; so nr_type_pdos() is not needed and removed. - Simplify fusb302_composite_snk_pdo_array() by only considering existing setting as Hans suggested. - Add Rob's reviewed-by for dt-binding patch. Changes for v2: - rebase the 1st patch to be based on commit 6f566af34628 ("Revert "typec: tcpm: Only request matching pdos""). - Convert the device properties passing max_snk_* to be a variable sink pdo for fusb302. Thank you for your work on this, v3 of the series looks good to me: Reviewed-by: Hans de GoedeRegards, Hans -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Chip Idea host usb hub port power switching
Hi, I was trying to get the USB Hub Port Power Switching to work, when I came across an - apparently - odd behavior: If CI_HDRC_TURN_VBUS_EARLY_ON is enabled[0], the regulator (reg_vbus) is not remembered and thus not switchable by the ehci_ci_portpower routine[1] later on. Is this behavior intended? If so, what's the reason behind it? I wanted to ask, before I create a patch, so that patch would be correct. [0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/chipidea/host.c#n140 [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/chipidea/host.c#n30 Best regards, Leif MIDDELSCHULTE
Re: [RFT/PATCH 18/38] usb: dwc3: gadget: check for Missed Isoc from event status
Hi, Thinh Nguyenwrites: >>> Maybe we should return the -EXDEV status every time there's a missed isoc. >> >> you mean like this? > > Yes, this will work. updated to branch -- balbi signature.asc Description: PGP signature
Re: [PATCH] Revert "xhci: plat: Register shutdown for xhci_plat"
On 13 April 2018 11:51:28 AM IST, Greg Kroah-Hartmanwrote: >On Fri, Apr 13, 2018 at 08:12:31AM +0530, Harsh Shandilya wrote: >> On 13 April 2018 5:59:51 AM IST, Greg Hackmann >wrote: >> >Pixel 2 field testers reported that when they tried to reboot their >> >phones with some USB devices plugged in, the reboot would get wedged >> >and >> >eventually trigger watchdog reset. Once the Pixel kernel team found >a >> >reliable repro case, they narrowed it down to this commit's 4.4.y >> >backport. Reverting the change made the issue go away. >> >> Are you allowed to make the repro steps public? I'm writing this from >> a walleye and would be grateful if I could test for this in the >> modifed tree I'm running atm. -- > >I was told the steps are pretty simple: > - reboot the phone a lot >eventually it will hang. There's a fix in the code aurora kernel tree >for this that they never sent upstream for some odd reason (they sent >the first patch, why not the second?) > >I'll go revert this for now, thanks for the patch! > >greg k-h That'd make sense, I only tried rebooting like five times before I had to run for a class. As far as CAF is concerned, I feel the not submitting upstream, working extra to write patches which have usually better variants already upstream, seems to be common. All USB changes were dropped when they merged kernel-common into msm-3.18 with no real explanation which has been an annoyance more than once during merging -stable in my fork of msm-3.18. While I understand their situation of maintaining upwards of 5 million lines of code not upstream, it still feels sloppy to not merge stable updates and do extra work instead. /* End rant */ -- Harsh Shandilya, PRJKT Development LLC -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Revert "xhci: plat: Register shutdown for xhci_plat"
On Fri, Apr 13, 2018 at 08:12:31AM +0530, Harsh Shandilya wrote: > On 13 April 2018 5:59:51 AM IST, Greg Hackmannwrote: > >Pixel 2 field testers reported that when they tried to reboot their > >phones with some USB devices plugged in, the reboot would get wedged > >and > >eventually trigger watchdog reset. Once the Pixel kernel team found a > >reliable repro case, they narrowed it down to this commit's 4.4.y > >backport. Reverting the change made the issue go away. > > Are you allowed to make the repro steps public? I'm writing this from > a walleye and would be grateful if I could test for this in the > modifed tree I'm running atm. -- I was told the steps are pretty simple: - reboot the phone a lot eventually it will hang. There's a fix in the code aurora kernel tree for this that they never sent upstream for some odd reason (they sent the first patch, why not the second?) I'll go revert this for now, thanks for the patch! greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 2/5] usb: typec: fusb302: remove max_snk_* for sink config
Since max_snk_* is to be deprecated, so remove max_snk_* by adding a variable PDO for sink config. Signed-off-by: Li Jun--- drivers/usb/typec/fusb302/fusb302.c | 34 -- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c index 7036171..893f9e5 100644 --- a/drivers/usb/typec/fusb302/fusb302.c +++ b/drivers/usb/typec/fusb302/fusb302.c @@ -120,6 +120,7 @@ struct fusb302_chip { enum typec_cc_polarity cc_polarity; enum typec_cc_status cc1; enum typec_cc_status cc2; + u32 snk_pdo[PDO_MAX_OBJECTS]; #ifdef CONFIG_DEBUG_FS struct dentry *dentry; @@ -1212,11 +1213,6 @@ static const u32 snk_pdo[] = { static const struct tcpc_config fusb302_tcpc_config = { .src_pdo = src_pdo, .nr_src_pdo = ARRAY_SIZE(src_pdo), - .snk_pdo = snk_pdo, - .nr_snk_pdo = ARRAY_SIZE(snk_pdo), - .max_snk_mv = 5000, - .max_snk_ma = 3000, - .max_snk_mw = 15000, .operating_snk_mw = 2500, .type = TYPEC_PORT_DRP, .data = TYPEC_PORT_DRD, @@ -1756,6 +1752,21 @@ static int init_gpio(struct fusb302_chip *chip) return 0; } +static int fusb302_composite_snk_pdo_array(struct fusb302_chip *chip) +{ + struct device *dev = chip->dev; + u32 max_uv, max_ua; + + chip->snk_pdo[0] = PDO_FIXED(5000, 400, PDO_FIXED_FLAGS); + + if (device_property_read_u32(dev, "fcs,max-sink-microvolt", _uv) || + device_property_read_u32(dev, "fcs,max-sink-microamp", _ua)) + return 1; + + chip->snk_pdo[1] = PDO_VAR(5000, max_uv / 1000, max_ua / 1000); + return 2; +} + static int fusb302_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1784,18 +1795,13 @@ static int fusb302_probe(struct i2c_client *client, chip->tcpc_dev.config = >tcpc_config; mutex_init(>lock); - if (!device_property_read_u32(dev, "fcs,max-sink-microvolt", )) - chip->tcpc_config.max_snk_mv = v / 1000; - - if (!device_property_read_u32(dev, "fcs,max-sink-microamp", )) - chip->tcpc_config.max_snk_ma = v / 1000; - - if (!device_property_read_u32(dev, "fcs,max-sink-microwatt", )) - chip->tcpc_config.max_snk_mw = v / 1000; - if (!device_property_read_u32(dev, "fcs,operating-sink-microwatt", )) chip->tcpc_config.operating_snk_mw = v / 1000; + /* Composite sink PDO */ + chip->tcpc_config.nr_snk_pdo = fusb302_composite_snk_pdo_array(chip); + chip->tcpc_config.snk_pdo = chip->snk_pdo; + /* * Devicetree platforms should get extcon via phandle (not yet * supported). On ACPI platforms, we get the name from a device prop. -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 3/5] dt-bindings: usb: fusb302: remove max-sink-* properties
Remove max-sink-* properties since they are deprecated. Reviewed-by: Rob HerringSigned-off-by: Li Jun --- Documentation/devicetree/bindings/usb/fcs,fusb302.txt | 6 -- 1 file changed, 6 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt index 472facf..6087dc7 100644 --- a/Documentation/devicetree/bindings/usb/fcs,fusb302.txt +++ b/Documentation/devicetree/bindings/usb/fcs,fusb302.txt @@ -6,12 +6,6 @@ Required properties : - interrupts : Interrupt specifier Optional properties : -- fcs,max-sink-microvolt : Maximum voltage to negotiate when configured as sink -- fcs,max-sink-microamp : Maximum current to negotiate when configured as sink -- fcs,max-sink-microwatt : Maximum power to negotiate when configured as sink - If this is less then max-sink-microvolt * - max-sink-microamp then the configured current will - be clamped. - fcs,operating-sink-microwatt : Minimum amount of power accepted from a sink when negotiating -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 5/5] usb: typec: tcpm: remove max_snk_mv/ma/mw
Since there is no user of max_snk_*, so we can remove them from tcpm. Signed-off-by: Li Jun--- drivers/usb/typec/tcpm.c | 12 include/linux/usb/tcpm.h | 9 - 2 files changed, 21 deletions(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index c127339..3d9cfd6 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -257,9 +257,6 @@ struct tcpm_port { u32 snk_vdo[VDO_MAX_OBJECTS]; unsigned int nr_snk_vdo; - unsigned int max_snk_mv; - unsigned int max_snk_ma; - unsigned int max_snk_mw; unsigned int operating_snk_mw; /* Requested current / voltage */ @@ -3597,9 +3594,6 @@ EXPORT_SYMBOL_GPL(tcpm_update_source_capabilities); int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, unsigned int nr_pdo, - unsigned int max_snk_mv, - unsigned int max_snk_ma, - unsigned int max_snk_mw, unsigned int operating_snk_mw) { if (tcpm_validate_caps(port, pdo, nr_pdo)) @@ -3607,9 +3601,6 @@ int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, mutex_lock(>lock); port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, pdo, nr_pdo); - port->max_snk_mv = max_snk_mv; - port->max_snk_ma = max_snk_ma; - port->max_snk_mw = max_snk_mw; port->operating_snk_mw = operating_snk_mw; switch (port->state) { @@ -3675,9 +3666,6 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo, tcpc->config->nr_snk_vdo); - port->max_snk_mv = tcpc->config->max_snk_mv; - port->max_snk_ma = tcpc->config->max_snk_ma; - port->max_snk_mw = tcpc->config->max_snk_mw; port->operating_snk_mw = tcpc->config->operating_snk_mw; if (!tcpc->config->try_role_hw) port->try_role = tcpc->config->default_role; diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index f0d839d..f5bda9a 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -62,9 +62,6 @@ enum tcpm_transmit_type { * @snk_pdo: PDO parameters sent to partner as response to * PD_CTRL_GET_SINK_CAP message * @nr_snk_pdo:Number of entries in @snk_pdo - * @max_snk_mv:Maximum acceptable sink voltage in mV - * @max_snk_ma:Maximum sink current in mA - * @max_snk_mw:Maximum required sink power in mW * @operating_snk_mw: * Required operating sink power in mW * @type: Port type (TYPEC_PORT_DFP, TYPEC_PORT_UFP, or @@ -85,9 +82,6 @@ struct tcpc_config { const u32 *snk_vdo; unsigned int nr_snk_vdo; - unsigned int max_snk_mv; - unsigned int max_snk_ma; - unsigned int max_snk_mw; unsigned int operating_snk_mw; enum typec_port_type type; @@ -174,9 +168,6 @@ int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, unsigned int nr_pdo); int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, unsigned int nr_pdo, - unsigned int max_snk_mv, - unsigned int max_snk_ma, - unsigned int max_snk_mw, unsigned int operating_snk_mw); void tcpm_vbus_change(struct tcpm_port *port); -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 0/5] usb: typec: remove max_snk_mv/ma/mw
This patch set is to remove max_snk_mv/ma/mw configs, as we should define the sink capability by sink PDOs, the first patch update the source PDO match policy by compare the voltage range between source and sink PDOs no matter what type they are, the following patchs remove those 3 variables from 2 existing users by adding a variable PDO, then finial patch remove the max_snk_* from tcpm. Changes for v3: - Remove 3 variables: nr_fxied, nr_var and nr_batt from tcpm_port; so nr_type_pdos() is not needed and removed. - Simplify fusb302_composite_snk_pdo_array() by only considering existing setting as Hans suggested. - Add Rob's reviewed-by for dt-binding patch. Changes for v2: - rebase the 1st patch to be based on commit 6f566af34628 ("Revert "typec: tcpm: Only request matching pdos""). - Convert the device properties passing max_snk_* to be a variable sink pdo for fusb302. Li Jun (5): usb: typec: tcpm: pdo matching optimization usb: typec: fusb302: remove max_snk_* for sink config dt-bindings: usb: fusb302: remove max-sink-* properties usb: typec: wcove: remove max_snk_* for sink config usb: typec: tcpm: remove max_snk_mv/ma/mw .../devicetree/bindings/usb/fcs,fusb302.txt| 6 -- drivers/usb/typec/fusb302/fusb302.c| 34 +++--- drivers/usb/typec/tcpm.c | 114 - drivers/usb/typec/typec_wcove.c| 4 +- include/linux/usb/tcpm.h | 9 -- 5 files changed, 86 insertions(+), 81 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 4/5] usb: typec: wcove: remove max_snk_* for sink config
Since max_snk_* is to be deprecated, so remove max_snk_* by adding a variable PDO for sink config. Signed-off-by: Li Jun--- drivers/usb/typec/typec_wcove.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/typec/typec_wcove.c b/drivers/usb/typec/typec_wcove.c index 19cca7f..39cff11 100644 --- a/drivers/usb/typec/typec_wcove.c +++ b/drivers/usb/typec/typec_wcove.c @@ -558,6 +558,7 @@ static const u32 src_pdo[] = { static const u32 snk_pdo[] = { PDO_FIXED(5000, 500, PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP | PDO_FIXED_USB_COMM), + PDO_VAR(5000, 12000, 3000), }; static struct tcpc_config wcove_typec_config = { @@ -566,9 +567,6 @@ static struct tcpc_config wcove_typec_config = { .snk_pdo = snk_pdo, .nr_snk_pdo = ARRAY_SIZE(snk_pdo), - .max_snk_mv = 12000, - .max_snk_ma = 3000, - .max_snk_mw = 36000, .operating_snk_mw = 15000, .type = TYPEC_PORT_DRP, -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/5] usb: typec: tcpm: pdo matching optimization
This patch is a combination of commit 57e6f0d7b804 ("typec: tcpm: Only request matching pdos") and source pdo selection optimization based on it, instead of only compare between the same pdo type of sink and source, we should check source pdo voltage range is within the voltage range of one sink pdo. Signed-off-by: Li Jun--- drivers/usb/typec/tcpm.c | 102 ++- 1 file changed, 65 insertions(+), 37 deletions(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 677d121..c127339 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -1772,40 +1772,65 @@ static int tcpm_pd_check_request(struct tcpm_port *port) return 0; } -static int tcpm_pd_select_pdo(struct tcpm_port *port) +#define min_power(x, y) min(pdo_max_power(x), pdo_max_power(y)) +#define min_current(x, y) min(pdo_max_current(x), pdo_max_current(y)) + +static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, + int *src_pdo) { - unsigned int i, max_mw = 0, max_mv = 0; + unsigned int i, j, max_src_mv = 0, min_src_mv = 0, max_mw = 0, +max_mv = 0, src_mw = 0, src_ma = 0, max_snk_mv = 0, +min_snk_mv = 0; int ret = -EINVAL; /* -* Select the source PDO providing the most power while staying within -* the board's voltage limits. Prefer PDO providing exp +* Select the source PDO providing the most power which has a +* matchig sink cap. */ for (i = 0; i < port->nr_source_caps; i++) { u32 pdo = port->source_caps[i]; enum pd_pdo_type type = pdo_type(pdo); - unsigned int mv, ma, mw; - if (type == PDO_TYPE_FIXED) - mv = pdo_fixed_voltage(pdo); - else - mv = pdo_min_voltage(pdo); + if (type == PDO_TYPE_FIXED) { + max_src_mv = pdo_fixed_voltage(pdo); + min_src_mv = max_src_mv; + } else { + max_src_mv = pdo_max_voltage(pdo); + min_src_mv = pdo_min_voltage(pdo); + } if (type == PDO_TYPE_BATT) { - mw = pdo_max_power(pdo); + src_mw = pdo_max_power(pdo); } else { - ma = min(pdo_max_current(pdo), -port->max_snk_ma); - mw = ma * mv / 1000; + src_ma = pdo_max_current(pdo); + src_mw = src_ma * min_src_mv / 1000; } - /* Perfer higher voltages if available */ - if ((mw > max_mw || (mw == max_mw && mv > max_mv)) && - mv <= port->max_snk_mv) { - ret = i; - max_mw = mw; - max_mv = mv; + for (j = 0; j < port->nr_snk_pdo; j++) { + pdo = port->snk_pdo[j]; + + if (pdo_type(pdo) == PDO_TYPE_FIXED) { + min_snk_mv = pdo_fixed_voltage(pdo); + max_snk_mv = pdo_fixed_voltage(pdo); + } else { + min_snk_mv = pdo_min_voltage(pdo); + max_snk_mv = pdo_max_voltage(pdo); + } + + if (max_src_mv <= max_snk_mv && + min_src_mv >= min_snk_mv) { + /* Prefer higher voltages if available */ + if ((src_mw == max_mw && min_src_mv > max_mv) || + src_mw > max_mw) { + *src_pdo = i; + *sink_pdo = j; + max_mw = src_mw; + max_mv = min_src_mv; + } + break; + } } + } return ret; @@ -1816,13 +1841,14 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo) unsigned int mv, ma, mw, flags; unsigned int max_ma, max_mw; enum pd_pdo_type type; - int index; - u32 pdo; + int src_pdo_index, snk_pdo_index; + u32 pdo, matching_snk_pdo; - index = tcpm_pd_select_pdo(port); - if (index < 0) + if (tcpm_pd_select_pdo(port, _pdo_index, _pdo_index) < 0) return -EINVAL; - pdo = port->source_caps[index]; + + pdo = port->source_caps[src_pdo_index]; + matching_snk_pdo = port->snk_pdo[snk_pdo_index]; type = pdo_type(pdo); if (type == PDO_TYPE_FIXED) @@ -1830,26 +1856,28 @@ static int tcpm_pd_build_request(struct tcpm_port