Re: [PATCH] usb: typec: Separate the definitions for data and power roles
On Mon, Mar 12, 2018 at 10:27:19AM +0200, Heikki Krogerus wrote: > On Fri, Mar 09, 2018 at 09:41:38AM -0800, Greg Kroah-Hartman wrote: > > On Fri, Mar 09, 2018 at 02:09:18PM +0300, Heikki Krogerus wrote: > > > USB Type-C specification v1.2 separated the power and data > > > roles more clearly. Dual-Role-Data term was introduced, and > > > the meaning of DRP was changed from "Dual-Role-Port" to > > > "Dual-Role-Power". > > > > > > In order to allow the port drivers to describe the > > > capabilities of the ports more clearly according to the > > > newest specifications, introducing separate definitions for > > > the data roles. > > > > > > Signed-off-by: Heikki Krogerus> > > Reviewed-by: Guenter Roeck > > > --- > > > drivers/usb/typec/class.c | 56 > > > ++--- > > > > This file isn't in the tree, what tree/branch did you make this patch > > against? > > > > confused, > > The patch was made on top of the series we prepared with Hans for the > USB muxes [1], which I totally failed to point out. Sorry for that. > > Since we need one more round (v7) with those to make the API changes > you proposed to the device-connection support, I'll just add this > patch to that series. I hope that's okay. That would be fine, thanks. 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
Re: [PATCH] usb: typec: Separate the definitions for data and power roles
On Fri, Mar 09, 2018 at 09:41:38AM -0800, Greg Kroah-Hartman wrote: > On Fri, Mar 09, 2018 at 02:09:18PM +0300, Heikki Krogerus wrote: > > USB Type-C specification v1.2 separated the power and data > > roles more clearly. Dual-Role-Data term was introduced, and > > the meaning of DRP was changed from "Dual-Role-Port" to > > "Dual-Role-Power". > > > > In order to allow the port drivers to describe the > > capabilities of the ports more clearly according to the > > newest specifications, introducing separate definitions for > > the data roles. > > > > Signed-off-by: Heikki Krogerus> > Reviewed-by: Guenter Roeck > > --- > > drivers/usb/typec/class.c | 56 > > ++--- > > This file isn't in the tree, what tree/branch did you make this patch > against? > > confused, The patch was made on top of the series we prepared with Hans for the USB muxes [1], which I totally failed to point out. Sorry for that. Since we need one more round (v7) with those to make the API changes you proposed to the device-connection support, I'll just add this patch to that series. I hope that's okay. [1] https://lkml.org/lkml/2018/3/2/340 Thanks, -- heikki -- 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] usb: typec: Separate the definitions for data and power roles
On Fri, Mar 09, 2018 at 02:09:18PM +0300, Heikki Krogerus wrote: > USB Type-C specification v1.2 separated the power and data > roles more clearly. Dual-Role-Data term was introduced, and > the meaning of DRP was changed from "Dual-Role-Port" to > "Dual-Role-Power". > > In order to allow the port drivers to describe the > capabilities of the ports more clearly according to the > newest specifications, introducing separate definitions for > the data roles. > > Signed-off-by: Heikki Krogerus> Reviewed-by: Guenter Roeck > --- > drivers/usb/typec/class.c | 56 > ++--- This file isn't in the tree, what tree/branch did you make this patch against? confused, 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
Re: [PATCH] usb: typec: Separate the definitions for data and power roles
On Fri, Mar 09, 2018 at 02:09:18PM +0300, Heikki Krogerus wrote: > USB Type-C specification v1.2 separated the power and data > roles more clearly. Dual-Role-Data term was introduced, and > the meaning of DRP was changed from "Dual-Role-Port" to > "Dual-Role-Power". > > In order to allow the port drivers to describe the > capabilities of the ports more clearly according to the > newest specifications, introducing separate definitions for > the data roles. > > Signed-off-by: Heikki KrogerusReviewed-by: Guenter Roeck > --- > drivers/usb/typec/class.c | 56 > ++--- > drivers/usb/typec/fusb302/fusb302.c | 1 + > drivers/usb/typec/tcpm.c| 9 +++--- > drivers/usb/typec/tps6598x.c| 26 +++-- > drivers/usb/typec/typec_wcove.c | 1 + > drivers/usb/typec/ucsi/ucsi.c | 13 +++-- > include/linux/usb/tcpm.h| 1 + > include/linux/usb/typec.h | 14 -- > 8 files changed, 80 insertions(+), 41 deletions(-) > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > index 2620a694704f..53df10df2f9d 100644 > --- a/drivers/usb/typec/class.c > +++ b/drivers/usb/typec/class.c > @@ -282,10 +282,10 @@ typec_altmode_roles_show(struct device *dev, struct > device_attribute *attr, > ssize_t ret; > > switch (mode->roles) { > - case TYPEC_PORT_DFP: > + case TYPEC_PORT_SRC: > ret = sprintf(buf, "source\n"); > break; > - case TYPEC_PORT_UFP: > + case TYPEC_PORT_SNK: > ret = sprintf(buf, "sink\n"); > break; > case TYPEC_PORT_DRP: > @@ -797,14 +797,14 @@ static const char * const typec_data_roles[] = { > }; > > static const char * const typec_port_types[] = { > - [TYPEC_PORT_DFP] = "source", > - [TYPEC_PORT_UFP] = "sink", > + [TYPEC_PORT_SRC] = "source", > + [TYPEC_PORT_SNK] = "sink", > [TYPEC_PORT_DRP] = "dual", > }; > > static const char * const typec_port_types_drp[] = { > - [TYPEC_PORT_DFP] = "dual [source] sink", > - [TYPEC_PORT_UFP] = "dual source [sink]", > + [TYPEC_PORT_SRC] = "dual [source] sink", > + [TYPEC_PORT_SNK] = "dual source [sink]", > [TYPEC_PORT_DRP] = "[dual] source sink", > }; > > @@ -875,9 +875,7 @@ static ssize_t data_role_store(struct device *dev, > return ret; > > mutex_lock(>port_type_lock); > - if (port->port_type != TYPEC_PORT_DRP) { > - dev_dbg(dev, "port type fixed at \"%s\"", > - typec_port_types[port->port_type]); > + if (port->cap->data != TYPEC_PORT_DRD) { > ret = -EOPNOTSUPP; > goto unlock_and_ret; > } > @@ -897,7 +895,7 @@ static ssize_t data_role_show(struct device *dev, > { > struct typec_port *port = to_typec_port(dev); > > - if (port->cap->type == TYPEC_PORT_DRP) > + if (port->cap->data == TYPEC_PORT_DRD) > return sprintf(buf, "%s\n", port->data_role == TYPEC_HOST ? > "[host] device" : "host [device]"); > > @@ -1328,7 +1326,6 @@ struct typec_port *typec_register_port(struct device > *parent, > const struct typec_capability *cap) > { > struct typec_port *port; > - int role; > int ret; > int id; > > @@ -1354,21 +1351,36 @@ struct typec_port *typec_register_port(struct device > *parent, > goto err_mux; > } > > - if (cap->type == TYPEC_PORT_DFP) > - role = TYPEC_SOURCE; > - else if (cap->type == TYPEC_PORT_UFP) > - role = TYPEC_SINK; > - else > - role = cap->prefer_role; > - > - if (role == TYPEC_SOURCE) { > - port->data_role = TYPEC_HOST; > + switch (cap->type) { > + case TYPEC_PORT_SRC: > port->pwr_role = TYPEC_SOURCE; > port->vconn_role = TYPEC_SOURCE; > - } else { > - port->data_role = TYPEC_DEVICE; > + break; > + case TYPEC_PORT_SNK: > port->pwr_role = TYPEC_SINK; > port->vconn_role = TYPEC_SINK; > + break; > + case TYPEC_PORT_DRP: > + if (cap->prefer_role != TYPEC_NO_PREFERRED_ROLE) > + port->pwr_role = cap->prefer_role; > + else > + port->pwr_role = TYPEC_SINK; > + break; > + } > + > + switch (cap->data) { > + case TYPEC_PORT_DFP: > + port->data_role = TYPEC_HOST; > + break; > + case TYPEC_PORT_UFP: > + port->data_role = TYPEC_DEVICE; > + break; > + case TYPEC_PORT_DRD: > + if (cap->prefer_role == TYPEC_SOURCE) > + port->data_role = TYPEC_HOST; > + else > + port->data_role = TYPEC_DEVICE; > + break; > } > >
[PATCH] usb: typec: Separate the definitions for data and power roles
USB Type-C specification v1.2 separated the power and data roles more clearly. Dual-Role-Data term was introduced, and the meaning of DRP was changed from "Dual-Role-Port" to "Dual-Role-Power". In order to allow the port drivers to describe the capabilities of the ports more clearly according to the newest specifications, introducing separate definitions for the data roles. Signed-off-by: Heikki Krogerus--- drivers/usb/typec/class.c | 56 ++--- drivers/usb/typec/fusb302/fusb302.c | 1 + drivers/usb/typec/tcpm.c| 9 +++--- drivers/usb/typec/tps6598x.c| 26 +++-- drivers/usb/typec/typec_wcove.c | 1 + drivers/usb/typec/ucsi/ucsi.c | 13 +++-- include/linux/usb/tcpm.h| 1 + include/linux/usb/typec.h | 14 -- 8 files changed, 80 insertions(+), 41 deletions(-) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 2620a694704f..53df10df2f9d 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -282,10 +282,10 @@ typec_altmode_roles_show(struct device *dev, struct device_attribute *attr, ssize_t ret; switch (mode->roles) { - case TYPEC_PORT_DFP: + case TYPEC_PORT_SRC: ret = sprintf(buf, "source\n"); break; - case TYPEC_PORT_UFP: + case TYPEC_PORT_SNK: ret = sprintf(buf, "sink\n"); break; case TYPEC_PORT_DRP: @@ -797,14 +797,14 @@ static const char * const typec_data_roles[] = { }; static const char * const typec_port_types[] = { - [TYPEC_PORT_DFP] = "source", - [TYPEC_PORT_UFP] = "sink", + [TYPEC_PORT_SRC] = "source", + [TYPEC_PORT_SNK] = "sink", [TYPEC_PORT_DRP] = "dual", }; static const char * const typec_port_types_drp[] = { - [TYPEC_PORT_DFP] = "dual [source] sink", - [TYPEC_PORT_UFP] = "dual source [sink]", + [TYPEC_PORT_SRC] = "dual [source] sink", + [TYPEC_PORT_SNK] = "dual source [sink]", [TYPEC_PORT_DRP] = "[dual] source sink", }; @@ -875,9 +875,7 @@ static ssize_t data_role_store(struct device *dev, return ret; mutex_lock(>port_type_lock); - if (port->port_type != TYPEC_PORT_DRP) { - dev_dbg(dev, "port type fixed at \"%s\"", -typec_port_types[port->port_type]); + if (port->cap->data != TYPEC_PORT_DRD) { ret = -EOPNOTSUPP; goto unlock_and_ret; } @@ -897,7 +895,7 @@ static ssize_t data_role_show(struct device *dev, { struct typec_port *port = to_typec_port(dev); - if (port->cap->type == TYPEC_PORT_DRP) + if (port->cap->data == TYPEC_PORT_DRD) return sprintf(buf, "%s\n", port->data_role == TYPEC_HOST ? "[host] device" : "host [device]"); @@ -1328,7 +1326,6 @@ struct typec_port *typec_register_port(struct device *parent, const struct typec_capability *cap) { struct typec_port *port; - int role; int ret; int id; @@ -1354,21 +1351,36 @@ struct typec_port *typec_register_port(struct device *parent, goto err_mux; } - if (cap->type == TYPEC_PORT_DFP) - role = TYPEC_SOURCE; - else if (cap->type == TYPEC_PORT_UFP) - role = TYPEC_SINK; - else - role = cap->prefer_role; - - if (role == TYPEC_SOURCE) { - port->data_role = TYPEC_HOST; + switch (cap->type) { + case TYPEC_PORT_SRC: port->pwr_role = TYPEC_SOURCE; port->vconn_role = TYPEC_SOURCE; - } else { - port->data_role = TYPEC_DEVICE; + break; + case TYPEC_PORT_SNK: port->pwr_role = TYPEC_SINK; port->vconn_role = TYPEC_SINK; + break; + case TYPEC_PORT_DRP: + if (cap->prefer_role != TYPEC_NO_PREFERRED_ROLE) + port->pwr_role = cap->prefer_role; + else + port->pwr_role = TYPEC_SINK; + break; + } + + switch (cap->data) { + case TYPEC_PORT_DFP: + port->data_role = TYPEC_HOST; + break; + case TYPEC_PORT_UFP: + port->data_role = TYPEC_DEVICE; + break; + case TYPEC_PORT_DRD: + if (cap->prefer_role == TYPEC_SOURCE) + port->data_role = TYPEC_HOST; + else + port->data_role = TYPEC_DEVICE; + break; } port->id = id; diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c index b267b907bf24..76c9d955fa40 100644 --- a/drivers/usb/typec/fusb302/fusb302.c +++ b/drivers/usb/typec/fusb302/fusb302.c @@