From patchwork Tue Aug 11 08:02:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 11708835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7E92109A for ; Tue, 11 Aug 2020 08:02:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B997120656 for ; Tue, 11 Aug 2020 08:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728322AbgHKICo (ORCPT ); Tue, 11 Aug 2020 04:02:44 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:51706 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728134AbgHKICn (ORCPT ); Tue, 11 Aug 2020 04:02:43 -0400 X-IronPort-AV: E=Sophos;i="5.75,460,1589209200"; d="scan'208";a="54355772" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Aug 2020 17:02:43 +0900 Received: from localhost.localdomain (unknown [172.29.52.148]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 736074007529; Tue, 11 Aug 2020 17:02:40 +0900 (JST) From: Biju Das To: Heikki Krogerus , Sergei Shtylyov Cc: Biju Das , Greg Kroah-Hartman , Yoshihiro Shimoda , Rob Herring , linux-usb@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Biju Das , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 3/5] usb: typec: hd3ss3220: Use OF graph API to get the connector fwnode Date: Tue, 11 Aug 2020 09:02:25 +0100 Message-Id: <20200811080227.3170-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200811080227.3170-1-biju.das.jz@bp.renesas.com> References: <20200811080227.3170-1-biju.das.jz@bp.renesas.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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 Reviewed-by: Lad Prabhakar Reviewed-by: Heikki Krogerus --- v1->v2: Fixed the commit message (https://patchwork.kernel.org/patch/11700777/) Ref:https://patchwork.kernel.org/patch/11669423/ --- drivers/usb/typec/hd3ss3220.c | 18 ++++++++++++++---- 1 file 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;