summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorBiju Das <biju.das.jz@bp.renesas.com>2020-09-20 16:49:03 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-02 16:28:18 +0300
commita6806e32e7a41c20c6b288009cb6f30929668327 (patch)
tree35fd55e3e5986566a55f260ee959852b9667e726 /drivers/usb
parent1c6e8ee63adbaf02a1e5177610fe9b77bec93d8a (diff)
downloadlinux-a6806e32e7a41c20c6b288009cb6f30929668327.tar.xz
usb: typec: hd3ss3220: Use OF graph API to get the connector fwnode
Some platforms have only super speed data bus connected to this device and high speed data bus directly connected to the SoC. In such platforms modelling connector as a child of this device is making it non compliant with usb connector bindings. By modelling connector node as standalone device node along with this device and the SoC data bus will make it compliant with usb connector bindings. Update the driver to handle this model by using OF graph API to get the connector fwnode and usb role switch class API to get role switch handle. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20200920134905.4370-5-biju.das.jz@bp.renesas.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/typec/hd3ss3220.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c
index 323dfa8160ab..f633ec15b1a1 100644
--- a/drivers/usb/typec/hd3ss3220.c
+++ b/drivers/usb/typec/hd3ss3220.c
@@ -155,7 +155,7 @@ static int hd3ss3220_probe(struct i2c_client *client,
{
struct typec_capability typec_cap = { };
struct hd3ss3220 *hd3ss3220;
- struct fwnode_handle *connector;
+ struct fwnode_handle *connector, *ep;
int ret;
unsigned int data;
@@ -173,11 +173,21 @@ static int hd3ss3220_probe(struct i2c_client *client,
hd3ss3220_set_source_pref(hd3ss3220,
HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_DEFAULT);
+ /* For backward compatibility check the connector child node first */
connector = device_get_named_child_node(hd3ss3220->dev, "connector");
- if (!connector)
- return -ENODEV;
+ if (connector) {
+ hd3ss3220->role_sw = fwnode_usb_role_switch_get(connector);
+ } else {
+ ep = fwnode_graph_get_next_endpoint(dev_fwnode(hd3ss3220->dev), NULL);
+ if (!ep)
+ return -ENODEV;
+ connector = fwnode_graph_get_remote_port_parent(ep);
+ fwnode_handle_put(ep);
+ if (!connector)
+ return -ENODEV;
+ hd3ss3220->role_sw = usb_role_switch_get(hd3ss3220->dev);
+ }
- hd3ss3220->role_sw = fwnode_usb_role_switch_get(connector);
if (IS_ERR(hd3ss3220->role_sw)) {
ret = PTR_ERR(hd3ss3220->role_sw);
goto err_put_fwnode;