From patchwork Thu Dec 17 02:31:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 7868431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 201369F32E for ; Thu, 17 Dec 2015 02:39:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 17FC7203EB for ; Thu, 17 Dec 2015 02:39:18 +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 27092203E3 for ; Thu, 17 Dec 2015 02:39:17 +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 1a9OQI-0005wb-2D; Thu, 17 Dec 2015 02:36:06 +0000 Received: from mail-by2on0104.outbound.protection.outlook.com ([207.46.100.104] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a9OQE-0005vQ-4u for linux-arm-kernel@lists.infradead.org; Thu, 17 Dec 2015 02:36:03 +0000 Received: from DM2PR03CA0043.namprd03.prod.outlook.com (10.141.96.42) by BY2PR03MB607.namprd03.prod.outlook.com (10.255.93.38) with Microsoft SMTP Server (TLS) id 15.1.337.19; Thu, 17 Dec 2015 02:35:39 +0000 Received: from BL2FFO11OLC008.protection.gbl (2a01:111:f400:7c09::160) by DM2PR03CA0043.outlook.office365.com (2a01:111:e400:2428::42) with Microsoft SMTP Server (TLS) id 15.1.355.16 via Frontend Transport; Thu, 17 Dec 2015 02:35:39 +0000 Authentication-Results: spf=permerror (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; linaro.org; dkim=none (message not signed) header.d=none; linaro.org; 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 BL2FFO11OLC008.mail.protection.outlook.com (10.173.160.143) with Microsoft SMTP Server (TLS) id 15.1.355.15 via Frontend Transport; Thu, 17 Dec 2015 02:35:38 +0000 Received: from shlinux2 (shlinux2.ap.freescale.net [10.192.224.44]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id tBH2ZWEg016114; Wed, 16 Dec 2015 19:35:33 -0700 Date: Thu, 17 Dec 2015 10:31:19 +0800 From: Peter Chen To: Arnd Bergmann Subject: Re: [PATCH v2 0/3] USB: add generic onboard USB HUB driver Message-ID: <20151217023118.GA3793@shlinux2> References: <1450077974-22762-1-git-send-email-peter.chen@freescale.com> <3023844.AYbAYqvHUZ@wuerfel> <1827708.e1pfN6rEID@wuerfel> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1827708.e1pfN6rEID@wuerfel> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC008; 1:FRfNgya9u/Du/3IqSJx9mNg+NIIVnBItHqvCQwLf75FOmsFxRdZNEcnex6z4FFGeXQ7a1N1CKrpdmgrKEbrga3nsTTgDHtY9jHcApAnl5w+eqlf2OIWS0JgFKnZxnweH5fZLcsSrPKHZsHKlHlr3EBvKkKxFYHlIdtBT+WO3fbhXEA1GLJkJnbIFXO5X0NOQBzAVr50RiH9eAIwESLdLr93ygTZliNm2H/pWvhIogbuFMcLHqvhui+n2fCzg5ZdRDPgfQj1QxkSG6xnUuZSsyZcUuvf1I5R2Qx+gTuRZxcIu4iK7DWWDhtmR2BLDRTWl37EX8q4hDmCG65nZuxb0tK+p9TiLUGcrk9pYTRuHHBDK84N8xdjxrHZW708frQPSkIOWby79tw5oHTv+MSxKhQ== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(448002)(377454003)(24454002)(199003)(189002)(104016004)(81156007)(1076002)(2950100001)(77096005)(86362001)(85326001)(46406003)(1096002)(50986999)(19580405001)(50466002)(586003)(33716001)(33656002)(1220700001)(76176999)(97756001)(19580395003)(23726003)(54356999)(92566002)(47776003)(5008740100001)(83506001)(11100500001)(106466001)(561944003)(110136002)(97736004)(87936001)(5001960100002)(189998001)(93886004)(69596002)(4001350100001)(6806005)(41533002)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR03MB607; H:az84smr01.freescale.net; FPR:; SPF:PermError; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB607; 2:pGKWOmmreetgUzmIusu/iwaC9xyZh4rQK9Mto9rzgxTljylo8LSpcZAZigSw0MfD9mNJe/Bd1MM7tFZ6t+qm+QPgi9VzWhtQ4OxaPAn8vIKCtFwVOg/EoejAfvLZPtMMvlofhoJdboKx1QsZarTBvQ==; 3:Tff16fJylFo9q4bVHk+3wB7YJfixhTO11G5L9MQBv1k/NMiIZflpzGDuYxnqoN/IX/udgQZz1PeTQOoYoLJSQGPqMHSBFK04sFl9CFu2jV4bViLTQAVSJqtCOyZeTcRyQrcDa/NT21Ic03CvYw8uvVZxYeXUaRXlHUzDObHDrHjatUPXaAfvVV79XnDsnaGAGrknLbLlj43isqg2wGyRze6uz9Xo5WP0kFHTOpXreNw=; 25:XA4qgREnDO5Om2wwcSYkWLzpcRj/E+X/Hn9vy+kuqkVIgboCsdH/vNxK827gpEIKc+0fscCWQ5oeEVz98OKPeSlOv7/5GzpSv5Uz1tucVmMRduhMk8JEqoZuJykeBqx2xKM41/mT3p6YVfpdMy5anrIOhXMFbjsC5PnzMCU/APMpxguSxAccBu+Xs3W3Aad92XSW6U0Zw1X+owhjZ86Je3y9BGdmzOjD18rcLyZLMXxXLk/GcykFxQxBLmub7OG6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB607; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB607; 20:GR2i9YME6FYV6qjeHboFobDFSzL6poESP/31ZPC3HAShXZRQr+s838v9NiXowazdyapWKtH7dd+eQBxDFWhSIaAb9lJKtuQwbyDJD/7tL0lCfxJ5NGGpKtIHT/hJ5hkAtOfpsxDgq0S65+zHvrymYKNsee/OQQjhHBq9ERyFHkwPs2/Rv5hV9kUzlr08VD1cRsaH+aU9AlEpANWLRPsGBuQfehVHul6RXj7y/IYzNdwEMSEK2Ag0+VN0TV/ZQzGffv/15EoSbtsnwbypWyxGjQtdaUd2EkmphlMajklE5lKXF634bOY9qaHlRpRASJNguUT8kgqBbIpkVQRzukrO7nVV+BL7FFW62aLl9KbtH0k=; 4:z8pD9w+6Qxa2L68GZZSx1I5mgcRQLZYkMP5nhKG1a/20Jg+jCTTk0AhMpfu0Z5plKfOApTx0X5ZFQTbNlf3gCVn5MklH2gU4wWov1Vg5MbRnqGsLx1TKiQyfeRV8un3mFrA4daynDzgrnQY0M9kH7AflSWQO1p6yxoH+BaHosriWmoJ/t4iSPRtcxR/CEUGyaQEMHCaPgj8GT7gZfqwu4Em4HO4FLjWSzVAM3Bx2vWXP5Qx4veII9Hh3VY7+vZOtbzBEvZLyT607/4O66K/db5ko7TsrPGnqAevekJZ30adgaiRiY9m2LNZOGnl/3c7yCWh9fFbqwyDYm9Lf5q/PXpxSNQI+5cezSF3q9Gdxkn6+ZKZOVAemsm0hdRzdd4Z4 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046); SRVR:BY2PR03MB607; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB607; X-Forefront-PRVS: 07935ACF08 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB607; 23:PHQknx2zf5+92Sq/Ga3v4GTzpE5FgtM866CD3KEX6b?= =?us-ascii?Q?cKIw2nh3nJNLZQYgM4qGYNkduxK9lOiwmHWerqJMuB1gubo2LHcENNlaaF1z?= =?us-ascii?Q?W66xi3rHBboUri6iZmJY7jksCfDdfl0pwxa9KT4dvrDjxbEJmEoDYQ/rJyOu?= =?us-ascii?Q?54V6Gm0eHhmQIYAQzytUCg/vK7W6gLRRyb32EF4tGwUIwRq2QlBygwfeMPpI?= =?us-ascii?Q?LR1TQjRlpAoAD9IYK43qx2iy+wWLNDQDnQAWT7GoL1PjY5i4UylbETfhXdMj?= =?us-ascii?Q?bbSc4e2xKc9kerO3ZZ61kdQNuDOnO6k2u+hVjzAhzp//IEpXAJFEGV8eIjnD?= =?us-ascii?Q?GW9irLGzXeflRwLWnkQv4d7jCgW4hmuJHgV9RNqBSJDHLoF5KEXzSirm3JBq?= =?us-ascii?Q?Dk3Id6MpTEDLq+7Y6ZkNgKNYAi0TdwAnI95CU8ATPFzUkSJixn/a3e860W9h?= =?us-ascii?Q?9rdj6NDLLvkR+xu/DIELoCHe/2gl3UNGUI40NSes5/JsqM0bRO7A+NMecWbg?= =?us-ascii?Q?PBzHmI+97uF8d7B+zfntfnJLpg3gzSFisAwm4PlvBCGQAREIN0bx2U69HMGa?= =?us-ascii?Q?dkyYZPnrrWnkoTTjj1XXtkP7fBVJAA45azukdJRjv/Ahr/p356AQp9WPBxxS?= =?us-ascii?Q?4FNbvZTWZi/m8h9BmWRMZBhlu282P4g6LqcnLOaRgmqMxRQt37GsIPah9CC1?= =?us-ascii?Q?xBIByKIuJHQeZVE1x34W6uadr6Taz9gxB8YRQP5Txc2CBlI/M9/fn8yuFrae?= =?us-ascii?Q?qO7ECXzKRiNcDc5GZGTgJ3U+JDjaCLgDhGT6TWfg7J25x2gbbFwEKB6/zpae?= =?us-ascii?Q?07EjhE7Lqz7J/fp/TzubriGGs+paoDR8oc3VZwWw8OREEAo+BmbHpxaIAr8N?= =?us-ascii?Q?Rh7k+sic8+0PoNK+3B52l1J53hvNgM6Fg8XAkhRpC1YQieo1cfIOh3zoe3V6?= =?us-ascii?Q?mA/KnblENAo9D13SPE/m15SFdCkqAS+GjD/i3Knx6yCmgxwSu/tcByvjGTFw?= =?us-ascii?Q?szGq4/idAm3NfLI8i94Lpm/70L2V6VaPb5znx3mns4I3CU5xGtytQd4QWBZp?= =?us-ascii?Q?e1Gfqzoqs+F4bdbk+qOf9uPT+uEe9Jvtrfb5dcYzWoQrpGtpk9Iat6CezpkU?= =?us-ascii?Q?TDSl1qKxSwtGfke8Obnr3w62OHseqFoxBoYhho1fUFtoWJ8WDHm7JiEtBeEP?= =?us-ascii?Q?NcPwznv6NPXQs=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB607; 5:/J9L0H+/WBgzLZYOMUFRy2LaWMV/7G1y1yXb9DlXRvykPkfEtZyEaVufPiT85lrxJkp1JurA5VpXYLXU5oBsDf/Vx4ynjZcwPdiaoOXH5yaqMUzxKw4la4lpjj+hTu5WgceYUBt8EnzYyPniWZ5grA==; 24:symlRVh5QWamQAG1T/PzZZw+M4hlX8bbBbIf+Nf6vELJKneYW+E0hcJ3V+nxGe6EG0UtUN42b3GvP9H6DQ6AxQb9k6s9xPpKYk0Mo47ddfw= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2015 02:35:38.4482 (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: BY2PR03MB607 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151216_183602_431903_A14C3755 X-CRM114-Status: GOOD ( 27.38 ) 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 , "devicetree@vger.kernel.org" , Fabio Estevam , Philipp Zabel , Pawel Moll , Greg Kroah-Hartman , Mathieu Poirier , Linux USB List , patryk@kowalczyk.ws, Felipe Balbi , Rob Herring , Alan Stern , "kernel@pengutronix.de" , Shawn Guo , "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 On Thu, Dec 17, 2015 at 12:13:07AM +0100, Arnd Bergmann wrote: > On Wednesday 16 December 2015 16:59:39 Rob Herring wrote: > > On Mon, Dec 14, 2015 at 3:35 AM, Arnd Bergmann wrote: > > > On Monday 14 December 2015 15:26:11 Peter Chen wrote: > > > > I agree on doing it properly, but am not sure that pwrseq binding for > > MMC is proper. The pwrseq binding is fairly limited and working around > > the driver model IMO. Hubs may also need I2C setup which I don't think > > could be done generically other than some defined sequence of i2c > > transactions. The current project I'm working on needs to use I2C to > > configure the hub to use HSIC mode for example. I really think we need > > a pre-probe driver hook to handle this. That would allow device > > specific setup to live in the driver. > > > > Perhaps a more simple approach would be just forcing driver probe if a > > DT node is present. I'm not all that familiar with USB drivers, but > > presumably there is some setup before probe like setting the USB > > device address. We'd have to allow doing that later during probe. > > Yes, good idea. I was also advocating that approach for MMC at some > point, but the power sequencing made it in the end. > Currently, my design is much like Rob proposal's. I will populate all children device under HUB's node (controller = 1st level hub), and each special onboard USB device needs a platform driver, it can be probed according to compatible string, and at its probe, it can register itself as usb device if needed, and handle properties described at its node. Sample code like below: At onboard general usb hub driver: static const struct of_device_id usb_hub_generic_dt_ids[] = { {.compatible = "generic-onboard-hub"}, { }, }; MODULE_DEVICE_TABLE(of, usb_hub_generic_dt_ids); static struct platform_driver usb_hub_generic_driver = { .probe = usb_hub_generic_probe, .remove = usb_hub_generic_remove, .driver = { .name = "usb_hub_generic_onboard", .of_match_table = usb_hub_generic_dt_ids, }, }; static int __init usb_hub_generic_init(void) { return platform_driver_register(&usb_hub_generic_driver); } subsys_initcall(usb_hub_generic_init); static void __exit usb_hub_generic_exit(void) { platform_driver_unregister(&usb_hub_generic_driver); } module_exit(usb_hub_generic_exit); diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi index 8263fc1..7451f7d 100644 --- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi @@ -590,6 +590,16 @@ &usbh1 { vbus-supply = <®_usb_h1_vbus>; status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + hub: usb2415@01 { + compatible = "generic-onboard-hub"; + reg = <0x01>; + clocks = <&clks IMX6QDL_CLK_CKO>; + reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>; + reset-duration-us = <10>; + }; }; diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 5e32ce7..2107b12 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,20 @@ 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 int hub_configure(struct usb_hub *hub, struct usb_endpoint_descriptor *endpoint) { @@ -1701,6 +1716,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 +1836,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;