From c6919d5e0cd168a732034d8dc19fdc3dff683a2b Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Tue, 8 Oct 2019 15:25:59 +0300 Subject: usb: roles: Add usb_role_switch_find_by_fwnode() Simple wrapper function that searches USB role switches with class_find_device_by_fwnode(). Signed-off-by: Heikki Krogerus Reviewed-by: Hans de Goede Tested-by: Hans de Goede Link: https://lore.kernel.org/r/20191008122600.22340-2-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- include/linux/usb/role.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h index 2d77f97df72d..efac3af83d6b 100644 --- a/include/linux/usb/role.h +++ b/include/linux/usb/role.h @@ -50,6 +50,9 @@ struct usb_role_switch *usb_role_switch_get(struct device *dev); struct usb_role_switch *fwnode_usb_role_switch_get(struct fwnode_handle *node); void usb_role_switch_put(struct usb_role_switch *sw); +struct usb_role_switch * +usb_role_switch_find_by_fwnode(const struct fwnode_handle *fwnode); + struct usb_role_switch * usb_role_switch_register(struct device *parent, const struct usb_role_switch_desc *desc); -- cgit v1.2.3 From 8c127a42af89c39560a8c5bd5accadaaa5741f8c Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Mon, 4 Nov 2019 17:24:19 +0300 Subject: usb: typec: Introduce typec_get_drvdata() Leaving the private driver_data pointer of the port device to the port drivers. Signed-off-by: Heikki Krogerus Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20191104142435.29960-3-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/class.c | 11 +++++++++++ include/linux/usb/typec.h | 4 ++++ 2 files changed, 15 insertions(+) (limited to 'include') diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 7749933ffce5..51154634c2c0 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1488,6 +1488,16 @@ EXPORT_SYMBOL_GPL(typec_set_mode); /* --------------------------------------- */ +/** + * typec_get_drvdata - Return private driver data pointer + * @port: USB Type-C port + */ +void *typec_get_drvdata(struct typec_port *port) +{ + return dev_get_drvdata(&port->dev); +} +EXPORT_SYMBOL_GPL(typec_get_drvdata); + /** * typec_port_register_altmode - Register USB Type-C Port Alternate Mode * @port: USB Type-C Port that supports the alternate mode @@ -1591,6 +1601,7 @@ struct typec_port *typec_register_port(struct device *parent, port->dev.fwnode = cap->fwnode; port->dev.type = &typec_port_dev_type; dev_set_name(&port->dev, "port%d", id); + dev_set_drvdata(&port->dev, cap->driver_data); port->cap = kmemdup(cap, sizeof(*cap), GFP_KERNEL); if (!port->cap) { diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 7df4ecabc78a..8b90cd77331c 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -179,6 +179,7 @@ struct typec_partner_desc { * @sw: Cable plug orientation switch * @mux: Multiplexer switch for Alternate/Accessory Modes * @fwnode: Optional fwnode of the port + * @driver_data: Private pointer for driver specific info * @try_role: Set data role preference for DRP port * @dr_set: Set Data Role * @pr_set: Set Power Role @@ -198,6 +199,7 @@ struct typec_capability { struct typec_switch *sw; struct typec_mux *mux; struct fwnode_handle *fwnode; + void *driver_data; int (*try_role)(const struct typec_capability *, int role); @@ -241,6 +243,8 @@ int typec_set_orientation(struct typec_port *port, enum typec_orientation typec_get_orientation(struct typec_port *port); int typec_set_mode(struct typec_port *port, int mode); +void *typec_get_drvdata(struct typec_port *port); + int typec_find_port_power_role(const char *name); int typec_find_power_role(const char *name); int typec_find_port_data_role(const char *name); -- cgit v1.2.3 From 46310e4dade2bc3b574d540e421e3aa9f32cfd5f Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Mon, 4 Nov 2019 17:24:20 +0300 Subject: usb: typec: Separate the operations vector Introducing struct typec_operations which has the same callbacks as struct typec_capability. The old callbacks are kept for now, but after all users have been converted, they will be removed. Signed-off-by: Heikki Krogerus Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20191104142435.29960-4-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/class.c | 39 +++++++++++++++++++++++++++++---------- include/linux/usb/typec.h | 20 ++++++++++++++++++++ 2 files changed, 49 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 51154634c2c0..b934a006535a 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -54,6 +54,7 @@ struct typec_port { const struct typec_capability *orig_cap; /* to be removed */ const struct typec_capability *cap; + const struct typec_operations *ops; }; #define to_typec_port(_dev_) container_of(_dev_, struct typec_port, dev) @@ -956,7 +957,7 @@ preferred_role_store(struct device *dev, struct device_attribute *attr, return -EOPNOTSUPP; } - if (!port->cap->try_role) { + if (!port->cap->try_role && (!port->ops || !port->ops->try_role)) { dev_dbg(dev, "Setting preferred role not supported\n"); return -EOPNOTSUPP; } @@ -969,7 +970,10 @@ preferred_role_store(struct device *dev, struct device_attribute *attr, return -EINVAL; } - ret = port->cap->try_role(port->orig_cap, role); + if (port->ops && port->ops->try_role) + ret = port->ops->try_role(port, role); + else + ret = port->cap->try_role(port->orig_cap, role); if (ret) return ret; @@ -1000,7 +1004,7 @@ static ssize_t data_role_store(struct device *dev, struct typec_port *port = to_typec_port(dev); int ret; - if (!port->cap->dr_set) { + if (!port->cap->dr_set && (!port->ops || !port->ops->dr_set)) { dev_dbg(dev, "data role swapping not supported\n"); return -EOPNOTSUPP; } @@ -1015,7 +1019,10 @@ static ssize_t data_role_store(struct device *dev, goto unlock_and_ret; } - ret = port->cap->dr_set(port->orig_cap, ret); + if (port->ops && port->ops->dr_set) + ret = port->ops->dr_set(port, ret); + else + ret = port->cap->dr_set(port->orig_cap, ret); if (ret) goto unlock_and_ret; @@ -1050,7 +1057,7 @@ static ssize_t power_role_store(struct device *dev, return -EOPNOTSUPP; } - if (!port->cap->pr_set) { + if (!port->cap->pr_set && (!port->ops || !port->ops->pr_set)) { dev_dbg(dev, "power role swapping not supported\n"); return -EOPNOTSUPP; } @@ -1072,7 +1079,10 @@ static ssize_t power_role_store(struct device *dev, goto unlock_and_ret; } - ret = port->cap->pr_set(port->orig_cap, ret); + if (port->ops && port->ops->dr_set) + ret = port->ops->pr_set(port, ret); + else + ret = port->cap->pr_set(port->orig_cap, ret); if (ret) goto unlock_and_ret; @@ -1103,7 +1113,8 @@ port_type_store(struct device *dev, struct device_attribute *attr, int ret; enum typec_port_type type; - if (!port->cap->port_type_set || port->cap->type != TYPEC_PORT_DRP) { + if (port->cap->type != TYPEC_PORT_DRP || (!port->cap->port_type_set && + (!port->ops || !port->ops->port_type_set))) { dev_dbg(dev, "changing port type not supported\n"); return -EOPNOTSUPP; } @@ -1120,7 +1131,10 @@ port_type_store(struct device *dev, struct device_attribute *attr, goto unlock_and_ret; } - ret = port->cap->port_type_set(port->orig_cap, type); + if (port->ops && port->ops->port_type_set) + ret = port->ops->port_type_set(port, type); + else + ret = port->cap->port_type_set(port->orig_cap, type); if (ret) goto unlock_and_ret; @@ -1176,7 +1190,7 @@ static ssize_t vconn_source_store(struct device *dev, return -EOPNOTSUPP; } - if (!port->cap->vconn_set) { + if (!port->cap->vconn_set && (!port->ops || !port->ops->vconn_set)) { dev_dbg(dev, "VCONN swapping not supported\n"); return -EOPNOTSUPP; } @@ -1185,7 +1199,11 @@ static ssize_t vconn_source_store(struct device *dev, if (ret) return ret; - ret = port->cap->vconn_set(port->orig_cap, (enum typec_role)source); + if (port->ops && port->ops->vconn_set) + ret = port->ops->vconn_set(port, (enum typec_role)source); + else + ret = port->cap->vconn_set(port->orig_cap, + (enum typec_role)source); if (ret) return ret; @@ -1591,6 +1609,7 @@ struct typec_port *typec_register_port(struct device *parent, mutex_init(&port->port_type_lock); port->id = id; + port->ops = cap->ops; port->orig_cap = cap; port->port_type = cap->type; port->prefer_role = cap->prefer_role; diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 8b90cd77331c..c9bef128453b 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -168,6 +168,23 @@ struct typec_partner_desc { struct usb_pd_identity *identity; }; +/** + * struct typec_operations - USB Type-C Port Operations + * @try_role: Set data role preference for DRP port + * @dr_set: Set Data Role + * @pr_set: Set Power Role + * @vconn_set: Source VCONN + * @port_type_set: Set port type + */ +struct typec_operations { + int (*try_role)(struct typec_port *port, int role); + int (*dr_set)(struct typec_port *port, enum typec_data_role role); + int (*pr_set)(struct typec_port *port, enum typec_role role); + int (*vconn_set)(struct typec_port *port, enum typec_role role); + int (*port_type_set)(struct typec_port *port, + enum typec_port_type type); +}; + /* * struct typec_capability - USB Type-C Port Capabilities * @type: Supported power role of the port @@ -180,6 +197,7 @@ struct typec_partner_desc { * @mux: Multiplexer switch for Alternate/Accessory Modes * @fwnode: Optional fwnode of the port * @driver_data: Private pointer for driver specific info + * @ops: Port operations vector * @try_role: Set data role preference for DRP port * @dr_set: Set Data Role * @pr_set: Set Power Role @@ -201,6 +219,8 @@ struct typec_capability { struct fwnode_handle *fwnode; void *driver_data; + const struct typec_operations *ops; + int (*try_role)(const struct typec_capability *, int role); -- cgit v1.2.3 From 8c038ea8b65fc803cd35423b8a1ff7057dd52f8b Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Mon, 4 Nov 2019 17:24:25 +0300 Subject: usb: typec: Remove the callback members from struct typec_capability There are no more users for them. Signed-off-by: Heikki Krogerus Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20191104142435.29960-9-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/class.c | 40 +++++++++++----------------------------- include/linux/usb/typec.h | 17 ----------------- 2 files changed, 11 insertions(+), 46 deletions(-) (limited to 'include') diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index b934a006535a..7ece6ca6e690 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -52,7 +52,6 @@ struct typec_port { struct typec_switch *sw; struct typec_mux *mux; - const struct typec_capability *orig_cap; /* to be removed */ const struct typec_capability *cap; const struct typec_operations *ops; }; @@ -957,7 +956,7 @@ preferred_role_store(struct device *dev, struct device_attribute *attr, return -EOPNOTSUPP; } - if (!port->cap->try_role && (!port->ops || !port->ops->try_role)) { + if (!port->ops || !port->ops->try_role) { dev_dbg(dev, "Setting preferred role not supported\n"); return -EOPNOTSUPP; } @@ -970,10 +969,7 @@ preferred_role_store(struct device *dev, struct device_attribute *attr, return -EINVAL; } - if (port->ops && port->ops->try_role) - ret = port->ops->try_role(port, role); - else - ret = port->cap->try_role(port->orig_cap, role); + ret = port->ops->try_role(port, role); if (ret) return ret; @@ -1004,7 +1000,7 @@ static ssize_t data_role_store(struct device *dev, struct typec_port *port = to_typec_port(dev); int ret; - if (!port->cap->dr_set && (!port->ops || !port->ops->dr_set)) { + if (!port->ops || !port->ops->dr_set) { dev_dbg(dev, "data role swapping not supported\n"); return -EOPNOTSUPP; } @@ -1019,10 +1015,7 @@ static ssize_t data_role_store(struct device *dev, goto unlock_and_ret; } - if (port->ops && port->ops->dr_set) - ret = port->ops->dr_set(port, ret); - else - ret = port->cap->dr_set(port->orig_cap, ret); + ret = port->ops->dr_set(port, ret); if (ret) goto unlock_and_ret; @@ -1057,7 +1050,7 @@ static ssize_t power_role_store(struct device *dev, return -EOPNOTSUPP; } - if (!port->cap->pr_set && (!port->ops || !port->ops->pr_set)) { + if (!port->ops || !port->ops->pr_set) { dev_dbg(dev, "power role swapping not supported\n"); return -EOPNOTSUPP; } @@ -1079,10 +1072,7 @@ static ssize_t power_role_store(struct device *dev, goto unlock_and_ret; } - if (port->ops && port->ops->dr_set) - ret = port->ops->pr_set(port, ret); - else - ret = port->cap->pr_set(port->orig_cap, ret); + ret = port->ops->pr_set(port, ret); if (ret) goto unlock_and_ret; @@ -1113,8 +1103,8 @@ port_type_store(struct device *dev, struct device_attribute *attr, int ret; enum typec_port_type type; - if (port->cap->type != TYPEC_PORT_DRP || (!port->cap->port_type_set && - (!port->ops || !port->ops->port_type_set))) { + if (port->cap->type != TYPEC_PORT_DRP || + !port->ops || !port->ops->port_type_set) { dev_dbg(dev, "changing port type not supported\n"); return -EOPNOTSUPP; } @@ -1131,10 +1121,7 @@ port_type_store(struct device *dev, struct device_attribute *attr, goto unlock_and_ret; } - if (port->ops && port->ops->port_type_set) - ret = port->ops->port_type_set(port, type); - else - ret = port->cap->port_type_set(port->orig_cap, type); + ret = port->ops->port_type_set(port, type); if (ret) goto unlock_and_ret; @@ -1190,7 +1177,7 @@ static ssize_t vconn_source_store(struct device *dev, return -EOPNOTSUPP; } - if (!port->cap->vconn_set && (!port->ops || !port->ops->vconn_set)) { + if (!port->ops || !port->ops->vconn_set) { dev_dbg(dev, "VCONN swapping not supported\n"); return -EOPNOTSUPP; } @@ -1199,11 +1186,7 @@ static ssize_t vconn_source_store(struct device *dev, if (ret) return ret; - if (port->ops && port->ops->vconn_set) - ret = port->ops->vconn_set(port, (enum typec_role)source); - else - ret = port->cap->vconn_set(port->orig_cap, - (enum typec_role)source); + ret = port->ops->vconn_set(port, (enum typec_role)source); if (ret) return ret; @@ -1610,7 +1593,6 @@ struct typec_port *typec_register_port(struct device *parent, port->id = id; port->ops = cap->ops; - port->orig_cap = cap; port->port_type = cap->type; port->prefer_role = cap->prefer_role; diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index c9bef128453b..894798084319 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -198,11 +198,6 @@ struct typec_operations { * @fwnode: Optional fwnode of the port * @driver_data: Private pointer for driver specific info * @ops: Port operations vector - * @try_role: Set data role preference for DRP port - * @dr_set: Set Data Role - * @pr_set: Set Power Role - * @vconn_set: Set VCONN Role - * @port_type_set: Set port type * * Static capabilities of a single USB Type-C port. */ @@ -220,18 +215,6 @@ struct typec_capability { void *driver_data; const struct typec_operations *ops; - - int (*try_role)(const struct typec_capability *, - int role); - - int (*dr_set)(const struct typec_capability *, - enum typec_data_role); - int (*pr_set)(const struct typec_capability *, - enum typec_role); - int (*vconn_set)(const struct typec_capability *, - enum typec_role); - int (*port_type_set)(const struct typec_capability *, - enum typec_port_type); }; /* Specific to try_role(). Indicates the user want's to clear the preference. */ -- cgit v1.2.3 From 61d78ee29a0bf1078ebf5bbb2ccab7e7998d7410 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Mon, 4 Nov 2019 17:24:26 +0300 Subject: usb: typec: Remove unused members from struct typec_capability The members for the muxes are not used, so dropping them. Signed-off-by: Heikki Krogerus Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20191104142435.29960-10-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- include/linux/usb/typec.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 894798084319..0f52723a11bd 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -209,8 +209,6 @@ struct typec_capability { int prefer_role; enum typec_accessory accessory[TYPEC_MAX_ACCESSORY]; - struct typec_switch *sw; - struct typec_mux *mux; struct fwnode_handle *fwnode; void *driver_data; -- cgit v1.2.3 From a079973f462a3d506c6a7f00c770a55b167ed094 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 14 Nov 2019 12:18:40 +0100 Subject: usb: typec: tcpm: Remove tcpc_config configuration mechanism All configuration can and should be done through fwnodes instead of through the tcpc_config struct and there are no existing users left of struct tcpc_config, so lets remove it. Signed-off-by: Hans de Goede Reviewed-by: Heikki Krogerus Link: https://lore.kernel.org/r/20191114111840.40876-1-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 90 ++----------------------------------------- include/linux/usb/tcpm.h | 41 -------------------- 2 files changed, 3 insertions(+), 128 deletions(-) (limited to 'include') diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index bc9edb4c013b..56fc356bc55c 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -380,9 +380,6 @@ static enum tcpm_state tcpm_default_state(struct tcpm_port *port) return SNK_UNATTACHED; else if (port->try_role == TYPEC_SOURCE) return SRC_UNATTACHED; - else if (port->tcpc->config && - port->tcpc->config->default_role == TYPEC_SINK) - return SNK_UNATTACHED; /* Fall through to return SRC_UNATTACHED */ } else if (port->port_type == TYPEC_PORT_SNK) { return SNK_UNATTACHED; @@ -4122,7 +4119,7 @@ static int tcpm_try_role(struct typec_port *p, int role) mutex_lock(&port->lock); if (tcpc->try_role) ret = tcpc->try_role(tcpc, role); - if (!ret && (!tcpc->config || !tcpc->config->try_role_hw)) + if (!ret) port->try_role = role; port->try_src_count = 0; port->try_snk_count = 0; @@ -4366,34 +4363,6 @@ void tcpm_tcpc_reset(struct tcpm_port *port) } EXPORT_SYMBOL_GPL(tcpm_tcpc_reset); -static int tcpm_copy_pdos(u32 *dest_pdo, const u32 *src_pdo, - unsigned int nr_pdo) -{ - unsigned int i; - - if (nr_pdo > PDO_MAX_OBJECTS) - nr_pdo = PDO_MAX_OBJECTS; - - for (i = 0; i < nr_pdo; i++) - dest_pdo[i] = src_pdo[i]; - - return nr_pdo; -} - -static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo, - unsigned int nr_vdo) -{ - unsigned int i; - - if (nr_vdo > VDO_MAX_OBJECTS) - nr_vdo = VDO_MAX_OBJECTS; - - for (i = 0; i < nr_vdo; i++) - dest_vdo[i] = src_vdo[i]; - - return nr_vdo; -} - static int tcpm_fw_get_caps(struct tcpm_port *port, struct fwnode_handle *fwnode) { @@ -4696,35 +4665,10 @@ 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; - port->self_powered = tcfg->self_powered; - - return 0; -} - struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) { struct tcpm_port *port; - int i, err; + int err; if (!dev || !tcpc || !tcpc->get_vbus || !tcpc->set_cc || !tcpc->get_cc || @@ -4757,15 +4701,10 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) tcpm_debugfs_init(port); 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; - 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->try_role = port->typec_caps.prefer_role; port->typec_caps.fwnode = tcpc->fwnode; port->typec_caps.revision = 0x0120; /* Type-C spec release 1.2 */ @@ -4792,29 +4731,6 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) goto out_role_sw_put; } - if (tcpc->config && tcpc->config->alt_modes) { - const struct typec_altmode_desc *paltmode = tcpc->config->alt_modes; - - i = 0; - while (paltmode->svid && i < ARRAY_SIZE(port->port_altmode)) { - struct typec_altmode *alt; - - alt = typec_port_register_altmode(port->typec_port, - paltmode); - if (IS_ERR(alt)) { - tcpm_log(port, - "%s: failed to register port alternate mode 0x%x", - dev_name(dev), paltmode->svid); - break; - } - typec_altmode_set_drvdata(alt, port); - alt->ops = &tcpm_altmode_ops; - port->port_altmode[i] = alt; - i++; - paltmode++; - } - } - mutex_lock(&port->lock); tcpm_init(port); mutex_unlock(&port->lock); diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index f516955a0cf4..e7979c01c351 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -46,45 +46,6 @@ enum tcpm_transmit_type { TCPC_TX_BIST_MODE_2 = 7 }; -/** - * struct tcpc_config - Port configuration - * @src_pdo: PDO parameters sent to port partner as response to - * PD_CTRL_GET_SOURCE_CAP message - * @nr_src_pdo: Number of entries in @src_pdo - * @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 - * @operating_snk_mw: - * Required operating sink power in mW - * @type: Port type (TYPEC_PORT_DFP, TYPEC_PORT_UFP, or - * TYPEC_PORT_DRP) - * @default_role: - * Default port role (TYPEC_SINK or TYPEC_SOURCE). - * Set to TYPEC_NO_PREFERRED_ROLE if no default role. - * @try_role_hw:True if try.{Src,Snk} is implemented in hardware - * @alt_modes: List of supported alternate modes - */ -struct tcpc_config { - const u32 *src_pdo; - unsigned int nr_src_pdo; - - const u32 *snk_pdo; - unsigned int nr_snk_pdo; - - const u32 *snk_vdo; - unsigned int nr_snk_vdo; - - unsigned int operating_snk_mw; - - enum typec_port_type type; - enum typec_port_data data; - enum typec_role default_role; - bool try_role_hw; /* try.{src,snk} implemented in hardware */ - bool self_powered; /* port belongs to a self powered device */ - - const struct typec_altmode_desc *alt_modes; -}; - /* Mux state attributes */ #define TCPC_MUX_USB_ENABLED BIT(0) /* USB enabled */ #define TCPC_MUX_DP_ENABLED BIT(1) /* DP enabled */ @@ -92,7 +53,6 @@ struct tcpc_config { /** * 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: @@ -121,7 +81,6 @@ struct tcpc_config { * @mux: Pointer to multiplexer data */ struct tcpc_dev { - const struct tcpc_config *config; struct fwnode_handle *fwnode; int (*init)(struct tcpc_dev *dev); -- cgit v1.2.3