From patchwork Wed Apr 18 08:09:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 10347541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AE82C60365 for ; Wed, 18 Apr 2018 08:11:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4ABB284CE for ; Wed, 18 Apr 2018 08:11:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 994172859A; Wed, 18 Apr 2018 08:11:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08E23284CE for ; Wed, 18 Apr 2018 08:11:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753446AbeDRILp (ORCPT ); Wed, 18 Apr 2018 04:11:45 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:10668 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753421AbeDRIKo (ORCPT ); Wed, 18 Apr 2018 04:10:44 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 18 Apr 2018 17:10:43 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 63AA38A1C6; Wed, 18 Apr 2018 17:10:43 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.48,464,1517842800"; d="scan'208";a="278555604" Received: from mail-pu1apc01lp0019.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.19]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-GCM-SHA384; 18 Apr 2018 17:10:41 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=yDZAdcDPxaBLAQxrFpC+xsWPpRFN09O79UNmyHcJReg=; b=gRoKtMF+aVs4Ck63SUi3zt/Kuy2O/ku6m52tmCI9NsYLoIiqvEM1leoS7XXs91HFH9pSL9jZTDTxibcnqWFXkx5bf/DTAcXEZaxxm9lTkyutL/nDKj6kShMpUKYiMn2JZTm9uk9nrjVvrQAOCUm3otkzv962qAIH7SMm9P/WYz4= Authentication-Results: linuxfoundation.org; dkim=none (message not signed) header.d=none; linuxfoundation.org; dmarc=none action=none header.from=renesas.com; Received: from localhost.localdomain (211.11.155.138) by SG2PR06MB0982.apcprd06.prod.outlook.com (2a01:111:e400:5213::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.14; Wed, 18 Apr 2018 08:10:35 +0000 From: Yoshihiro Shimoda To: gregkh@linuxfoundation.org, robh+dt@kernel.org, mark.rutland@arm.com, frowand.list@gmail.com Cc: heikki.krogerus@linux.intel.com, hdegoede@redhat.com, andy.shevchenko@gmail.com, p.zabel@pengutronix.de, linux-usb@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH/RFC 05/11] usb: common: roles: add fwnode graph parsing Date: Wed, 18 Apr 2018 17:09:59 +0900 Message-Id: <1524039005-30618-6-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524039005-30618-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1524039005-30618-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: OSAPR01CA0023.jpnprd01.prod.outlook.com (2603:1096:603:2a::35) To SG2PR06MB0982.apcprd06.prod.outlook.com (2a01:111:e400:5213::24) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(48565401081)(2017052603328)(7153060)(7193020); SRVR:SG2PR06MB0982; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0982; 3:VowPbQhZXjWb1cvFh509R71nFSekQbysEHXmnwbXOkt85H0nTuxtwLpuru7MfeQPtC3GKyFRg8E1mahwiEwJP1ONvzrWoobKEVRsf4p2+s2D7eAMp6iGqrf4WrsHRhNhPBDZtbcUj+TH9SpAJ9V098PoU3W31WGBeA9E5Vs75Hy2TaYPkC9iOTaHcIWJxguAtvPOSzyv1GaMjnrVT7sf9SDngoGTTEwOsMuja9CcRk4YGJTIdCll7AK3Qg+JY0Ku; 25:dCmkIIlzlOaFsqVPXrouMSjYJSYjxXgtptjSuT+139ND+0SOV9tmNDoBaJ+oi9/80u71pdgnUINehY+GTZSowWTp2ZRYtPvCuSQhjguVRemeGiA3u9HbhO2X44800sh70ZFR+wPO+stSHGdkpEAk/sAQUuLG6PJHAraIaCpPwqDD8/m/Qx2My5Jh/2HYu3hxUsxh+v8Ixs88eUxQNcbicN9YIToWswQJvDBY7RpEqoVi4J1BHWI6yN0YQjVX49oGn3NxZS4TBafIuTIIJOJgN/UGPQslWmfzb+QO+FSkHeZFRlJ9JBFYsrpCA2D+cEmrEnswj5LMWeQuvg2WZymBdA==; 31:VtM+tsxSb2rLj5liD4aC+82yGO8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antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231232)(944501327)(52105095)(93006095)(6055026)(6041310)(20161123562045)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061750153)(6072148)(201708071742011); SRVR:SG2PR06MB0982; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB0982; X-Forefront-PRVS: 06469BCC91 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(39860400002)(346002)(376002)(396003)(366004)(39380400002)(7416002)(956004)(2616005)(6116002)(446003)(3846002)(47776003)(8936002)(97736004)(66066001)(50466002)(4326008)(2906002)(76176011)(42882007)(53936002)(52116002)(6512007)(476003)(107886003)(386003)(11346002)(6506007)(51416003)(59450400001)(36756003)(25786009)(316002)(6666003)(305945005)(16586007)(5660300001)(7736002)(48376002)(78352004)(8676002)(6486002)(50226002)(16526019)(81166006)(39060400002)(498600001)(26005)(3720700003); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB0982; H:localhost.localdomain; FPR:; SPF:None; LANG:en; MLV:ovr; PTR:InfoNoRecords; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB0982; 23:/7h607MLWYfh4rQ5Vvvg2T8xa5o0htbaugrMurq1T?= =?us-ascii?Q?Mu5lAQOyCsh1q97arTvkc7V28N3d7HPKXQNYlaYtpDhY+J0ZrX1ts4nBMDQK?= =?us-ascii?Q?K8hOazTeogYzNHGbtb7g1an45vQkat+6Z3Sw0Ht39YGFjhLiEmyJWl/NCagE?= =?us-ascii?Q?bxxwWI+q9gH7ohHoa6ZGcVfapnyVR3SoEfuyoWZ8TNYXBZ260Ibdxc65aPRd?= =?us-ascii?Q?bjz0safk+4KCvrOiV2m1qXqH8M9uzIvLtNG+HsB8UGhWKgFHWr0nU46hbHhJ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/GLjjsJvUrFCDh9pFHdeCoRCMLgHskQZXHImQAqA=3D=3D?= X-Microsoft-Antispam-Message-Info: 8owuij7Yb/sVT/SgTCxJtdiEH606gWl5cRED4DEC7xweUgxymRHXrQbct0hNynP9jP50J5J1bY4kvYRCgCC6/c4JqWdqrP/PWTCrI9kMFDlzrxUjhThjUSH+R2WjchIMVLuLGtSwBohgSCQChiZ8CdqMiFKsDVQKFtJAvhpibi17kDEQoUMkBBE8IC83SdOq X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0982; 6:RnDlex4SnTxB9n4h4aZ+PFyj3vrd5fzfQped09KFOYfbMkn/OjYsDfvUsJg+V2qGVpO6e9DPWs8eXUraAwsgEPXCHC72pqwFT1Zx/P2guuN4kH62YIeybSM6S032mXJ57+XurTvLo6VCxSlSb6os42reao95c+88IsrPWVTBMXaLCpws+uZBO0tD5Fz0KOoEEKOd4fwbEsLg6E2vHBaW31gyCAZrHMAfllEmxRyUEkprp+w9Ke5uuq7CjfoFXaF//zqjPJzmPEchQTkefRvrlNr0flzOVa4YufuiFcUKusNpym2QC6e5ME8Gg9/LjxxTbeAJHOHNF3TvW97VWph5zjCGfa+pOtxD0kiKimJX6XTXg5Hm2+G91ierUhPZvgjxtYa2U/LjC01gR0sEHc65FzVS79syL4FqlvQiuiHC/RgJrRc/RZorveUjDDaP2igtCKmOUdmzce6mE2EJ/eGoVQ==; 5:MCi0EufX+SITKmiS0bp7tkUREmPEhlPYdPpiiBWZdBdBLgPxUCR2hiXU0ryBDk+8wMTB6PnAgsIsdAGeaqw66lTpmRwDhBWadWshelt1dbIriwSGXu1A84EE3IaixyVRrPNtVaUzqR6tQcRjeZwHWJl5fXX2Ru/ihF2kCrnI6TM=; 24:vF8LjDdfGZTJdvL/CHS0bAoc9fqtG+YRUC+xey5Sv/Z9FckuagB+ku55RbPduoqQg/PvrlOsqCw3U4VvhWFdLUgCO8/Xu8HYtW7PkzS0pRk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0982; 7:xbCrCQVr6ZQs5ZLTzGk4i09mpsEVbYWb+4O/6a0WOT+39xZxeb3a7Ht9LZhczZpQGX22bbz4Dpr1RJWf4GQ/2Lxp/9looYW1XmwrQ04yHGXjqfetXKv6HeFLlXcAmR+JdvCLLgjUEJHD3jIVvTLLIz6B9gbadQZUVvxZHt1Yd9zYj/umYy/J7WWwLQw4GGOYoMxVnoXkiDuvwqOtz0O8T+kjHvbtAAcZWta8qlHznYqWsOa4/NeDx0DeCi9n1Smq; 20:l2DzN0YFpaAE4utbnXPWTCtnIz4NvT4cqaXRuJnxdrI3fl1MVnCDB2kadmccFomKuwHEWal/nXidCiiLhZJNyKeNY8ienFMJosAZ3qAZhX/iH0lbnCZFETkdSYOQw+1/h+WjzMDU3NbhHHn6A/L6AVh1LQ9/d3Zry+bESbmX6ao= X-MS-Office365-Filtering-Correlation-Id: 0fe3b67d-021c-45b8-00bf-08d5a503ddca X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2018 08:10:35.4624 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0fe3b67d-021c-45b8-00bf-08d5a503ddca X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0982 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds fwnode graph parsing to set usb[23]_port and udc into the usb_role_switch structure by usb_role_switch_register(). Signed-off-by: Yoshihiro Shimoda --- drivers/usb/common/roles.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/usb/common/roles.c b/drivers/usb/common/roles.c index 15cc76e..cc1c55a 100644 --- a/drivers/usb/common/roles.c +++ b/drivers/usb/common/roles.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include static struct class *role_class; @@ -219,6 +221,42 @@ static void usb_role_switch_release(struct device *dev) .release = usb_role_switch_release, }; +static void usb_role_parse_fwnode_graph(struct usb_role_switch *sw) +{ + struct fwnode_handle *parent = sw->dev.parent->fwnode; + struct fwnode_handle *child_ep, *child_port; + struct fwnode_handle *remote; + /* This order comes from DT bindings */ + struct device **dev[] = { + &sw->usb2_port, + &sw->usb3_port, + &sw->udc, + }; + u32 port; + + fwnode_graph_for_each_endpoint(parent, child_ep) { + child_port = fwnode_get_parent(child_ep); + if (!child_port) + continue; + + if (fwnode_property_read_u32(child_port, "reg", &port) < 0) + continue; + + if (port >= ARRAY_SIZE(dev)) + break; + + remote = fwnode_graph_get_remote_port_parent(child_ep); + if (remote) { + struct device_node *remote_np = to_of_node(remote); + struct platform_device *pdev; + + pdev = of_find_device_by_node(remote_np); + if (pdev) + *dev[port] = &pdev->dev; + } + }; +} + /** * usb_role_switch_register - Register USB Role Switch * @parent: Parent device for the switch @@ -267,7 +305,7 @@ struct usb_role_switch * return ERR_PTR(ret); } - /* TODO: Symlinks for the host port and the device controller. */ + usb_role_parse_fwnode_graph(sw); return sw; }