Message ID | 1530056732-9640-1-git-send-email-jun.li@nxp.com |
---|---|
Headers | show |
Series | staging: typec: tcpci: move out of staging | expand |
On 06/26/2018 04:45 PM, Li Jun wrote: > Add nxp ptn5110 typec controller compatible string: "nxp,ptn5110", > which is a standard tcpci chip with power delivery support. Meanwhile > remove "usb,tcpci" because it doesn't follow the binding format rule > and has not been used yet. > > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > Signed-off-by: Li Jun <jun.li@nxp.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/staging/typec/tcpci.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c > index 076d97e..dd29288 100644 > --- a/drivers/staging/typec/tcpci.c > +++ b/drivers/staging/typec/tcpci.c > @@ -575,7 +575,7 @@ MODULE_DEVICE_TABLE(i2c, tcpci_id); > > #ifdef CONFIG_OF > static const struct of_device_id tcpci_of_match[] = { > - { .compatible = "usb,tcpci", }, > + { .compatible = "nxp,ptn5110", }, > {}, > }; > MODULE_DEVICE_TABLE(of, tcpci_of_match); > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 06/26/2018 04:45 PM, Li Jun wrote: > Add fwnode handle to get the fwnode so we can get typec configs > it contains. > > Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > Signed-off-by: Li Jun <jun.li@nxp.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/staging/typec/tcpci.c | 7 +++++++ > drivers/usb/typec/tcpm.c | 1 + > include/linux/usb/tcpm.h | 2 ++ > 3 files changed, 10 insertions(+) > > diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c > index dd29288..e59547a 100644 > --- a/drivers/staging/typec/tcpci.c > +++ b/drivers/staging/typec/tcpci.c > @@ -10,6 +10,7 @@ > #include <linux/module.h> > #include <linux/i2c.h> > #include <linux/interrupt.h> > +#include <linux/property.h> > #include <linux/regmap.h> > #include <linux/usb/pd.h> > #include <linux/usb/tcpm.h> > @@ -474,6 +475,12 @@ static int tcpci_parse_config(struct tcpci *tcpci) > > /* TODO: Populate struct tcpc_config from ACPI/device-tree */ > tcpci->tcpc.config = &tcpci_tcpc_config; > + tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev, > + "connector"); > + if (!tcpci->tcpc.fwnode) { > + dev_err(tcpci->dev, "Can't find connector node.\n"); > + return -EINVAL; > + } > > return 0; > } > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c > index 8a201dd..d22b37b 100644 > --- a/drivers/usb/typec/tcpm.c > +++ b/drivers/usb/typec/tcpm.c > @@ -4576,6 +4576,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) > else > port->try_role = TYPEC_NO_PREFERRED_ROLE; > > + port->typec_caps.fwnode = tcpc->fwnode; > port->typec_caps.prefer_role = tcpc->config->default_role; > port->typec_caps.type = tcpc->config->type; > port->typec_caps.data = tcpc->config->data; > diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h > index b231b93..193920a 100644 > --- a/include/linux/usb/tcpm.h > +++ b/include/linux/usb/tcpm.h > @@ -110,6 +110,7 @@ enum tcpc_mux_mode { > /** > * struct tcpc_dev - Port configuration and callback functions > * @config: Pointer to port configuration > + * @fwnode: Pointer to port fwnode > * @get_vbus: Called to read current VBUS state > * @get_current_limit: > * Optional; called by the tcpm core when configured as a snk > @@ -138,6 +139,7 @@ enum tcpc_mux_mode { > */ > struct tcpc_dev { > const struct tcpc_config *config; > + struct fwnode_handle *fwnode; > > int (*init)(struct tcpc_dev *dev); > int (*get_vbus)(struct tcpc_dev *dev); > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 06/26/2018 04:45 PM, Li Jun wrote: > Since we will use config settings via device properties, so > remove the hard code tcpci_tcpc_config. > > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > Signed-off-by: Li Jun <jun.li@nxp.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/staging/typec/tcpci.c | 7 ------- > 1 file changed, 7 deletions(-) > > diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c > index e59547a..076498a 100644 > --- a/drivers/staging/typec/tcpci.c > +++ b/drivers/staging/typec/tcpci.c > @@ -464,17 +464,10 @@ static const struct regmap_config tcpci_regmap_config = { > .max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */ > }; > > -static const struct tcpc_config tcpci_tcpc_config = { > - .type = TYPEC_PORT_DFP, > - .default_role = TYPEC_SINK, > -}; > - > static int tcpci_parse_config(struct tcpci *tcpci) > { > tcpci->controls_vbus = true; /* XXX */ > > - /* TODO: Populate struct tcpc_config from ACPI/device-tree */ > - tcpci->tcpc.config = &tcpci_tcpc_config; > tcpci->tcpc.fwnode = device_get_named_child_node(tcpci->dev, > "connector"); > if (!tcpci->tcpc.fwnode) { > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 06/26/2018 04:45 PM, Li Jun wrote: > As tcpm_register_port() and tcpci_register_port() never return > NULL and NULL is not a success in this case, use IS_ERR() to check > the return value of both. > > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > Signed-off-by: Li Jun <jun.li@nxp.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/staging/typec/tcpci.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c > index 076498a..b63f147 100644 > --- a/drivers/staging/typec/tcpci.c > +++ b/drivers/staging/typec/tcpci.c > @@ -509,7 +509,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) > return ERR_PTR(err); > > tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc); > - if (PTR_ERR_OR_ZERO(tcpci->port)) > + if (IS_ERR(tcpci->port)) > return ERR_CAST(tcpci->port); > > return tcpci; > @@ -551,7 +551,7 @@ static int tcpci_probe(struct i2c_client *client, > return err; > > chip->tcpci = tcpci_register_port(&client->dev, &chip->data); > - if (PTR_ERR_OR_ZERO(chip->tcpci)) > + if (IS_ERR(chip->tcpci)) > return PTR_ERR(chip->tcpci); > > i2c_set_clientdata(client, chip); > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 06/26/2018 04:45 PM, Li Jun wrote: > From: Peter Chen <peter.chen@nxp.com> > > With that we can clear any pending events and the port is registered > so driver can be ready to handle typec events once we request irq. > > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > Signed-off-by: Peter Chen <peter.chen@nxp.com> > Signed-off-by: Li Jun <jun.li@nxp.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/staging/typec/tcpci.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c > index b63f147..3b35fce 100644 > --- a/drivers/staging/typec/tcpci.c > +++ b/drivers/staging/typec/tcpci.c > @@ -537,24 +537,27 @@ static int tcpci_probe(struct i2c_client *client, > if (IS_ERR(chip->data.regmap)) > return PTR_ERR(chip->data.regmap); > > + i2c_set_clientdata(client, chip); > + > /* Disable chip interrupts before requesting irq */ > err = regmap_raw_write(chip->data.regmap, TCPC_ALERT_MASK, &val, > sizeof(u16)); > if (err < 0) > return err; > > + chip->tcpci = tcpci_register_port(&client->dev, &chip->data); > + if (IS_ERR(chip->tcpci)) > + return PTR_ERR(chip->tcpci); > + > err = devm_request_threaded_irq(&client->dev, client->irq, NULL, > _tcpci_irq, > IRQF_ONESHOT | IRQF_TRIGGER_LOW, > dev_name(&client->dev), chip); > - if (err < 0) > + if (err < 0) { > + tcpci_unregister_port(chip->tcpci); > return err; > + } > > - chip->tcpci = tcpci_register_port(&client->dev, &chip->data); > - if (IS_ERR(chip->tcpci)) > - return PTR_ERR(chip->tcpci); > - > - i2c_set_clientdata(client, chip); > return 0; > } > > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 06/26/2018 04:45 PM, Li Jun wrote: > While set polarity, we should keep the disconnected cc line to be > open. > > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > Signed-off-by: Li Jun <jun.li@nxp.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/staging/typec/tcpci.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c > index 4d3b0ae..11c2d37 100644 > --- a/drivers/staging/typec/tcpci.c > +++ b/drivers/staging/typec/tcpci.c > @@ -185,15 +185,25 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc, > enum typec_cc_polarity polarity) > { > struct tcpci *tcpci = tcpc_to_tcpci(tcpc); > + unsigned int reg; > int ret; > > - ret = regmap_write(tcpci->regmap, TCPC_TCPC_CTRL, > - (polarity == TYPEC_POLARITY_CC2) ? > - TCPC_TCPC_CTRL_ORIENTATION : 0); > + /* Keep the disconnect cc line open */ > + ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, ®); > if (ret < 0) > return ret; > > - return 0; > + if (polarity == TYPEC_POLARITY_CC2) > + reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT; > + else > + reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT; > + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); > + if (ret < 0) > + return ret; > + > + return regmap_write(tcpci->regmap, TCPC_TCPC_CTRL, > + (polarity == TYPEC_POLARITY_CC2) ? > + TCPC_TCPC_CTRL_ORIENTATION : 0); > } > > static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable) > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 06/26/2018 04:45 PM, Li Jun wrote: > Move TCPCI(Typec port controller interface) driver and rt1711h > driver out of staging. > > Signed-off-by: Li Jun <jun.li@nxp.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/staging/Kconfig | 2 -- > drivers/staging/Makefile | 1 - > drivers/staging/typec/Kconfig | 22 ---------------------- > drivers/staging/typec/Makefile | 2 -- > drivers/staging/typec/TODO | 5 ----- > drivers/usb/typec/Kconfig | 15 +++++++++++++++ > drivers/usb/typec/Makefile | 2 ++ > drivers/{staging => usb}/typec/tcpci.c | 0 > drivers/{staging => usb}/typec/tcpci.h | 0 > drivers/{staging => usb}/typec/tcpci_rt1711h.c | 0 > 10 files changed, 17 insertions(+), 32 deletions(-) > > diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig > index 75a4804..af9a82f 100644 > --- a/drivers/staging/Kconfig > +++ b/drivers/staging/Kconfig > @@ -106,8 +106,6 @@ source "drivers/staging/greybus/Kconfig" > > source "drivers/staging/vc04_services/Kconfig" > > -source "drivers/staging/typec/Kconfig" > - > source "drivers/staging/vboxvideo/Kconfig" > > source "drivers/staging/pi433/Kconfig" > diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile > index e84959a..8479d47 100644 > --- a/drivers/staging/Makefile > +++ b/drivers/staging/Makefile > @@ -2,7 +2,6 @@ > # Makefile for staging directory > > obj-y += media/ > -obj-y += typec/ > obj-$(CONFIG_PRISM2_USB) += wlan-ng/ > obj-$(CONFIG_COMEDI) += comedi/ > obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/ > diff --git a/drivers/staging/typec/Kconfig b/drivers/staging/typec/Kconfig > deleted file mode 100644 > index 3aa981f..0000000 > --- a/drivers/staging/typec/Kconfig > +++ /dev/null > @@ -1,22 +0,0 @@ > -menu "USB Power Delivery and Type-C drivers" > - > -if TYPEC_TCPM > - > -config TYPEC_TCPCI > - tristate "Type-C Port Controller Interface driver" > - depends on I2C > - select REGMAP_I2C > - help > - Type-C Port Controller driver for TCPCI-compliant controller. > - > -config TYPEC_RT1711H > - tristate "Richtek RT1711H Type-C chip driver" > - select TYPEC_TCPCI > - help > - Richtek RT1711H Type-C chip driver that works with > - Type-C Port Controller Manager to provide USB PD and USB > - Type-C functionalities. > - > -endif > - > -endmenu > diff --git a/drivers/staging/typec/Makefile b/drivers/staging/typec/Makefile > deleted file mode 100644 > index 7803d48..0000000 > --- a/drivers/staging/typec/Makefile > +++ /dev/null > @@ -1,2 +0,0 @@ > -obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o > -obj-$(CONFIG_TYPEC_RT1711H) += tcpci_rt1711h.o > diff --git a/drivers/staging/typec/TODO b/drivers/staging/typec/TODO > deleted file mode 100644 > index 53fe2f7..0000000 > --- a/drivers/staging/typec/TODO > +++ /dev/null > @@ -1,5 +0,0 @@ > -tcpci: > -- Test with real hardware > - > -Please send patches to Guenter Roeck <linux@roeck-us.net> and copy > -Heikki Krogerus <heikki.krogerus@linux.intel.com>. > diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig > index 2c8eab1..972fd19 100644 > --- a/drivers/usb/typec/Kconfig > +++ b/drivers/usb/typec/Kconfig > @@ -56,6 +56,21 @@ config TYPEC_TCPM > > if TYPEC_TCPM > > +config TYPEC_TCPCI > + tristate "Type-C Port Controller Interface driver" > + depends on I2C > + select REGMAP_I2C > + help > + Type-C Port Controller driver for TCPCI-compliant controller. > + > +config TYPEC_RT1711H > + tristate "Richtek RT1711H Type-C chip driver" > + select TYPEC_TCPCI > + help > + Richtek RT1711H Type-C chip driver that works with > + Type-C Port Controller Manager to provide USB PD and USB > + Type-C functionalities. > + > source "drivers/usb/typec/fusb302/Kconfig" > > config TYPEC_WCOVE > diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile > index 1f599a6..46f86ee 100644 > --- a/drivers/usb/typec/Makefile > +++ b/drivers/usb/typec/Makefile > @@ -7,3 +7,5 @@ obj-$(CONFIG_TYPEC_WCOVE) += typec_wcove.o > obj-$(CONFIG_TYPEC_UCSI) += ucsi/ > obj-$(CONFIG_TYPEC_TPS6598X) += tps6598x.o > obj-$(CONFIG_TYPEC) += mux/ > +obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o > +obj-$(CONFIG_TYPEC_RT1711H) += tcpci_rt1711h.o > diff --git a/drivers/staging/typec/tcpci.c b/drivers/usb/typec/tcpci.c > similarity index 100% > rename from drivers/staging/typec/tcpci.c > rename to drivers/usb/typec/tcpci.c > diff --git a/drivers/staging/typec/tcpci.h b/drivers/usb/typec/tcpci.h > similarity index 100% > rename from drivers/staging/typec/tcpci.h > rename to drivers/usb/typec/tcpci.h > diff --git a/drivers/staging/typec/tcpci_rt1711h.c b/drivers/usb/typec/tcpci_rt1711h.c > similarity index 100% > rename from drivers/staging/typec/tcpci_rt1711h.c > rename to drivers/usb/typec/tcpci_rt1711h.c > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 27 June 2018 00:45, Li Jun wrote: > This patch adds support of get typec and power delivery config from > firmware description. > > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > Reviewed-by: Guenter Roeck <linux@roeck-us.net> > Signed-off-by: Li Jun <jun.li@nxp.com> Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> > --- > drivers/usb/typec/tcpm.c | 131 +++++++++++++++++++++++++++++++++++++++----- > --- > 1 file changed, 109 insertions(+), 22 deletions(-) > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c > index d22b37b..9dcab81 100644 > --- a/drivers/usb/typec/tcpm.c > +++ b/drivers/usb/typec/tcpm.c > @@ -4236,6 +4236,81 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 > *src_vdo, > return nr_vdo; > } > > +static int tcpm_fw_get_caps(struct tcpm_port *port, > + struct fwnode_handle *fwnode) > +{ > + const char *cap_str; > + int ret; > + u32 mw; > + > + if (!fwnode) > + return -EINVAL; > + > + /* USB data support is optional */ > + ret = fwnode_property_read_string(fwnode, "data-role", &cap_str); > + if (ret == 0) { > + port->typec_caps.data = typec_find_port_data_role(cap_str); > + if (port->typec_caps.data < 0) > + return -EINVAL; > + } > + > + ret = fwnode_property_read_string(fwnode, "power-role", &cap_str); > + if (ret < 0) > + return ret; > + > + port->typec_caps.type = typec_find_port_power_role(cap_str); > + if (port->typec_caps.type < 0) > + return -EINVAL; > + port->port_type = port->typec_caps.type; > + > + if (port->port_type == TYPEC_PORT_SNK) > + goto sink; > + > + /* Get source pdos */ > + ret = fwnode_property_read_u32_array(fwnode, "source-pdos", > + NULL, 0); > + if (ret <= 0) > + return -EINVAL; > + > + port->nr_src_pdo = min(ret, PDO_MAX_OBJECTS); > + ret = fwnode_property_read_u32_array(fwnode, "source-pdos", > + port->src_pdo, port->nr_src_pdo); > + if ((ret < 0) || tcpm_validate_caps(port, port->src_pdo, > + port->nr_src_pdo)) > + return -EINVAL; > + > + if (port->port_type == TYPEC_PORT_SRC) > + return 0; > + > + /* Get the preferred power role for DRP */ > + ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str); > + if (ret < 0) > + return ret; > + > + port->typec_caps.prefer_role = typec_find_power_role(cap_str); > + if (port->typec_caps.prefer_role < 0) > + return -EINVAL; > +sink: > + /* Get sink pdos */ > + ret = fwnode_property_read_u32_array(fwnode, "sink-pdos", > + NULL, 0); > + if (ret <= 0) > + return -EINVAL; > + > + port->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS); > + ret = fwnode_property_read_u32_array(fwnode, "sink-pdos", > + port->snk_pdo, port->nr_snk_pdo); > + if ((ret < 0) || tcpm_validate_caps(port, port->snk_pdo, > + port->nr_snk_pdo)) > + return -EINVAL; > + > + if (fwnode_property_read_u32(fwnode, "op-sink-microwatt", &mw) < 0) > + return -EINVAL; > + port->operating_snk_mw = mw / 1000; > + > + return 0; > +} > + > int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, > unsigned int nr_pdo) > { > @@ -4521,12 +4596,36 @@ static int devm_tcpm_psy_register(struct tcpm_port > *port) > return PTR_ERR_OR_ZERO(port->psy); > } > > +static int tcpm_copy_caps(struct tcpm_port *port, > + const struct tcpc_config *tcfg) > +{ > + if (tcpm_validate_caps(port, tcfg->src_pdo, tcfg->nr_src_pdo) || > + tcpm_validate_caps(port, tcfg->snk_pdo, tcfg->nr_snk_pdo)) > + return -EINVAL; > + > + port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcfg->src_pdo, > + tcfg->nr_src_pdo); > + port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcfg->snk_pdo, > + tcfg->nr_snk_pdo); > + > + port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcfg->snk_vdo, > + tcfg->nr_snk_vdo); > + > + port->operating_snk_mw = tcfg->operating_snk_mw; > + > + port->typec_caps.prefer_role = tcfg->default_role; > + port->typec_caps.type = tcfg->type; > + port->typec_caps.data = tcfg->data; > + > + return 0; > +} > + > struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) > { > struct tcpm_port *port; > int i, err; > > - if (!dev || !tcpc || !tcpc->config || > + if (!dev || !tcpc || > !tcpc->get_vbus || !tcpc->set_cc || !tcpc->get_cc || > !tcpc->set_polarity || !tcpc->set_vconn || !tcpc->set_vbus || > !tcpc->set_pd_rx || !tcpc->set_roles || !tcpc->pd_transmit) > @@ -4556,30 +4655,18 @@ struct tcpm_port *tcpm_register_port(struct device > *dev, struct tcpc_dev *tcpc) > init_completion(&port->pps_complete); > tcpm_debugfs_init(port); > > - if (tcpm_validate_caps(port, tcpc->config->src_pdo, > - tcpc->config->nr_src_pdo) || > - tcpm_validate_caps(port, tcpc->config->snk_pdo, > - tcpc->config->nr_snk_pdo)) { > - err = -EINVAL; > + err = tcpm_fw_get_caps(port, tcpc->fwnode); > + if ((err < 0) && tcpc->config) > + err = tcpm_copy_caps(port, tcpc->config); > + if (err < 0) > goto out_destroy_wq; > - } > - port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcpc->config->src_pdo, > - tcpc->config->nr_src_pdo); > - port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config- > >snk_pdo, > - tcpc->config->nr_snk_pdo); > - port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config- > >snk_vdo, > - tcpc->config->nr_snk_vdo); > - > - port->operating_snk_mw = tcpc->config->operating_snk_mw; > - if (!tcpc->config->try_role_hw) > - port->try_role = tcpc->config->default_role; > + > + if (!tcpc->config || !tcpc->config->try_role_hw) > + port->try_role = port->typec_caps.prefer_role; > else > port->try_role = TYPEC_NO_PREFERRED_ROLE; > > port->typec_caps.fwnode = tcpc->fwnode; > - port->typec_caps.prefer_role = tcpc->config->default_role; > - port->typec_caps.type = tcpc->config->type; > - port->typec_caps.data = tcpc->config->data; > port->typec_caps.revision = 0x0120; /* Type-C spec release 1.2 */ > port->typec_caps.pd_revision = 0x0300; /* USB-PD spec release 3.0 */ > port->typec_caps.dr_set = tcpm_dr_set; > @@ -4589,7 +4676,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, > struct tcpc_dev *tcpc) > port->typec_caps.port_type_set = tcpm_port_type_set; > > port->partner_desc.identity = &port->partner_ident; > - port->port_type = tcpc->config->type; > + port->port_type = port->typec_caps.type; > > port->role_sw = usb_role_switch_get(port->dev); > if (IS_ERR(port->role_sw)) { > @@ -4607,7 +4694,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, > struct tcpc_dev *tcpc) > goto out_destroy_wq; > } > > - if (tcpc->config->alt_modes) { > + if (tcpc->config && tcpc->config->alt_modes) { > const struct typec_altmode_desc *paltmode = tcpc->config- > >alt_modes; > > i = 0; > -- > 2.7.4 > > -- > To unsubscribe from this list: send the line "unsubscribe devicetree" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Jun 27, 2018 at 07:45:32AM +0800, Li Jun wrote: > Move TCPCI(Typec port controller interface) driver and rt1711h > driver out of staging. > > Signed-off-by: Li Jun <jun.li@nxp.com> Thanks Li! Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > --- > drivers/staging/Kconfig | 2 -- > drivers/staging/Makefile | 1 - > drivers/staging/typec/Kconfig | 22 ---------------------- > drivers/staging/typec/Makefile | 2 -- > drivers/staging/typec/TODO | 5 ----- > drivers/usb/typec/Kconfig | 15 +++++++++++++++ > drivers/usb/typec/Makefile | 2 ++ > drivers/{staging => usb}/typec/tcpci.c | 0 > drivers/{staging => usb}/typec/tcpci.h | 0 > drivers/{staging => usb}/typec/tcpci_rt1711h.c | 0 > 10 files changed, 17 insertions(+), 32 deletions(-) > > diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig > index 75a4804..af9a82f 100644 > --- a/drivers/staging/Kconfig > +++ b/drivers/staging/Kconfig > @@ -106,8 +106,6 @@ source "drivers/staging/greybus/Kconfig" > > source "drivers/staging/vc04_services/Kconfig" > > -source "drivers/staging/typec/Kconfig" > - > source "drivers/staging/vboxvideo/Kconfig" > > source "drivers/staging/pi433/Kconfig" > diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile > index e84959a..8479d47 100644 > --- a/drivers/staging/Makefile > +++ b/drivers/staging/Makefile > @@ -2,7 +2,6 @@ > # Makefile for staging directory > > obj-y += media/ > -obj-y += typec/ > obj-$(CONFIG_PRISM2_USB) += wlan-ng/ > obj-$(CONFIG_COMEDI) += comedi/ > obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/ > diff --git a/drivers/staging/typec/Kconfig b/drivers/staging/typec/Kconfig > deleted file mode 100644 > index 3aa981f..0000000 > --- a/drivers/staging/typec/Kconfig > +++ /dev/null > @@ -1,22 +0,0 @@ > -menu "USB Power Delivery and Type-C drivers" > - > -if TYPEC_TCPM > - > -config TYPEC_TCPCI > - tristate "Type-C Port Controller Interface driver" > - depends on I2C > - select REGMAP_I2C > - help > - Type-C Port Controller driver for TCPCI-compliant controller. > - > -config TYPEC_RT1711H > - tristate "Richtek RT1711H Type-C chip driver" > - select TYPEC_TCPCI > - help > - Richtek RT1711H Type-C chip driver that works with > - Type-C Port Controller Manager to provide USB PD and USB > - Type-C functionalities. > - > -endif > - > -endmenu > diff --git a/drivers/staging/typec/Makefile b/drivers/staging/typec/Makefile > deleted file mode 100644 > index 7803d48..0000000 > --- a/drivers/staging/typec/Makefile > +++ /dev/null > @@ -1,2 +0,0 @@ > -obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o > -obj-$(CONFIG_TYPEC_RT1711H) += tcpci_rt1711h.o > diff --git a/drivers/staging/typec/TODO b/drivers/staging/typec/TODO > deleted file mode 100644 > index 53fe2f7..0000000 > --- a/drivers/staging/typec/TODO > +++ /dev/null > @@ -1,5 +0,0 @@ > -tcpci: > -- Test with real hardware > - > -Please send patches to Guenter Roeck <linux@roeck-us.net> and copy > -Heikki Krogerus <heikki.krogerus@linux.intel.com>. > diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig > index 2c8eab1..972fd19 100644 > --- a/drivers/usb/typec/Kconfig > +++ b/drivers/usb/typec/Kconfig > @@ -56,6 +56,21 @@ config TYPEC_TCPM > > if TYPEC_TCPM > > +config TYPEC_TCPCI > + tristate "Type-C Port Controller Interface driver" > + depends on I2C > + select REGMAP_I2C > + help > + Type-C Port Controller driver for TCPCI-compliant controller. > + > +config TYPEC_RT1711H > + tristate "Richtek RT1711H Type-C chip driver" > + select TYPEC_TCPCI > + help > + Richtek RT1711H Type-C chip driver that works with > + Type-C Port Controller Manager to provide USB PD and USB > + Type-C functionalities. > + > source "drivers/usb/typec/fusb302/Kconfig" > > config TYPEC_WCOVE > diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile > index 1f599a6..46f86ee 100644 > --- a/drivers/usb/typec/Makefile > +++ b/drivers/usb/typec/Makefile > @@ -7,3 +7,5 @@ obj-$(CONFIG_TYPEC_WCOVE) += typec_wcove.o > obj-$(CONFIG_TYPEC_UCSI) += ucsi/ > obj-$(CONFIG_TYPEC_TPS6598X) += tps6598x.o > obj-$(CONFIG_TYPEC) += mux/ > +obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o > +obj-$(CONFIG_TYPEC_RT1711H) += tcpci_rt1711h.o > diff --git a/drivers/staging/typec/tcpci.c b/drivers/usb/typec/tcpci.c > similarity index 100% > rename from drivers/staging/typec/tcpci.c > rename to drivers/usb/typec/tcpci.c > diff --git a/drivers/staging/typec/tcpci.h b/drivers/usb/typec/tcpci.h > similarity index 100% > rename from drivers/staging/typec/tcpci.h > rename to drivers/usb/typec/tcpci.h > diff --git a/drivers/staging/typec/tcpci_rt1711h.c b/drivers/usb/typec/tcpci_rt1711h.c > similarity index 100% > rename from drivers/staging/typec/tcpci_rt1711h.c > rename to drivers/usb/typec/tcpci_rt1711h.c
On Wed, Jun 27, 2018 at 07:45:18AM +0800, Li Jun wrote: > This patch set attempts to move the tcpci drivers out of staging by fix > some tcpci driver issues and define typec and power delivery device > properties, the changes are verified on NXP PTN5110, which is a standard > tcpci typec port controller device with power delivery support, tested > power source and sink with drp config. Nice work, thanks for sticking with this. All now merged. greg k-h -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html