From patchwork Tue Jul 22 22:17:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 4605971 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 528A89F295 for ; Tue, 22 Jul 2014 22:18:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59FDA20179 for ; Tue, 22 Jul 2014 22:18:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5FA1620173 for ; Tue, 22 Jul 2014 22:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757090AbaGVWSA (ORCPT ); Tue, 22 Jul 2014 18:18:00 -0400 Received: from mail-la0-f43.google.com ([209.85.215.43]:36906 "EHLO mail-la0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757088AbaGVWR6 (ORCPT ); Tue, 22 Jul 2014 18:17:58 -0400 Received: by mail-la0-f43.google.com with SMTP id hr17so258190lab.16 for ; Tue, 22 Jul 2014 15:17:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:organization:to:subject:date:user-agent:cc :mime-version:content-type:content-transfer-encoding:message-id; bh=04zlNGH9CAefIYrOQ7b7ogHLA4S0DvZhG7VpvyMC65o=; b=jgwjPZjT2eDoty1qLas9Oq2tiowkIHESqj8M12JyA3XiOampegB+AglIBnQmauHw9d IvqEjUCgz5sR6y6HCnnfi/npEjqPZmly4HFrU0EWNENveeI6slIr+tUP+lioLFsRlWFE HKepafUdWjHKqHVuyAqro5Le7d2v+BWhFhRm3ON4QLBRyeXSqDth5hUYoW5bLeRIgwvI lR0rSRiKBlCyGRZEqW5XrGJthGJofgCJ1c7oZW58ToyCUmoIiNDIOV8SOFrxE/M8SGxn yRbSp2qMFnNvHtdxe5xzEKZlOBBsMsCqJvWAGGIAmu46AyPl0XuO29/uuDVovC3LCrZZ j04w== X-Gm-Message-State: ALoCoQmiby0FwPJzgCyBLs9ZEMQzxjHSa5frQX9BAYPEiTMI9fVYO57q6l+T990IDe8RFSp8hZrX X-Received: by 10.152.29.170 with SMTP id l10mr38746181lah.43.1406067477015; Tue, 22 Jul 2014 15:17:57 -0700 (PDT) Received: from wasted.cogentembedded.com (ppp27-157.pppoe.mtu-net.ru. [81.195.27.157]) by mx.google.com with ESMTPSA id k1sm2384953lbc.14.2014.07.22.15.17.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 22 Jul 2014 15:17:56 -0700 (PDT) From: Sergei Shtylyov Organization: Cogent Embedded To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org Subject: [PATCH v4] usb: hcd: add generic PHY support Date: Wed, 23 Jul 2014 02:17:55 +0400 User-Agent: KMail/1.13.5 (Linux/2.6.32.26-175.fc12.i686.PAE; KDE/4.4.5; i686; ; ) Cc: linux-sh@vger.kernel.org, yoshihiro.shimoda.uh@renesas.com MIME-Version: 1.0 Message-Id: <201407230217.56283.sergei.shtylyov@cogentembedded.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Add the generic PHY support, analogous to the USB PHY support. Intended it to be used with the PCI EHCI/OHCI drivers and the xHCI platform driver. Signed-off-by: Sergei Shtylyov Signed-off-by: Yoshihiro Shimoda --- This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. The USB PHY driver patch with which this patch is intended to be used, has been just posted, along with the platform PHY device tree patches; the patches that link the PCI EHCI/OHCI devices to the PHY device will follow shortly. Changes in version 4: - refreshed the patch. Changes in version 3: - refreshed the patch. Changes in version 2: - renamed the new 'phy' field of 'struct usb_phy' to 'gen_phy'; - resolved rejects due to removal of the first patch in the series. drivers/usb/core/hcd.c | 42 ++++++++++++++++++++++++++++++++++++++++-- include/linux/usb/hcd.h | 3 ++- 2 files changed, 42 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: usb/drivers/usb/core/hcd.c =================================================================== --- usb.orig/drivers/usb/core/hcd.c +++ usb/drivers/usb/core/hcd.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -2645,6 +2646,29 @@ int usb_add_hcd(struct usb_hcd *hcd, } } + if (IS_ENABLED(CONFIG_GENERIC_PHY)) { + struct phy *phy = phy_get(hcd->self.controller, "usb"); + + if (IS_ERR(phy)) { + retval = PTR_ERR(phy); + if (retval == -EPROBE_DEFER) + goto err_phy; + } else { + retval = phy_init(phy); + if (retval) { + phy_put(phy); + goto err_phy; + } + retval = phy_power_on(phy); + if (retval) { + phy_exit(phy); + phy_put(phy); + goto err_phy; + } + hcd->gen_phy = phy; + } + } + dev_info(hcd->self.controller, "%s\n", hcd->product_desc); /* Keep old behaviour if authorized_default is not in [0, 1]. */ @@ -2660,7 +2684,7 @@ int usb_add_hcd(struct usb_hcd *hcd, */ if ((retval = hcd_buffer_create(hcd)) != 0) { dev_dbg(hcd->self.controller, "pool alloc failed\n"); - goto err_remove_phy; + goto err_create_buf; } if ((retval = usb_register_bus(&hcd->self)) < 0) @@ -2787,7 +2811,14 @@ err_allocate_root_hub: usb_deregister_bus(&hcd->self); err_register_bus: hcd_buffer_destroy(hcd); -err_remove_phy: +err_create_buf: + if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->gen_phy) { + phy_power_off(hcd->gen_phy); + phy_exit(hcd->gen_phy); + phy_put(hcd->gen_phy); + hcd->gen_phy = NULL; + } +err_phy: if (hcd->remove_phy && hcd->phy) { usb_phy_shutdown(hcd->phy); usb_put_phy(hcd->phy); @@ -2864,6 +2895,13 @@ void usb_remove_hcd(struct usb_hcd *hcd) usb_deregister_bus(&hcd->self); hcd_buffer_destroy(hcd); + + if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->gen_phy) { + phy_power_off(hcd->gen_phy); + phy_exit(hcd->gen_phy); + phy_put(hcd->gen_phy); + hcd->gen_phy = NULL; + } if (hcd->remove_phy && hcd->phy) { usb_phy_shutdown(hcd->phy); usb_put_phy(hcd->phy); Index: usb/include/linux/usb/hcd.h =================================================================== --- usb.orig/include/linux/usb/hcd.h +++ usb/include/linux/usb/hcd.h @@ -106,7 +106,8 @@ struct usb_hcd { * OTG and some Host controllers need software interaction with phys; * other external phys should be software-transparent */ - struct usb_phy *phy; + struct usb_phy *phy; + struct phy *gen_phy; /* Flags that need to be manipulated atomically because they can * change while the host controller is running. Always use