From patchwork Fri Dec 18 09:33:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 7881581 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 577CEBEEE5 for ; Fri, 18 Dec 2015 09:40:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 722E6204B0 for ; Fri, 18 Dec 2015 09:40:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8ACE5204A2 for ; Fri, 18 Dec 2015 09:40:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a9rVE-0003JV-Jz; Fri, 18 Dec 2015 09:39:08 +0000 Received: from mail-bl2on0140.outbound.protection.outlook.com ([65.55.169.140] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a9rUx-00038s-1N for linux-arm-kernel@lists.infradead.org; Fri, 18 Dec 2015 09:38:52 +0000 Received: from BN3PR0301CA0075.namprd03.prod.outlook.com (10.160.152.171) by CY1PR0301MB1993.namprd03.prod.outlook.com (10.164.2.11) with Microsoft SMTP Server (TLS) id 15.1.361.13; Fri, 18 Dec 2015 09:38:28 +0000 Received: from BL2FFO11FD017.protection.gbl (2a01:111:f400:7c09::192) by BN3PR0301CA0075.outlook.office365.com (2a01:111:e400:401e::43) with Microsoft SMTP Server (TLS) id 15.1.361.13 via Frontend Transport; Fri, 18 Dec 2015 09:38:28 +0000 Authentication-Results: spf=permerror (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; Received-SPF: PermError (protection.outlook.com: domain of freescale.com used an invalid SPF mechanism) Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD017.mail.protection.outlook.com (10.173.161.35) with Microsoft SMTP Server (TLS) id 15.1.355.15 via Frontend Transport; Fri, 18 Dec 2015 09:38:27 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id tBI9cGKl020738; Fri, 18 Dec 2015 02:38:22 -0700 From: Peter Chen To: , , Subject: [RFC PATCH 1/5] usb: hub: add device tree support for populating onboard usb device Date: Fri, 18 Dec 2015 17:33:55 +0800 Message-ID: <1450431239-16439-2-git-send-email-peter.chen@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450431239-16439-1-git-send-email-peter.chen@freescale.com> References: <1450431239-16439-1-git-send-email-peter.chen@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD017; 1:HP0Af5b4Q1cv244nIcx7M4eOXH9vPHk4qlhoJivVj7tmz2F3UTTlEqAYz/xWXyzUsASfoY1Vv3wLd/BDpDoTU0D8keaQdJRRv4FlgQjxyy9WIEN5XLJ2ZrNFC91+xKC1p6FUutpZldEgE2NJdV0no2lKur+3C/URqw9HhZ/lwQcFbMGoqMbvXiDgD2oQYZFG/5R5K4lne05eD4h6S6dKA31kxzZi0qH9gFZrgQSLrksra/SyGd3UZeh9coF4Xr/4KmzZ8LvSfpOOBhxmQ8iI/B/Wiinl7fjCGjCIr6tmaGjhFC4Fjx/LZS8Tvkx+3nJoBNjeWgCxxOgWPw74jUt/EQEdmKyBSnBNCUGtMv7w6Hd+PWz+jylM9Zshq2+6LowH+uSJDkjAXMcUm1tF8iw7BGPFo2J0Cz5hBOlFbOxq9FRZWRBGU/6ltiDzRfjKcv0+ X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(448002)(3190300001)(199003)(189002)(36756003)(97736004)(107886002)(4001430100002)(69596002)(1096002)(50226001)(5008740100001)(586003)(86362001)(19580405001)(11100500001)(19580395003)(5003940100001)(50466002)(1220700001)(85326001)(47776003)(81156007)(48376002)(2171001)(104016004)(87936001)(106466001)(77096005)(5001960100002)(33646002)(229853001)(2201001)(92566002)(5001770100001)(2950100001)(6806005)(76176999)(50986999)(189998001)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB1993; H:az84smr01.freescale.net; FPR:; SPF:PermError; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1993; 2:S7msfK+Px9hRKl1/pRZ2JTkJ6actjtQkB4sVsGvv+bOjvNlzEAxDpwRlt0G5QD8cMQb1NVOS0tLT19eHoqJSnEgZVLEsRK/FBTXK98uggwIiAhCvB3xPGjiy47qVbgkRCbLoRRgPzBQFCCHOzDybAg==; 3:6Gf2c7AI8vosoXyekgVJ4ZNrTNxq/vNqQ3xUxmj8PMk3Vck96EfDAQ4dXFwpymMvJY3kSq9CsFrb/2g8ZX8iBBKUN8HqI6UDA9RZ5ojPA6tYmCoyaeJhjn7EFlnbazaw/yiPm//4yOEzZz8jc8s3Jh5QIG7MHCqdxVcNCKowmdEq0Au154ixJK5OUUPn7P0x8qFb8ZUjE5ecUKIlarK/eGDp47W3/EfZKzsIsHAXOu4=; 25:OnNpU3kMYaYmB4yw0XQPIOV8/KUvv3NwyrfREPRuYNPhPmrfJ+djGX6cH51+A6Na0Fmykj4zbThRuanI8FO3Fm97N8LfV+768OSNKF0FCfbCHCqfXai4J6xFhINL8OeFccjHVG9G5/DT3DjSqtyChxERfjlqn/V4JDVzUpnkv8LgJXMdmw1Ngs8tCHUdvgZyc+QKnmrD7PyKcdbXvrso9TB9Zkh2YhSt792s1WUQC5CuSEw00Z0WBIibrlCriO44ZXU85bCWc6g48JguaObMkg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1993; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1993; 20:k20IVDn6DIzyi2PzRd9ZbiEzY8hKDEjJdRLkVORTP1i3WUea62r3l8umh5HVA3KFugFqzwUbEqq3mfyT6KlSr3a8uPmVAI5wTl9gVI4BG6Px5B4ilYC/SqzklqTz9au7CSuvHCyt3WxjpnOfpjqkjITU3SftLx0besqLi/+D/R6sDzN+u2n+DdMqqDVSc5hlaY01x3ZrFVzsKiMlsPtZWBz/fykgWSl74+YrK7KlqkYRwrVax4O8fnKkYLUF1vICgapyB0qTkZZyyJEJu1EYf1RPUnkPkNOLDr3zy3OMyu84zo5xx0ydeNbhL06e1Ygny+lGkqGMMNA3YNph3vdcgnmhzHKrbaTkLHsvxxsGuyg=; 4:OLsC0MUc/Xei+JxBrE6unsloLwB7uu0QyPLmjOryKz5vRfl0J4lKlYto+pI+7+l/3UZpP9qr2ndJ5f9wOD8YQAOyXlcYh2mDGaotoNdViLF+Tv8hVb+vJwhHCrSRoOyKeIa1PrpZM5toRYOScPr19H6fgXgyEoqASLikEQ75dxg9z9bq3sS/GxI9uzRvEkWR9f3iWwSiNlO0XOe28BDvVBkoIpf5rp09+6EliUvMjrNSig9IgUQTmG8WsHidcdJI+KuF9ZWrjwK+HDBE9vvTDSrAKYF12e0A7gafrk/316EhD4Ij6QTeTE0tke86TRUGjcP2GBtmnG5SLB94JRfITNZIc21jmH840x/VoODn5i5SsHj3Wepk6rjkiGsFyyqES3U7L1DhhNBJStxAWQamCjWi83LMpGdVZDlbosYDtc/FkMeTMDTtsFZ99+PsexhO X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001); SRVR:CY1PR0301MB1993; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1993; X-Forefront-PRVS: 07943272E1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1993; 23:Iujv97lX3yONbjWHsRrKRY+in0ki6G9Sqn1XN8U?= =?us-ascii?Q?fn0cEZ8loFGSxOF/uozDIquizkFAR2o/RJ+zpvYleoIRNKl0ka0R6+nzPWN5?= =?us-ascii?Q?fDtpfuAeGzIvgyy9r8Jol5Bhu5O4BxF/u70thA7Q7p73atnXg0RA2aaeU2qm?= =?us-ascii?Q?MbVuR3rbw5uXDmBfRJqnUZbTuVCXlq5EzcfMxemG9OD+dXMD53LJGPa7I4jD?= =?us-ascii?Q?uRzMgNXTUU32LMZykg8nm67sMSViP0Dsbiz6Ncx5RCrGlan3PI9KKRpeJz+Z?= =?us-ascii?Q?fija247Hwsfxki+LqQQOil5Jf3F/WYs80jHiFM9oCTlPuq8HcCevVR/F7jRI?= =?us-ascii?Q?NiLAV4DaCl0NkENfymBGmx8a2kEXM1C2UotDYT6VKbZ/rJur26wL2w7Y3uQd?= =?us-ascii?Q?g+XGmb5ORh3wNyOcxr7v+wPxaDa8BDlk1Krqi61oyN+ujVdrx99kvD0H2+op?= =?us-ascii?Q?hyJC08NiJqTxdSy3X5TqNuYaR3cX2JQCTtc537lCTkZP/qGYeHuA8CjINKQ8?= =?us-ascii?Q?bmHvgqd7q+fhjWbG+hJcQxxMXfK/40MuZA5XTo+nJuZOdo6qL+lJ28f1yw88?= =?us-ascii?Q?8+0aSS4ZAGvfP0ZD0zXhBAn17oYcrS0AUVMOD6cM3yuxEe7FAIAS8YoiiMCX?= =?us-ascii?Q?O0gyqgr1NtFNK93HorW+RdQq19UwKZR0EVS1OD/auKl//B6nVRD+b5MqjkdV?= =?us-ascii?Q?+8kukKWjW2l4+mCVot+2e2k0t/sby/+LqCcpu46hD8fjPmHO8RJmTHcw+mml?= =?us-ascii?Q?G5PbfZvKWs/MXtD+e+tPxWaigTjluIWdXgWFbLkpBSfOa7fXjq15OO7H+xMP?= =?us-ascii?Q?VgXC7O+3ldGNadEwlpMlC2wztxNa/a8cEEK7ODwAu1+lSITTSvqge3Fmys1Y?= =?us-ascii?Q?zk+PherJwQAUa/ggFasH8wQiAxse+R+HluR80LjZrrjBUJgdT3C9DaIPNtzs?= =?us-ascii?Q?eXpMQgBr0WP6Lvg6XRo+oUsdwXU/dP2EidusfDjifWf/Cs/3wdNWUYlw4RLt?= =?us-ascii?Q?m222S6TdyO0A+7Vou3rXlqHQQA5AZUbiG3J+wivvxaU1g+QsKNaMX3n9lLJj?= =?us-ascii?Q?6GJXPn2tAl2mbTXo9S0ees+ppaCGDEaWnevlwnt1eqrM1P0q4RsDbX3s9ma0?= =?us-ascii?Q?NB/HJaFCuZK8i5e95BNUbig9MeJ0kAifE?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1993; 5:RTphj55onP0hTBh2gnNEEDY0C38fvmZAQ4AUR4R1Wpb3CCHBDRRpy6DXVJzsVvvVLhC0aYXZq5tZxdVj5dzwl77ZyrPyyvxBzOBtqmjD8s3Bzmd3uTaataGc+DbNfada8v3ysW3hvlGfLAOhEq3tjQ==; 24:Q6sYben5JttdHsGzBTagcr8sXFztnZ7XNaa9sjcmXkdyrsQj8eEueK5PYq+xIvy/1e8Wkd7DNPV6LRHGYHR/lzZtEcvSlmzEND9qdwo+ZV0= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2015 09:38:27.6321 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1993 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151218_013851_591727_A8C17A4D X-CRM114-Status: GOOD ( 15.72 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, p.zabel@pengutronix.de, pawel.moll@arm.com, mathieu.poirier@linaro.org, linux-usb@vger.kernel.org, patryk@kowalczyk.ws, balbi@ti.com, robh+dt@kernel.org, arnd@arndb.de, Peter Chen , kernel@pengutronix.de, festevam@gmail.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Although most of USB device is hot-plug's, there are still some USB devices are soldered on the board, and these kinds of devices maybe the upstream device at 1st or 2nd level hub's, so in order to detect all onboard devices, we put the detect device node code at hub's driver, and it will populate platform device under this HUB. Signed-off-by: Peter Chen --- drivers/usb/core/hub.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 5e32ce7..889f188 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -1334,6 +1335,34 @@ static int hub_post_reset(struct usb_interface *intf) return 0; } +static int hub_of_children_register(struct usb_device *hdev) +{ + struct device *dev; + + if (hdev->parent) + dev = &hdev->dev; + else + dev = bus_to_hcd(hdev->bus)->self.controller; + + if (!dev->of_node) + return 0; + + return of_platform_populate(dev->of_node, NULL, NULL, dev); +} + +static void hub_of_children_unregister(struct usb_device *hdev) +{ + struct device *dev; + + if (hdev->parent) + dev = &hdev->dev; + else + dev = bus_to_hcd(hdev->bus)->self.controller; + + if (dev->of_node) + of_platform_depopulate(dev); +} + static int hub_configure(struct usb_hub *hub, struct usb_endpoint_descriptor *endpoint) { @@ -1677,6 +1706,7 @@ static void hub_disconnect(struct usb_interface *intf) usb_set_intfdata(intf, NULL); spin_unlock_irq(&device_state_lock); + hub_of_children_unregister(hdev); for (; port1 > 0; --port1) usb_hub_remove_port_device(hub, port1); @@ -1701,6 +1731,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) struct usb_endpoint_descriptor *endpoint; struct usb_device *hdev; struct usb_hub *hub; + int ret; desc = intf->cur_altsetting; hdev = interface_to_usbdev(intf); @@ -1820,6 +1851,12 @@ descriptor_error: if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND) hub->quirk_check_port_auto_suspend = 1; + ret = hub_of_children_register(hdev); + if (ret) { + dev_err(&hdev->dev, "Failed to register child device\n"); + return ret; + } + if (hub_configure(hub, endpoint) >= 0) return 0;