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: 21310 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4301623908 for ; Fri, 1 Nov 2013 19:46:23 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id 6sf9050549qeb.0 for ; Fri, 01 Nov 2013 12:46:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=0uSRXCTlkvSvE/ZsRrlCUb1N2gBik//2BD3Fh9ZfdaY=; b=dl02Zq4ZJgGA/qG8kMYWBTUZe2W06//9mC7I2UZbFiJbVHMoAchhOVyt5w0TNltR9M Vdd9y7u/auvWpD8Y1/o7gjJcUTSrCTw6Dlfv8MRb7+LhPxibrTmB5v1nwCNEMKdYYXbM LjZnR+7UHetQ6Sp8g7P0NzIDK8IBrAa9blryiVOOg6uH+Awy779Jkm2+5z+EQzbYo3Rh TTrsEXqR9tuCko3hOcEafdKUos9PdzKJwY55crnwIkfKnHvSS6Wg4xb13QWlwTAtpW7s xWfWaRFLkRXGKbaJ1gLB7WD4d8FaG/guRhaF+n6iAFtGDhXH7/EANa73IvOu5z84I+N0 rnNA== X-Gm-Message-State: ALoCoQmr3RsGlDNsmhrYTE1tP6oowVtGrcf2xfSBTa/pCzUqxblsNCvlE/2dFGywL2TbLUEFyly3 X-Received: by 10.236.220.39 with SMTP id n37mr2104228yhp.15.1383335183127; Fri, 01 Nov 2013 12:46:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.81.9 with SMTP id v9ls1431879qex.99.gmail; Fri, 01 Nov 2013 12:46:23 -0700 (PDT) X-Received: by 10.58.168.205 with SMTP id zy13mr3102796veb.19.1383335183002; Fri, 01 Nov 2013 12:46:23 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id ta5si1035686veb.107.2013.11.01.12.46.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Nov 2013 12:46:22 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hz11so3264900vcb.10 for ; Fri, 01 Nov 2013 12:46:22 -0700 (PDT) X-Received: by 10.58.50.194 with SMTP id e2mr150563veo.54.1383335182922; Fri, 01 Nov 2013 12:46:22 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp66768vcz; Fri, 1 Nov 2013 12:46:22 -0700 (PDT) X-Received: by 10.50.61.35 with SMTP id m3mr3498808igr.56.1383335182256; Fri, 01 Nov 2013 12:46:22 -0700 (PDT) Received: from mail-ie0-f172.google.com (mail-ie0-f172.google.com [209.85.223.172]) by mx.google.com with ESMTPS id u10si9909475icp.101.2013.11.01.12.46.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Nov 2013 12:46:22 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.223.172 is neither permitted nor denied by best guess record for domain of matt.porter@linaro.org) client-ip=209.85.223.172; Received: by mail-ie0-f172.google.com with SMTP id tp5so8308732ieb.31 for ; Fri, 01 Nov 2013 12:46:22 -0700 (PDT) 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 Cc: Linux USB List , Linux ARM Kernel List , Linux Kernel Mailing List , Devicetree List , Linaro Patches 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: matt.porter@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;