From patchwork Wed Sep 24 19:09:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 4969471 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7D390BEEA5 for ; Wed, 24 Sep 2014 19:10:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E424201B9 for ; Wed, 24 Sep 2014 19:10:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0008201DD for ; Wed, 24 Sep 2014 19:10:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751500AbaIXTJt (ORCPT ); Wed, 24 Sep 2014 15:09:49 -0400 Received: from mail-la0-f53.google.com ([209.85.215.53]:47974 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751076AbaIXTJs (ORCPT ); Wed, 24 Sep 2014 15:09:48 -0400 Received: by mail-la0-f53.google.com with SMTP id ge10so11410974lab.12 for ; Wed, 24 Sep 2014 12:09:46 -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:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=XT5YZxU1WmMIPEwsQBb2lc6kfbchChsOVfqL3M+y/Ik=; b=RSSNgllwbJbq6jmXJ10x1E+JX7SYmqsQtnDxAJ4JZU1fSgUQqH3kFWsrlZMPJvC71E 1xugKUitS/lJDZD6l0LMvCkp13hCRazfMmFYgaORdS99m0DLAG5MjdwwecTVjDczVjBg nFnaPDCuFHBv/sN2gioD6GJ5smTSjgJKh2mEC5D8wFsNYfTJ8TAL66fs5Ynu0/9KSVoE xixAgLJ+oQsUIqJ6pCpICkPyr0bCUn4ezi5uXEHqZp1ctqTlxJPNgYBJ1Vy7rGEloQTi A22VlNJ4tpbpm9lk9doKTsBh6RShVAX0YEe/qALbrcvOkpA9miT3p/ORiGz7LKRtRS8M 2UQg== X-Gm-Message-State: ALoCoQn7YOJcvvxh0iAs0TKiopz8S1sHA0y1ibFi9FqO6q1VDXsW5gUQfCcAeHN4qY7L6EL1J4Od X-Received: by 10.112.141.7 with SMTP id rk7mr8153798lbb.6.1411585786832; Wed, 24 Sep 2014 12:09:46 -0700 (PDT) Received: from wasted.cogentembedded.com (ppp21-194.pppoe.mtu-net.ru. [81.195.21.194]) by mx.google.com with ESMTPSA id z2sm50530laa.15.2014.09.24.12.09.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Sep 2014 12:09:46 -0700 (PDT) From: Sergei Shtylyov To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, antoine.tenart@free-electrons.com, yoshihiro.shimoda.uh@renesas.com Subject: [PATCH v6 2/2] usb: hcd: add generic PHY support Date: Wed, 24 Sep 2014 23:09:44 +0400 Message-ID: <4738517.TNcWBCM3Rf@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.13.3 (Linux/3.15.10-201.fc20.x86_64; KDE/4.13.3; x86_64; ; ) In-Reply-To: <37148636.BU5lT4M4eC@wasted.cogentembedded.com> References: <37148636.BU5lT4M4eC@wasted.cogentembedded.com> MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 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 --- Changes in version 5: - renamed the new 'gen_phy' field of 'struct usb_phy' back to 'phy'; - resolved rejects occured due to a newly added patch. 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 | 1 + 2 files changed, 41 insertions(+), 2 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->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->phy) { + phy_power_off(hcd->phy); + phy_exit(hcd->phy); + phy_put(hcd->phy); + hcd->phy = NULL; + } +err_phy: if (hcd->remove_phy && hcd->usb_phy) { usb_phy_shutdown(hcd->usb_phy); usb_put_phy(hcd->usb_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->phy) { + phy_power_off(hcd->phy); + phy_exit(hcd->phy); + phy_put(hcd->phy); + hcd->phy = NULL; + } if (hcd->remove_phy && hcd->usb_phy) { usb_phy_shutdown(hcd->usb_phy); usb_put_phy(hcd->usb_phy); Index: usb/include/linux/usb/hcd.h =================================================================== --- usb.orig/include/linux/usb/hcd.h +++ usb/include/linux/usb/hcd.h @@ -107,6 +107,7 @@ struct usb_hcd { * other external phys should be software-transparent */ struct usb_phy *usb_phy; + struct phy *phy; /* Flags that need to be manipulated atomically because they can * change while the host controller is running. Always use