Thread (18 messages) 18 messages, 3 authors, 2018-06-26

RE: [PATCH v7 06/14] usb: typec: tcpm: support get typec and pd config from device properties

From: Adam Thomson <hidden>
Date: 2018-06-25 10:45:55
Also in: linux-usb

On 25 June 2018 09:09, Li Jun wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
 drivers/usb/typec/tcpm.c | 132 +++++++++++++++++++++++++++++++++++++++-----
---
 1 file changed, 110 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index d22b37b..0454654 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;
 }
...
quoted hunk ↗ jump to hunk
 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,19 @@ 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;
+	if (tcpc->config)
+		err = tcpm_copy_caps(port, tcpc->config);
+	else
+		err = tcpm_fw_get_caps(port, tcpc->fwnode);
+	if (err < 0)
Should we not be favouring the generic FW based capabilities over values defined
in a Type C port controller driver, if the FW config is present? For example
fusb302 driver has a hard coded config so that would always be selected rather
than the FW based config, unless I'm missing something obvious?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help