From patchwork Fri Nov 2 05:49:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: p.paneri@samsung.com X-Patchwork-Id: 1687241 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id A9DF4DFABE for ; Fri, 2 Nov 2012 05:42:02 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TU9z8-0006gp-Nj; Fri, 02 Nov 2012 05:40:02 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TU9z2-0006gO-5l for linux-arm-kernel@lists.infradead.org; Fri, 02 Nov 2012 05:39:59 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MCU00IM2IDYNGA0@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 02 Nov 2012 14:39:49 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.122]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 7E.07.12699.4AC53905; Fri, 02 Nov 2012 14:39:48 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-01-50935ca447c4 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 8C.07.12699.4AC53905; Fri, 02 Nov 2012 14:39:48 +0900 (KST) Received: from matrix.sisodomain.com ([107.108.73.199]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MCU00GNMIAE29G0@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 02 Nov 2012 14:39:48 +0900 (KST) From: Praveen Paneri To: linux-usb@vger.kernel.org Subject: [PATCH 2/5] usb: s3c-hsotg: Adding phy driver support Date: Fri, 02 Nov 2012 11:19:09 +0530 Message-id: <1351835349-30210-1-git-send-email-p.paneri@samsung.com> X-Mailer: git-send-email 1.7.1 In-reply-to: References: DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFLMWRmVeSWpSXmKPExsWyRsSkSndJzOQAg21nbSw2Pb7G6sDosXlJ fQBjFJdNSmpOZllqkb5dAlfGk4PNrAVXpCr63lxlaWC8JNrFyMkhIWAiMePGGWYIW0ziwr31 bF2MXBxCAksZJVoOLWeGKbq2dBMrRGI6o0T/7iusIAkhgQ1MEts3l3QxcnCwCWhLNMw0AgmL CMhKHL7yG6yXWWAus0TvDUEQW1jATmLmu5csIDaLgKrEtrtnmEBsXgEXiYn7n7BA7JKT2LH6 CVicUyBYYt+pNkaIVQESS+6+ZoLoFZD4NvkQC8haCaBdmw4wg5wmIXCZTWLjq0dQcyQlDq64 wTKBUXgBI8MqRtHUguSC4qT0XCO94sTc4tK8dL3k/NxNjMAAPP3vmfQOxlUNFocYBTgYlXh4 LVZMChBiTSwrrsw9xCjBwawkwnscJMSbklhZlVqUH19UmpNafIjRB+iSicxSosn5wOjIK4k3 NDYxNzU2tTQyMjM1xSGsJM7b7JESICSQnliSmp2aWpBaBDOOiYNTqoHRkDuAcUc5l+kK8dIH pkHyd6zSnL4vjL85uT3jn+LDk8nPVmUv2zPzuUd4/fmDKhETyh4k3ny/zbTRI0n6Bw+fHHeC X0TmuVcKN05JNe+9/oqBT3TG5W2OS01PcRoWZ67ta7mUnyGwoe6hR83+LYYeU8uncvMuf7S/ Xykyb53kTi+eslaGvBQlluKMREMt5qLiRAAOezNibQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkkeLIzCtJLcpLzFFi42I5/e+xoO6SmMkBBtPu6lhsenyN1YHRY/OS +gDGqAZGm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwNDXUNLC3MlhbzE3FRbJRefAF23zByg qUoKZYk5pUChgMTiYiV9O0wTQkPcdC1gGiN0fUOC4HqMDNBAwhrGjCcHm1kLrkhV9L25ytLA eEm0i5GTQ0LAROLa0k2sELaYxIV769m6GLk4hASmM0r0774ClhAS2MAksX1zSRcjBwebgLZE w0wjkLCIgKzE4Su/mUFsZoG5zBK9NwRBbGEBO4mZ716ygNgsAqoS2+6eYQKxeQVcJCbuf8IC sUtOYsfqJ2BxToFgiX2n2hghVgVILLn7mmkCI+8CRoZVjKKpBckFxUnpuUZ6xYm5xaV56XrJ +bmbGMHh/Ux6B+OqBotDjAIcjEo8vBYrJgUIsSaWFVfmHmKU4GBWEuE9DhLiTUmsrEotyo8v Ks1JLT7E6AN01URmKdHkfGDs5ZXEGxqbmJsam1qaWJiYWeIQVhLnbfZICRASSE8sSc1OTS1I LYIZx8TBKdXAOEkqK3WXbv+uj8bzDM7KKm09GHx830mhx1/u3he54VgobNHJLKwpvUGUSd5F yK14rrmaCFfnlMRi2YsvNHR+Kc/duni390kZ08vHd90S5zg713bKNcsplUz7DF4WBXhIvCq8 +u52avvnnOsH/3iu/RpwyerUruserkk1WlNL7iVvkpOTSKuuV2Ipzkg01GIuKk4EAMDkD/Sc AgAA X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121102_013956_512592_A837675F X-CRM114-Status: GOOD ( 14.87 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.33 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: l.majewski@samsung.com, kgene.kim@samsung.com, heiko@sntech.de, gregkh@linuxfoundation.org, devicetree-discuss@lists.ozlabs.org, broonie@opensource.wolfsonmicro.com, balbi@ti.com, grant.likely@secretlab.ca, kyungmin.park@samsung.com, linux-samsung-soc@vger.kernel.org, thomas.abraham@linaro.org, gautam.vivek@samsung.com, ben-linux@fluff.org, t.figa@samsung.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Adding the phy driver support to hsotg driver. Keeping the platform data for continuing the smooth operation for boards which still uses it. Signed-off-by: Praveen Paneri --- drivers/usb/gadget/s3c-hsotg.c | 37 +++++++++++++++++++++++++++---------- 1 files changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 6f696ee..bc30a2d 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -133,7 +134,9 @@ struct s3c_hsotg_ep { * struct s3c_hsotg - driver state. * @dev: The parent device supplied to the probe function * @driver: USB gadget driver - * @plat: The platform specific configuration data. + * @phy: The otg phy transceiver structure for 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. * @irq: The IRQ number we are using * @supplies: Definition of USB power supplies @@ -153,6 +156,7 @@ struct s3c_hsotg_ep { struct s3c_hsotg { struct device *dev; struct usb_gadget_driver *driver; + struct usb_phy *phy; struct s3c_hsotg_plat *plat; spinlock_t lock; @@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg) struct platform_device *pdev = to_platform_device(hsotg->dev); dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev); - if (hsotg->plat->phy_init) + + if (hsotg->phy) + usb_phy_init(hsotg->phy); + else if (hsotg->plat->phy_init) hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); } @@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg) { struct platform_device *pdev = to_platform_device(hsotg->dev); - if (hsotg->plat->phy_exit) + if (hsotg->phy) + usb_phy_shutdown(hsotg->phy); + else if (hsotg->plat->phy_exit) hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); } @@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev) static int __devinit s3c_hsotg_probe(struct platform_device *pdev) { struct s3c_hsotg_plat *plat = pdev->dev.platform_data; + struct usb_phy *phy; struct device *dev = &pdev->dev; struct s3c_hsotg_ep *eps; struct s3c_hsotg *hsotg; @@ -3501,20 +3511,27 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) int ret; int i; - plat = pdev->dev.platform_data; - if (!plat) { - dev_err(&pdev->dev, "no platform data defined\n"); - return -EINVAL; - } - hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL); if (!hsotg) { dev_err(dev, "cannot get memory\n"); return -ENOMEM; } + phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + if (IS_ERR_OR_NULL(phy)) { + /* Fallback for pdata */ + plat = pdev->dev.platform_data; + if (!plat) { + dev_err(&pdev->dev, "no platform data or transceiver defined\n"); + return -EPROBE_DEFER; + } else { + hsotg->plat = plat; + } + } else { + hsotg->phy = phy; + } + hsotg->dev = dev; - hsotg->plat = plat; hsotg->clk = devm_clk_get(&pdev->dev, "otg"); if (IS_ERR(hsotg->clk)) {