From patchwork Fri Nov 1 19:45:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 3127501 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B7087BEEB2 for ; Fri, 1 Nov 2013 19:49:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9AA1203F4 for ; Fri, 1 Nov 2013 19:49:42 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3358201BF for ; Fri, 1 Nov 2013 19:49:41 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VcKhC-0004Rh-3c; Fri, 01 Nov 2013 19:47:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VcKgn-00082v-V8; Fri, 01 Nov 2013 19:47:25 +0000 Received: from mail-ie0-f179.google.com ([209.85.223.179]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VcKg7-0007tZ-4H for linux-arm-kernel@lists.infradead.org; Fri, 01 Nov 2013 19:46:46 +0000 Received: by mail-ie0-f179.google.com with SMTP id aq17so7982356iec.24 for ; Fri, 01 Nov 2013 12:46:22 -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:in-reply-to :references; bh=0uSRXCTlkvSvE/ZsRrlCUb1N2gBik//2BD3Fh9ZfdaY=; b=loGB8DgvTj6Ldheb7VHx7qfTTQ1wJyBiM8VrWaTm914oJtZQzOuEsyaQj3KLjucMD7 V8Tcnn/KC4rHqwUCKNBXI9nbzzNfeg2Ijjr1f3L9m+sunqP9UTmG17pR3kf9n7K/Txlu VHS+VPU2AIAc/Gv9xc9YpDyR/+HmASec74WQtoTElgr7GVAS6pxPm5Ei+HRK4JgHY5Fy wwuyemLZWe1ueLIQGl2WpWQIR+fOKZ8l6p85ciGqPDT3qXKXjYWDkCOABpknM4WPgEYw 1sDCQ0HGn5EPUkKn5PiJGY/CHc23nQfDN75VHl6e7V+jT4JUZ/koy5NiH9iBc8Jijt86 vjEQ== X-Gm-Message-State: ALoCoQkfBdWVrkIl/LReCpv7QEFxC/8SU8VMrC8x1Twuz08aZrXaw5kK35TSfLiaDDKlOENYNSDg X-Received: by 10.50.39.84 with SMTP id n20mr3566266igk.14.1383335181973; Fri, 01 Nov 2013 12:46:21 -0700 (PDT) Received: from beef.ohporter.com (cpe-98-27-254-98.neo.res.rr.com. [98.27.254.98]) by mx.google.com with ESMTPSA id f5sm5616338igc.4.2013.11.01.12.46.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Nov 2013 12:46:21 -0700 (PDT) From: Matt Porter To: Felipe Balbi , Greg Kroah-Hartman , Kishon Vijay Abraham I , Rob Herring , Pawel Moll , Mark Rutland , Kumar Gala , Ian Campbell , Christian Daudt , Paul Zimmerman Subject: [PATCH v2 5/9] usb: gadget: s3c-hsotg: enable generic phy support Date: Fri, 1 Nov 2013 15:45:54 -0400 Message-Id: <1383335158-19730-6-git-send-email-matt.porter@linaro.org> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1383335158-19730-1-git-send-email-matt.porter@linaro.org> References: <1383335158-19730-1-git-send-email-matt.porter@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131101_154643_257163_87523E46 X-CRM114-Status: GOOD ( 17.73 ) X-Spam-Score: -2.6 (--) Cc: Devicetree List , Linux USB List , Linux Kernel Mailing List , Linux ARM Kernel List , Linaro Patches X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Adds support for the generic PHY subsystem. Generic PHY support is probed and then the driver falls back to checking for an old style USB PHY and pdata if not found. Signed-off-by: Matt Porter --- drivers/usb/gadget/s3c-hsotg.c | 54 ++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 3e0c124..f97978b 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include "s3c-hsotg.h" @@ -131,7 +132,8 @@ struct s3c_hsotg_ep { * struct s3c_hsotg - driver state. * @dev: The parent device supplied to the probe function * @driver: USB gadget driver - * @phy: The otg phy transceiver structure for phy control. + * @phy: The otg phy transceiver structure for old USB phy control. + * @gphy: The otg phy transceiver structure for generic phy control. * @plat: The platform specific configuration data. This can be removed once * all SoCs support usb transceiver. * @regs: The memory area mapped for accessing registers. @@ -154,6 +156,7 @@ struct s3c_hsotg { struct device *dev; struct usb_gadget_driver *driver; struct usb_phy *phy; + struct phy *gphy; struct s3c_hsotg_plat *plat; spinlock_t lock; @@ -2820,9 +2823,12 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg) dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); - if (hsotg->phy) + if (hsotg->gphy) { + phy_init(hsotg->gphy); + phy_power_on(hsotg->gphy); + } else if (hsotg->phy) { usb_phy_init(hsotg->phy); - else if (hsotg->plat->phy_init) + } else if (hsotg->plat->phy_init) hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); } @@ -2837,9 +2843,12 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) { struct platform_device *pdev = to_platform_device(hsotg->dev); - if (hsotg->phy) + if (hsotg->gphy) { + phy_power_off(hsotg->gphy); + phy_exit(hsotg->gphy); + } else if (hsotg->phy) { usb_phy_shutdown(hsotg->phy); - else if (hsotg->plat->phy_exit) + } else if (hsotg->plat->phy_exit) hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); } @@ -3446,6 +3455,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev) { struct s3c_hsotg_plat *plat = dev_get_platdata(&pdev->dev); struct usb_phy *phy; + struct phy *gphy; struct device *dev = &pdev->dev; struct s3c_hsotg_ep *eps; struct s3c_hsotg *hsotg; @@ -3460,19 +3470,27 @@ static int s3c_hsotg_probe(struct platform_device *pdev) return -ENOMEM; } - phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); - if (IS_ERR(phy)) { - /* Fallback for pdata */ - plat = dev_get_platdata(&pdev->dev); - if (!plat) { - dev_err(&pdev->dev, "no platform data or transceiver defined\n"); - return -EPROBE_DEFER; - } else { - hsotg->plat = plat; - } - } else { - hsotg->phy = phy; - } + /* + * Attempt to find a generic PHY, then look for an old style + * USB PHY, finally fall back to pdata + */ + gphy = devm_phy_get(dev, "usb2-phy"); + if (IS_ERR(gphy)) { + phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + if (IS_ERR(phy)) { + /* Fallback for pdata */ + plat = dev_get_platdata(&pdev->dev); + if (!plat) { + dev_err(&pdev->dev, + "no platform data or transceiver defined\n"); + return -EPROBE_DEFER; + } else { + hsotg->plat = plat; + } + } else + hsotg->phy = phy; + } else + hsotg->gphy = gphy; hsotg->dev = dev;