From patchwork Wed Aug 1 13:05:48 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: 1264211 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 6F472DF215 for ; Wed, 1 Aug 2012 12:59:30 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SwYUJ-0000wN-03; Wed, 01 Aug 2012 12:57:19 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SwYU8-0000vV-2R for linux-arm-kernel@lists.infradead.org; Wed, 01 Aug 2012 12:57:10 +0000 Received: from epcpsbgm1.samsung.com (mailout3.samsung.com [203.254.224.33]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M82003AFUN71XB0@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 01 Aug 2012 21:57:07 +0900 (KST) X-AuditID: cbfee61a-b7f616d000004b7e-c5-501927a21819 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 2A.FB.19326.2A729105; Wed, 01 Aug 2012 21:57:07 +0900 (KST) Received: from matrix.sisodomain.com ([107.108.73.199]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M82005GSUMJPX20@mmp1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 01 Aug 2012 21:57:06 +0900 (KST) From: Praveen Paneri To: linux-usb@vger.kernel.org Subject: [PATCH 2/5] usb: s3c-hsotg: Adding phy driver support Date: Wed, 01 Aug 2012 18:35:48 +0530 Message-id: <1343826351-8756-3-git-send-email-p.paneri@samsung.com> X-Mailer: git-send-email 1.7.1 In-reply-to: <1343826351-8756-1-git-send-email-p.paneri@samsung.com> References: <1343826351-8756-1-git-send-email-p.paneri@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIJMWRmVeSWpSXmKPExsVy+t9jAd3F6pIBBvtns1lsenyN1YHRY/OS +gDGKC6blNSczLLUIn27BK6MFWfnshd8lam4sGcRWwPjBfEuRk4OCQETicd7d7FC2GISF+6t Z+ti5OIQEljEKHHn7SFWCGcDk8TENTeYuhg5ONgEtCUaZhqBNIgIyEocvvKbGcRmFrjDJHGo NR3EFhawk5j57iULiM0ioCrROeMqWA2vgLPEyykz2CGWyUnsWP2ECcTmFHCR2HL8DdgRQkA1 z9p/Mk1g5F3AyLCKUTS1ILmgOCk911CvODG3uDQvXS85P3cTI9jjz6R2MK5ssDjEKMDBqMTD O9FEIkCINbGsuDL3EKMEB7OSCK+timSAEG9KYmVValF+fFFpTmrxIUZpDhYlcV5j76/+QgLp iSWp2ampBalFMFkmDk6pBsYjYSIzpJdOblpU8+3iox3bz/qY+IeLu3tuOSjTo3GtcumKyBl9 7yqqvytv6F2mKRB8/Wts8+odm/rKJ5u1R+xU0z94tyLR7sEFI7lJLLF12zk3b/jH7+V5hkHI l3ve7wPWuhJ/wzxqTntK2NUcWfjsrqqGxeG2a2c2r0p4t+lpQKr+gqSV+wuVWIozEg21mIuK EwGskedz9AEAAA== X-TM-AS-MML: No X-Spam-Note: CRM114 invocation failed X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.9 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.0 T_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, 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, ben-linux@fluff.org, 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 transceiver 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 | 38 ++++++++++++++++++++++++++++---------- 1 files changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index b13e0bb..f4ba9a3 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 transeiver 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,25 @@ 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 (!phy) { + /* Fallback for platform data */ + plat = pdev->dev.platform_data; + if (!plat) { + dev_err(&pdev->dev, "no platform data or transceiver defined\n"); + return -ENODEV; + } else + hsotg->plat = plat; + } else + hsotg->phy = phy; + hsotg->dev = dev; - hsotg->plat = plat; hsotg->clk = clk_get(&pdev->dev, "otg"); if (IS_ERR(hsotg->clk)) { @@ -3689,6 +3704,9 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev) s3c_hsotg_phy_disable(hsotg); regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); + if (hsotg->phy) + devm_usb_put_phy(&pdev->dev, hsotg->phy); + clk_disable_unprepare(hsotg->clk); clk_put(hsotg->clk);