From patchwork Tue Feb 21 10:59:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 9584239 X-Patchwork-Delegate: geert@linux-m68k.org 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 67295600CA for ; Tue, 21 Feb 2017 11:01:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D5E1262F2 for ; Tue, 21 Feb 2017 11:01:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3140326E4F; Tue, 21 Feb 2017 11:01:58 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI 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 A737B288B4 for ; Tue, 21 Feb 2017 11:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751873AbdBULB5 (ORCPT ); Tue, 21 Feb 2017 06:01:57 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:18666 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751287AbdBULBx (ORCPT ); Tue, 21 Feb 2017 06:01:53 -0500 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie4.idc.renesas.com with ESMTP; 21 Feb 2017 20:01:50 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 1EE0E70E76; Tue, 21 Feb 2017 20:01:50 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 0508818070; Tue, 21 Feb 2017 20:01:49 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id F02501806F; Tue, 21 Feb 2017 20:01:49 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id WAD32526; Tue, 21 Feb 2017 20:01:49 +0900 X-IronPort-AV: E=Sophos;i="5.35,189,1483974000"; d="scan'208";a="235289873" Received: from mail-sg2apc01lp0247.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.247]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 21 Feb 2017 20:01:48 +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=hD6ftYX+0Vi3l++vFqDdfS+0Wbf4LHITG6YBGHYobRo=; b=pluxFE2+HDW7SBnQAa5B29GANmyUMHXay0j/KbddViNwbxjRxD1xRiTjvkbDeJT+8+81aeswZf4CnYTYZ7MM918ey6OJ0REmxGxE6pkRVOTuWP0qSAaIQ8EJuPYYMYFnFB0fubvtTHHsA/SE/uQnE9sRb8Abj2zLsUfME2nhfn0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; Received: from localhost.localdomain (211.11.155.144) by HK2PR06MB0548.apcprd06.prod.outlook.com (10.161.183.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Tue, 21 Feb 2017 11:01:46 +0000 From: Yoshihiro Shimoda To: , , , CC: , , , Yoshihiro Shimoda Subject: [PATCH v2 1/2] usb: of: add functions to bind a companion controller Date: Tue, 21 Feb 2017 19:59:47 +0900 Message-ID: <1487674788-12599-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1487674788-12599-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1487674788-12599-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OSXPR01CA0024.jpnprd01.prod.outlook.com (10.167.143.179) To HK2PR06MB0548.apcprd06.prod.outlook.com (10.161.183.153) X-MS-Office365-Filtering-Correlation-Id: 458c6b52-0e79-4089-f098-08d45a49075e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:HK2PR06MB0548; X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB0548; 3:wj2DL9AyNBU7h47vf9M9VHDJ4In2dHJXti7vfZObrWenrHfZ2zYq8el3V7tycTQ1Ov1GaVhMES4iocaVZMGFeubw5jRmQ/aSyyQ7U3JlysAqRHQxPQi756LMcq/pOc8W1TukGrU43NRvRGruizHurEmkdCKMTNZ+LOcn+dZsEITJCEuptb+II+TDAcDJfOjY8kO5k6fgvluJh5BERZMhKa5T0mMBoc7tPD43IQmPJt8OyZbfwystaG7oYWBYTIh6m8SDnngPgkRnw5Y0LwzYNhQFbiuERIO1KVnDt+dhUIA=; 25:WO2uCp3cr+uDvBYc4EpjCGP5j32FwjYIyzWQnTkB56a998SRXKCLrDnAAXam/GbydxxfpHMXdMlCoQOsx7akcuidk40GC6kvjbRKuB6rIGhVDvOOQ7Jp8B2NKKNWAsgBfgLuE4DOSTsTbRKI/cB8yODvIzCsQelfNxE0WkOTZ5dSHu92YH0Q95qP+GzooAXKZfGeDNXKLua2+kJx6VSsitYqap6HzNi8NV+gehkK/GlJPxM8p8MvEz4PgGqq4hCSLKOt+ytGPu3AzIIWm3ZtdCaKeB6q3XQII5LZ2dHUtp3R0aG4iEbGo8QHGDCgzesw4OjyupFOu8faXtnP7By0Ryznhl8/z3E4EusihY3D3mVYiT6p+XYEWN8TuK/BEGncpm+faszWx+pMkNiyscpwllTIYTeS7DuXPmt4NAWVTYL9QllnV0teqnWjUzIAO4RVFj01uHKPJUNOtuneHAqiig== X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB0548; 31:b4qWkJuBL9i+S6NVlN8EJp2wqAjv1DKdoPZ6syIgfLpbD6Ms50dpkvyNor5YNydqW7NETIZ8wfgIWx4b8HHQLCt/WUnfPG/gA+QwO0oFURICihoIyTBeuYuZngJCpeoJZdqiTcYT2fDrCKRsa3NyeZnQhRvQkDDjbxTOt+Aceu30WjIwEli6zdiI+oAc19rUkpGILZ0jrdip2LAhi5TOEBpCZeW5BjPqyfL64Fwc2H5SGYMeZ/G+HwgLslKBBd+G; 20:8v5wgBwpJyrTvsUapCNrzCMMwbXO2xrulXm916N47H4O+s/bTnioqDiVG4M0EZTdTTiwkf2XY0CsstZ+mB1mLgTnwF/V5uSQUHKXbjKp9mk1NOzpknjy+cmqbo9t8gmYYBJ54qGhENRFZ0yVDGLloVFRj8QQMKA10zlKeGt0IRHDz8OOnJK+McQjhbHY+1/ob5NOuGSNo2f0wSrNzppXd/7RTSkGWvx5jZSbkwMaIDaQ3XyhO6fLz+vNM0+fDwLRZA4a/uH4crBWB0mLQ3rzYCDiz3blJqAv7aWX5LeCHGPMPmXu8TOTJBNRKZxl1OuTuPbQv3zXb/qmCIFkazqNysq9CEawrRRnZlo/Rkw0krmIvF2UFLgzg89o0Uwa4T72nvuwdn1qa5QeEXq7aX5TLBpfGNbVyn52QO/2ySTeC58eoWjo7l5LS4gTM6YigRUL7WsYCYQyGpPO3K+OhK8j53h71nwVsT+JT1iaV0BYtOWzuvM3B1jRCoyOcz5kg9yq X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123558025)(20161123562025)(20161123555025)(20161123560025)(6072148); SRVR:HK2PR06MB0548; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB0548; X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB0548; 4:SkBkHsa3QN4dExZXrXCChWkac2jXQsyohZ42Y73ggSDEaiFAKyI+0zKsWQuoqDsKL677Pi+7p8t/JulBIngOHrhD6n4WRoduOxr06Hcgg+nnNRHiGnRh70i8XRUWSynyqQC/Wt6WAo9mIov2dDirB3BXHFw80dJWbWJQTlphvmz/+aCBiQgsuLvcEnFkMh5YYg5DqWSSkP4OtN5EFcqYVEkJ3Ha27rddfth+qqxbEARi5S0YttZFnrijQievhHOfNy/FWqQN1sG6ofPVASGgM2jy6/GJ5emcm3rpBL/HJZA8tNgX7f9IkG2f6jKqOtIyjoigD6yolKdHyd5EYzFMaM1BATfqhUR5e5LAPc3nOKZmSWZ2lFhWMy5Ckkj0TvhRW1tPCyS1VYrW7wd391/XKLnU52WF6h8vtK9PVhrrObcHX4RhQZ76CjShuRQP8Nc6WoNTIn5D3iYC2JLaI9fqXvENdDMBIo7kLRk/S7ojFTizVuvqjj+cGnv5klQXQ3MwR3DESbJ1IenebQJWD52YodWiytSHJUpcOczSbbJx8ChjyleyxsPzxkZwJtzXEU7zj9Gfwi35vwytPTuUSobkBgc0E2vlYVA9o/750joYBoxKvc0LWAyOHY0xwZ+QX6MX X-Forefront-PRVS: 0225B0D5BC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(39410400002)(39850400002)(39840400002)(39450400003)(39860400002)(199003)(189002)(2171002)(68736007)(101416001)(66066001)(47776003)(36756003)(53936002)(50986999)(76176999)(48376002)(33646002)(50466002)(105586002)(106356001)(42186005)(305945005)(78352004)(7736002)(5003940100001)(50226002)(6116002)(25786008)(3846002)(54906002)(6512007)(2906002)(4326007)(2950100002)(42882006)(5660300001)(6506006)(81166006)(6486002)(81156014)(8676002)(107886003)(38730400002)(92566002)(97736004)(189998001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB0548; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:0; MX:0; LANG:en; Received-SPF: None (protection.outlook.com: localhost.localdomain does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB0548; 23:835iWhz3jChlHhK+5F9AZILwnE2uq9ncoZYYk8JEu?= =?us-ascii?Q?/f5nJlcOYR/NIdA1hnBgx7TTajiI7jEwq/Qn2yHkgrnAou+f7+XSaH0wVXot?= =?us-ascii?Q?ffhTlRZnAHaDOtGkkJfwCaYukP6AK6Wnag+eMiuDPjCB04wNgyy3NuqKyofx?= =?us-ascii?Q?Pp2qM1iAWjr70YmedbANO7nKjKqh11s2aQ2Jh+e9y1VJ1Eln8shPwkyCNV4B?= =?us-ascii?Q?I/t93ROyWoHbXTCpM7zDd9UaamiCuryH5i4PQ0jBkMKxcuhi79JNp0zMv/mm?= =?us-ascii?Q?63c5dIL8GpjFgZUEefzdLZxQS4ZC9HCOMw1pqinfrGI+KZX/Cn7y7NzbTUgo?= =?us-ascii?Q?JJhR0z3umZK/PdigzsLt3zwDjlT0/BX6uOKxVp1WlXsEeSYTt2wPRbYk4MCx?= =?us-ascii?Q?gmP8kKkdDzMq4wutlA+IYpyJHEWYXPMAr137ntN4QeHFTndpJ5iZPMkK9DZF?= =?us-ascii?Q?PWwP4ODkfYtWbg63korMk57KItXs8/3SmUdJaLMJK4UHuolgYmhJAYukPzqx?= =?us-ascii?Q?u7Gq4HgQNSEqlCevswdJ7xnWNvxnvSqZ/X35gwR4b4CFOBH0d4U7lhWfjPkD?= =?us-ascii?Q?oxsH4pt3Y4TR/KyaHq1BcE2jjySWfBdiFWNlRpO0JPt0NBU4fxn0Rxzyltxo?= =?us-ascii?Q?G+jWc7wlEhJ+PN8eneKYe3VAijw5RAqA2cavQ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8MMdU0+SL5AB0cgHxYKiAYaJRDriFSSzpLOL57hpwLAXbGju0cci0MVezMu1b83rEGkq8/ckb8NxR2UIU9BMLvc3pd+P1VYxXUCQt73huF3jaGfEpuxLoTjk=; 5:cO0NI+Z+1Pn34I8qXh8dWba19hOJVYgn6P+5HKg8MH2k5ngm0GbHf2kjL2bEuGEe/l0MxClo4bLKix5xRhMW99Jz7GkUkosPaGbSVsobWB5AXGym0AgSWsH74eR07Aj8Nv2mMbfbBsINFl0/tb2nGhLjhn3gD7hUaj7A4SctS5w=; 24:3Yyn2Fq2zxnPDC86znxfrK97dOC6ah9uHclZAejzw1SSs0XPU267HqJKnw5SDhxOGpbTjclwa8kRDDmcAQOctVCKxtdTg45a1Qk+0dck6ss= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB0548; 7:eK1WLsFaorRPCGygV2lsF1Ri1YX1LxjxJo3tpbN1AvLNfDK7S/Cqg7dEekAAavQQJ9zBPDq748uPVtYJrCUDhyu4Wsm2Sog1oyhtRdY+YJpnAnQUAH0bfzB+xEZRvhb4/SNIuWYOoEdLVz1+7m0iCBeZxa1cFrqJ1HFxy3n14rRMUcOSOJbiYfkK0Q5CvjzBCKQKCYRyh93RVwXWC1Yr/Dr+ajkqW7QMrHq+GciJXVCwNb8TmS9/NV5QB4Lq93dh5J68tV9bqfqT1140422phtmBhmqXxbq8XdesmpIhKrUCTNcYztIe8g+DwKyNZzXYGV2XTuHZ1UCkbJLfQtoeAQ==; 20:itmIfpSkcaN4FG3gmGg9RXVZSa4FpgxLZFsN6g0Q1cBZzmwqkDIIEIp6rmbsY+4VYKiwPlh19M6jnSM9KiKm+WH1TdVeGoJdQtcLhroSVvLg2cj6Sll8LeCYdpjYBHhmMFsgr6fjqRTpx/sHD2h8x+T6q1kcUAVhuX4R9hiDa/Y= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2017 11:01:46.1513 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB0548 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP EHCI controllers will have a companion controller. However, on platform bus, there was difficult to bind them in previous code. So, this patch adds helper functions to bind them using a "companion" property. Signed-off-by: Yoshihiro Shimoda Acked-by: Rob Herring Acked-by: Peter Chen --- Documentation/devicetree/bindings/usb/generic.txt | 1 + drivers/usb/core/of.c | 23 +++++++++++++++++++++++ include/linux/usb/of.h | 5 +++++ 3 files changed, 29 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt index bfadeb1..0a74ab8 100644 --- a/Documentation/devicetree/bindings/usb/generic.txt +++ b/Documentation/devicetree/bindings/usb/generic.txt @@ -22,6 +22,7 @@ Optional properties: property is used if any real OTG features(HNP/SRP/ADP) is enabled, if ADP is required, otg-rev should be 0x0200 or above. + - companion: phandle of a companion - hnp-disable: tells OTG controllers we want to disable OTG HNP, normally HNP is the basic function of real OTG except you want it to be a srp-capable only B device. diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c index 3de4f88..d787f19 100644 --- a/drivers/usb/core/of.c +++ b/drivers/usb/core/of.c @@ -18,6 +18,7 @@ */ #include +#include #include /** @@ -46,3 +47,25 @@ struct device_node *usb_of_get_child_node(struct device_node *parent, } EXPORT_SYMBOL_GPL(usb_of_get_child_node); +/** + * usb_of_get_companion_dev - Find the companion device + * @dev: the device pointer to find a companion + * + * Find the companion device from platform bus. + * + * Return: On success, a pointer to the companion device, %NULL on failure. + */ +struct device *usb_of_get_companion_dev(struct device *dev) +{ + struct device_node *node; + struct platform_device *pdev = NULL; + + node = of_parse_phandle(dev->of_node, "companion", 0); + if (node) + pdev = of_find_device_by_node(node); + + of_node_put(node); + + return pdev ? &pdev->dev : NULL; +} +EXPORT_SYMBOL_GPL(usb_of_get_companion_dev); diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index 5ff9032..4031f47 100644 --- a/include/linux/usb/of.h +++ b/include/linux/usb/of.h @@ -18,6 +18,7 @@ int of_usb_update_otg_caps(struct device_node *np, struct usb_otg_caps *otg_caps); struct device_node *usb_of_get_child_node(struct device_node *parent, int portnum); +struct device *usb_of_get_companion_dev(struct device *dev); #else static inline enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0) @@ -38,6 +39,10 @@ static inline int of_usb_update_otg_caps(struct device_node *np, { return NULL; } +static inline struct device *usb_of_get_companion_dev(struct device *dev) +{ + return NULL; +} #endif #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT)