From patchwork Fri Aug 2 00:52:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julius Werner X-Patchwork-Id: 2837429 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7547C9F47C for ; Fri, 2 Aug 2013 00:54:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0B9B4202F1 for ; Fri, 2 Aug 2013 00:54:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E906920300 for ; Fri, 2 Aug 2013 00:54:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753451Ab3HBAxl (ORCPT ); Thu, 1 Aug 2013 20:53:41 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:44125 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753169Ab3HBAxH (ORCPT ); Thu, 1 Aug 2013 20:53:07 -0400 Received: by mail-pd0-f174.google.com with SMTP id 10so52285pdc.5 for ; Thu, 01 Aug 2013 17:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=iqhECppTrJKuzVFN6chvzjoQ6d1BQNN+7SKcEnjKoXs=; b=octRZIzewvk8/Y+WZLtdxB5Kxdg/+7CeiNT3z4f4xDDdusgkawVcassfzNuc73wIMy f0nhhs/sFOArac9pXFnWfxsYM4h9MlZMlFB5QHIJWq/xQ/PAXHya5qP7Nz01RGJF3Fca 9iZd/ymjs9dsGUqFaMyXEHEbIdoJ72PiAb0MY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=iqhECppTrJKuzVFN6chvzjoQ6d1BQNN+7SKcEnjKoXs=; b=e49jMe06YC9U/TkrDITHNTMcu12PUGR+QaNLvRos4TFrR7vKQPwqTZgXg3kT1raWzY HFRRyhsXdFtOLg/RV7rNB12+2Smmo6Wmb5nZPrfGPIveAxxcaTgAlgP8To7czLz4CqfZ jiPRMkD/ioybDY7z9cK4n3JYqJgGJj6Sod9wiHvazAbFMGg7yJ3lMgCOETyxZEbKJqE3 I+QHUlAbGsrfRgrhGP/uo793IyE0L4ysMaJb60iWz4Drj3MPSFjv2k5lFdw017nMCQ7z HWwUT1EGcgaam6T/whhFL6HbF3yQTGppofbzmfkc4kkzZNIwobNkOcvcTbq1zs4t0fy4 8fBw== X-Received: by 10.66.7.104 with SMTP id i8mr7409850paa.130.1375404786795; Thu, 01 Aug 2013 17:53:06 -0700 (PDT) Received: from jwerner-linux.mtv.corp.google.com (jwerner-linux.mtv.corp.google.com [172.22.72.75]) by mx.google.com with ESMTPSA id mr3sm6711199pbb.27.2013.08.01.17.53.05 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 Aug 2013 17:53:06 -0700 (PDT) From: Julius Werner To: Felipe Balbi Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Tomasz Figa , Vivek Gautam , devicetree@vger.kernel.org, Sylwester Nawrocki , Julius Werner Subject: [PATCH 3/3] usb: phy-samsung-usb: Remove USB_PHY_TYPE from Samsung PHY driver Date: Thu, 1 Aug 2013 17:52:06 -0700 Message-Id: <1375404726-26264-4-git-send-email-jwerner@chromium.org> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1375404726-26264-1-git-send-email-jwerner@chromium.org> References: <1375404726-26264-1-git-send-email-jwerner@chromium.org> X-Gm-Message-State: ALoCoQmpIHgNLIguKGop+3T3kdzfksXsILgdxZvEHoE4iKLfiVGce7iEkeaVBJ8i9BMQ9HRV5r9p Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Since the PMU register handling was simplified, the last reason to differentiate between HOST and DEVICE PHYs in the Samsung USB PHY driver has disappeared. This patch removes that variable and reworks surrounding code to live without it to make the driver a little smaller and cleaner. Signed-off-by: Julius Werner --- drivers/usb/phy/phy-samsung-usb.c | 23 +++-------------------- drivers/usb/phy/phy-samsung-usb.h | 7 +------ drivers/usb/phy/phy-samsung-usb2.c | 19 +++---------------- drivers/usb/phy/phy-samsung-usb3.c | 7 ------- 4 files changed, 7 insertions(+), 49 deletions(-) diff --git a/drivers/usb/phy/phy-samsung-usb.c b/drivers/usb/phy/phy-samsung-usb.c index fa382c9..32c5264 100644 --- a/drivers/usb/phy/phy-samsung-usb.c +++ b/drivers/usb/phy/phy-samsung-usb.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "phy-samsung-usb.h" @@ -101,7 +100,7 @@ EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation_4210); /* * Configure the mode of working of usb-phy here: HOST/DEVICE. */ -void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy) +void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy, bool device_mode) { u32 reg; @@ -112,31 +111,15 @@ void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy) reg = readl(sphy->sysreg); - if (sphy->phy_type == USB_PHY_TYPE_DEVICE) + if (device_mode) reg &= ~EXYNOS_USB20PHY_CFG_HOST_LINK; - else if (sphy->phy_type == USB_PHY_TYPE_HOST) + else reg |= EXYNOS_USB20PHY_CFG_HOST_LINK; writel(reg, sphy->sysreg); } EXPORT_SYMBOL_GPL(samsung_usbphy_cfg_sel); -/* - * PHYs are different for USB Device and USB Host. - * This make sure that correct PHY type is selected before - * any operation on PHY. - */ -int samsung_usbphy_set_type(struct usb_phy *phy, - enum samsung_usb_phy_type phy_type) -{ - struct samsung_usbphy *sphy = phy_to_sphy(phy); - - sphy->phy_type = phy_type; - - return 0; -} -EXPORT_SYMBOL_GPL(samsung_usbphy_set_type); - int samsung_usbphy_rate_to_clksel_64xx(struct samsung_usbphy *sphy, unsigned long rate) { diff --git a/drivers/usb/phy/phy-samsung-usb.h b/drivers/usb/phy/phy-samsung-usb.h index f2e9c4a..0c0d7d1 100644 --- a/drivers/usb/phy/phy-samsung-usb.h +++ b/drivers/usb/phy/phy-samsung-usb.h @@ -285,8 +285,6 @@ struct samsung_usbphy_drvdata { * @sysreg: USB2.0 PHY_CFG register memory base * @ref_clk_freq: reference clock frequency selection * @drv_data: driver data available for different SoCs - * @phy_type: Samsung SoCs specific phy types: #HOST - * #DEVICE * @phy_usage: usage count for phy * @lock: lock for phy operations */ @@ -300,7 +298,6 @@ struct samsung_usbphy { void __iomem *sysreg; int ref_clk_freq; const struct samsung_usbphy_drvdata *drv_data; - enum samsung_usb_phy_type phy_type; atomic_t phy_usage; spinlock_t lock; }; @@ -326,9 +323,7 @@ static inline const struct samsung_usbphy_drvdata extern int samsung_usbphy_parse_dt(struct samsung_usbphy *sphy); extern void samsung_usbphy_set_isolation_4210(struct samsung_usbphy *sphy, bool on); -extern void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy); -extern int samsung_usbphy_set_type(struct usb_phy *phy, - enum samsung_usb_phy_type phy_type); +extern void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy, bool dev_mode); extern int samsung_usbphy_get_refclk_freq(struct samsung_usbphy *sphy); extern int samsung_usbphy_rate_to_clksel_64xx(struct samsung_usbphy *sphy, unsigned long rate); diff --git a/drivers/usb/phy/phy-samsung-usb2.c b/drivers/usb/phy/phy-samsung-usb2.c index c2c83d4..eb215a1 100644 --- a/drivers/usb/phy/phy-samsung-usb2.c +++ b/drivers/usb/phy/phy-samsung-usb2.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "phy-samsung-usb.h" @@ -283,13 +282,13 @@ static int samsung_usb2phy_init(struct usb_phy *phy) spin_lock_irqsave(&sphy->lock, flags); + /* Selecting Host/OTG mode; After reset USB2.0PHY_CFG: HOST */ if (host) { - /* setting default phy-type for USB 2.0 */ if (!strstr(dev_name(host->controller), "ehci") || !strstr(dev_name(host->controller), "ohci")) - samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_HOST); + samsung_usbphy_cfg_sel(sphy, false); } else { - samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE); + samsung_usbphy_cfg_sel(sphy, true); } /* Disable phy isolation */ @@ -298,9 +297,6 @@ static int samsung_usb2phy_init(struct usb_phy *phy) else if (sphy->drv_data->set_isolation) sphy->drv_data->set_isolation(sphy, false); - /* Selecting Host/OTG mode; After reset USB2.0PHY_CFG: HOST */ - samsung_usbphy_cfg_sel(sphy); - /* Initialize usb phy registers */ sphy->drv_data->phy_enable(sphy); @@ -332,15 +328,6 @@ static void samsung_usb2phy_shutdown(struct usb_phy *phy) spin_lock_irqsave(&sphy->lock, flags); - if (host) { - /* setting default phy-type for USB 2.0 */ - if (!strstr(dev_name(host->controller), "ehci") || - !strstr(dev_name(host->controller), "ohci")) - samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_HOST); - } else { - samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE); - } - /* De-initialize usb phy registers */ sphy->drv_data->phy_disable(sphy); diff --git a/drivers/usb/phy/phy-samsung-usb3.c b/drivers/usb/phy/phy-samsung-usb3.c index 6259a35..ac05d91 100644 --- a/drivers/usb/phy/phy-samsung-usb3.c +++ b/drivers/usb/phy/phy-samsung-usb3.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "phy-samsung-usb.h" @@ -178,9 +177,6 @@ static int samsung_usb3phy_init(struct usb_phy *phy) spin_lock_irqsave(&sphy->lock, flags); - /* setting default phy-type for USB 3.0 */ - samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE); - /* Disable phy isolation */ if (sphy->drv_data->set_isolation) sphy->drv_data->set_isolation(sphy, false); @@ -213,9 +209,6 @@ static void samsung_usb3phy_shutdown(struct usb_phy *phy) spin_lock_irqsave(&sphy->lock, flags); - /* setting default phy-type for USB 3.0 */ - samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE); - /* De-initialize usb phy registers */ sphy->drv_data->phy_disable(sphy);