From patchwork Tue Mar 26 14:53:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2337831 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B25303FC54 for ; Tue, 26 Mar 2013 14:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934566Ab3CZOxo (ORCPT ); Tue, 26 Mar 2013 10:53:44 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:43197 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933632Ab3CZOxn (ORCPT ); Tue, 26 Mar 2013 10:53:43 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MK900FOKW1GGU00@mailout1.samsung.com>; Tue, 26 Mar 2013 23:53:42 +0900 (KST) X-AuditID: cbfee61a-b7fa86d0000045ae-0a-5151b674789a Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 41.74.17838.476B1515; Tue, 26 Mar 2013 23:53:40 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MK9000TTW0VGU70@mmp1.samsung.com>; Tue, 26 Mar 2013 23:53:40 +0900 (KST) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Cc: linux-usb@vger.kernel.org, balbi@ti.com, kyungmin.park@samsung.com, kgene.kim@samsung.com, p.paneri@samsung.com, gautam.vivek@samsung.com, m.szyprowski@samsung.com, Tomasz Figa Subject: [PATCH 4/6] usb: phy: samsung: Pass set_isolation callback through driver data Date: Tue, 26 Mar 2013 15:53:13 +0100 Message-id: <1364309595-16102-5-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1364309595-16102-1-git-send-email-t.figa@samsung.com> References: <1364309595-16102-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprELMWRmVeSWpSXmKPExsVy+t9jAd2SbYGBBh/O61kcvF9v0XblILtF 74KrbBZnm96wW8w4v4/JYtGyVmaLtUfusluc39LJZLF+xmsWB06Pvi2rGD2O39jO5PF5k1wA cxSXTUpqTmZZapG+XQJXxt99xxkLWs0qpt9/ytrA+EC3i5GTQ0LAROL0/TnMELaYxIV769m6 GLk4hAQWMUqs/3CECSQhJNDFJDFrWw2IzSagJvG54REbiC0ioCrxuW0BO0gDs8BZRonGjqMs IAlhgUiJHTtmg9ksQEVPVy0FG8Qr4CTxeNsHRoht8hJP7/eBDeIUcJa4PmkJ0CAOoGVOEvta yicw8i5gZFjFKJpakFxQnJSea6hXnJhbXJqXrpecn7uJERxSz6R2MK5ssDjEKMDBqMTDuyE4 IFCINbGsuDL3EKMEB7OSCK/gxsBAId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rwHWq0DhQTSE0tS s1NTC1KLYLJMHJxSDYycl8uuXyrrK1XnC9cP2Mnoe2W5oPy0ouMWK1dbmMr5fJJlVJ0nwBfz +M00+dM6Bcnivh8mquWlf/39Q27l+hN5MaynIn2+/f+zTvLIwnP6mlYz9i+4Zav7Xeqsgt+f /uRXETUN/wMNtS1adyb/lVF6EXEwsji6x+jv4pkx946lLiydoHzML1+JpTgj0VCLuag4EQCJ 9WUXJQIAAA== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch extends driver data structure with set_isolation callback, which allows to remove the need for checking for SoC type in a switch statement. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park --- drivers/usb/phy/phy-samsung-usb.c | 36 ++++++++---------------------------- drivers/usb/phy/phy-samsung-usb.h | 4 +++- drivers/usb/phy/phy-samsung-usb2.c | 11 +++++++---- drivers/usb/phy/phy-samsung-usb3.c | 7 +++++-- 4 files changed, 23 insertions(+), 35 deletions(-) diff --git a/drivers/usb/phy/phy-samsung-usb.c b/drivers/usb/phy/phy-samsung-usb.c index c40ea32..7a1ed90 100644 --- a/drivers/usb/phy/phy-samsung-usb.c +++ b/drivers/usb/phy/phy-samsung-usb.c @@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(samsung_usbphy_parse_dt); * Here 'on = true' would mean USB PHY block is isolated, hence * de-activated and vice-versa. */ -void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on) +void samsung_usbphy_set_isolation_4210(struct samsung_usbphy *sphy, bool on) { void __iomem *reg = NULL; u32 reg_val; @@ -84,32 +84,12 @@ void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on) return; } - switch (sphy->drv_data->cpu_type) { - case TYPE_S3C64XX: - /* - * Do nothing: We will add here once S3C64xx goes for DT support - */ - break; - case TYPE_EXYNOS4210: - /* - * Fall through since exynos4210 and exynos5250 have similar - * register architecture: two separate registers for host and - * device phy control with enable bit at position 0. - */ - case TYPE_EXYNOS5250: - if (sphy->phy_type == USB_PHY_TYPE_DEVICE) { - reg = sphy->pmuregs + - sphy->drv_data->devphy_reg_offset; - en_mask = sphy->drv_data->devphy_en_mask; - } else if (sphy->phy_type == USB_PHY_TYPE_HOST) { - reg = sphy->pmuregs + - sphy->drv_data->hostphy_reg_offset; - en_mask = sphy->drv_data->hostphy_en_mask; - } - break; - default: - dev_err(sphy->dev, "Invalid SoC type\n"); - return; + if (sphy->phy_type == USB_PHY_TYPE_DEVICE) { + reg = sphy->pmuregs + sphy->drv_data->devphy_reg_offset; + en_mask = sphy->drv_data->devphy_en_mask; + } else if (sphy->phy_type == USB_PHY_TYPE_HOST) { + reg = sphy->pmuregs + sphy->drv_data->hostphy_reg_offset; + en_mask = sphy->drv_data->hostphy_en_mask; } reg_val = readl(reg); @@ -121,7 +101,7 @@ void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on) writel(reg_val, reg); } -EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation); +EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation_4210); /* * Configure the mode of working of usb-phy here: HOST/DEVICE. diff --git a/drivers/usb/phy/phy-samsung-usb.h b/drivers/usb/phy/phy-samsung-usb.h index 0336f6b..5203784 100644 --- a/drivers/usb/phy/phy-samsung-usb.h +++ b/drivers/usb/phy/phy-samsung-usb.h @@ -271,6 +271,7 @@ struct samsung_usbphy_drvdata { u32 devphy_reg_offset; u32 hostphy_reg_offset; int (*rate_to_clksel)(struct samsung_usbphy *, unsigned long); + void (*set_isolation)(struct samsung_usbphy *, bool); }; /* @@ -323,7 +324,8 @@ static inline const struct samsung_usbphy_drvdata } extern int samsung_usbphy_parse_dt(struct samsung_usbphy *sphy); -extern void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on); +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); diff --git a/drivers/usb/phy/phy-samsung-usb2.c b/drivers/usb/phy/phy-samsung-usb2.c index 802e738..ae6da68 100644 --- a/drivers/usb/phy/phy-samsung-usb2.c +++ b/drivers/usb/phy/phy-samsung-usb2.c @@ -284,8 +284,8 @@ static int samsung_usb2phy_init(struct usb_phy *phy) /* Disable phy isolation */ if (sphy->plat && sphy->plat->pmu_isolation) sphy->plat->pmu_isolation(false); - else - samsung_usbphy_set_isolation(sphy, false); + 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); @@ -342,8 +342,8 @@ static void samsung_usb2phy_shutdown(struct usb_phy *phy) /* Enable phy isolation */ if (sphy->plat && sphy->plat->pmu_isolation) sphy->plat->pmu_isolation(true); - else - samsung_usbphy_set_isolation(sphy, true); + else if (sphy->drv_data->set_isolation) + sphy->drv_data->set_isolation(sphy, true); spin_unlock_irqrestore(&sphy->lock, flags); @@ -447,6 +447,7 @@ static const struct samsung_usbphy_drvdata usb2phy_s3c64xx = { .cpu_type = TYPE_S3C64XX, .devphy_en_mask = S3C64XX_USBPHY_ENABLE, .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx, + .set_isolation = NULL, /* TODO */ }; static const struct samsung_usbphy_drvdata usb2phy_exynos4 = { @@ -454,6 +455,7 @@ static const struct samsung_usbphy_drvdata usb2phy_exynos4 = { .devphy_en_mask = EXYNOS_USBPHY_ENABLE, .hostphy_en_mask = EXYNOS_USBPHY_ENABLE, .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx, + .set_isolation = samsung_usbphy_set_isolation_4210, }; static struct samsung_usbphy_drvdata usb2phy_exynos5 = { @@ -461,6 +463,7 @@ static struct samsung_usbphy_drvdata usb2phy_exynos5 = { .hostphy_en_mask = EXYNOS_USBPHY_ENABLE, .hostphy_reg_offset = EXYNOS_USBHOST_PHY_CTRL_OFFSET, .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12, + .set_isolation = samsung_usbphy_set_isolation_4210, }; #ifdef CONFIG_OF diff --git a/drivers/usb/phy/phy-samsung-usb3.c b/drivers/usb/phy/phy-samsung-usb3.c index 7845588..a4f4fa6 100644 --- a/drivers/usb/phy/phy-samsung-usb3.c +++ b/drivers/usb/phy/phy-samsung-usb3.c @@ -184,7 +184,8 @@ static int samsung_usb3phy_init(struct usb_phy *phy) samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE); /* Disable phy isolation */ - samsung_usbphy_set_isolation(sphy, false); + if (sphy->drv_data->set_isolation) + sphy->drv_data->set_isolation(sphy, false); /* Initialize usb phy registers */ samsung_exynos5_usb3phy_enable(sphy); @@ -221,7 +222,8 @@ static void samsung_usb3phy_shutdown(struct usb_phy *phy) samsung_exynos5_usb3phy_disable(sphy); /* Enable phy isolation */ - samsung_usbphy_set_isolation(sphy, true); + if (sphy->drv_data->set_isolation) + sphy->drv_data->set_isolation(sphy, true); spin_unlock_irqrestore(&sphy->lock, flags); @@ -311,6 +313,7 @@ static struct samsung_usbphy_drvdata usb3phy_exynos5 = { .cpu_type = TYPE_EXYNOS5250, .devphy_en_mask = EXYNOS_USBPHY_ENABLE, .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12, + .set_isolation = samsung_usbphy_set_isolation_4210, }; #ifdef CONFIG_OF