From patchwork Tue Mar 26 14:53:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2337841 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 04F7E3FC54 for ; Tue, 26 Mar 2013 14:53:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934576Ab3CZOxq (ORCPT ); Tue, 26 Mar 2013 10:53:46 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:43202 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933632Ab3CZOxp (ORCPT ); Tue, 26 Mar 2013 10:53:45 -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:44 +0900 (KST) X-AuditID: cbfee61a-b7fa86d0000045ae-10-5151b6780a6e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 82.74.17838.876B1515; Tue, 26 Mar 2013 23:53:44 +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:44 +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 5/6] usb: phy: samsung: Pass enable/disable callbacks through driver data Date: Tue, 26 Mar 2013 15:53:14 +0100 Message-id: <1364309595-16102-6-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+t9jAd2KbYGBBstfiFkcvF9v0XblILtF 74KrbBZnm96wW8w4v4/JYtGyVmaLtUfusluc39LJZLF+xmsWB06Pvi2rGD2O39jO5PF5k1wA cxSXTUpqTmZZapG+XQJXxrxlZ5kK7qpVLL/xnr2BcZpiFyMnh4SAiUTbxtPMELaYxIV769m6 GLk4hAQWMUos/9PMAuF0MUn8v/KNDaSKTUBN4nPDIzBbREBV4nPbAnaQImaBs4wSjR1HgTo4 OIQFoiXuzVYAqWEBqtm0r4MFxOYVcJI4MHElE8Q2eYmn9/vA5nAKOEtcn7SEHaRVCKhmX0v5 BEbeBYwMqxhFUwuSC4qT0nMN9YoTc4tL89L1kvNzNzGCQ+qZ1A7GlQ0WhxgFOBiVeHg3BAcE CrEmlhVX5h5ilOBgVhLhFdwYGCjEm5JYWZValB9fVJqTWnyIUZqDRUmc90CrdaCQQHpiSWp2 ampBahFMlomDU6qBUfFq18q41izdiIrG174h3y58tVDjfiZWXp/fHLZ8tpuJo/sTQ9cggU+T M5bpVz2x+frrbZvGRrunKZpuNrb/o23OHr7u3vpHbjlL09zXsy9IcOUkd+ne+/3uzbcJAjJ8 ew5mf1/J6VSuzVJ5gNvQMPsOR0/64dZ1uhsdm+1dPE/FbXVrvJCoxFKckWioxVxUnAgA8Z0A QCUCAAA= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org To remove unnecessary if statements, this patch introduces phy_enable and phy_disable callbacks in driver data structure that implement SoC-specific PHY initialization and deinitialization. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park --- drivers/usb/phy/phy-samsung-usb.h | 2 ++ drivers/usb/phy/phy-samsung-usb2.c | 16 ++++++++-------- drivers/usb/phy/phy-samsung-usb3.c | 10 +++++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/usb/phy/phy-samsung-usb.h b/drivers/usb/phy/phy-samsung-usb.h index 5203784..31e2ec3 100644 --- a/drivers/usb/phy/phy-samsung-usb.h +++ b/drivers/usb/phy/phy-samsung-usb.h @@ -272,6 +272,8 @@ struct samsung_usbphy_drvdata { u32 hostphy_reg_offset; int (*rate_to_clksel)(struct samsung_usbphy *, unsigned long); void (*set_isolation)(struct samsung_usbphy *, bool); + void (*phy_enable)(struct samsung_usbphy *); + void (*phy_disable)(struct samsung_usbphy *); }; /* diff --git a/drivers/usb/phy/phy-samsung-usb2.c b/drivers/usb/phy/phy-samsung-usb2.c index ae6da68..b81347b 100644 --- a/drivers/usb/phy/phy-samsung-usb2.c +++ b/drivers/usb/phy/phy-samsung-usb2.c @@ -291,10 +291,7 @@ static int samsung_usb2phy_init(struct usb_phy *phy) samsung_usbphy_cfg_sel(sphy); /* Initialize usb phy registers */ - if (sphy->drv_data->cpu_type == TYPE_EXYNOS5250) - samsung_exynos5_usb2phy_enable(sphy); - else - samsung_usb2phy_enable(sphy); + sphy->drv_data->phy_enable(sphy); spin_unlock_irqrestore(&sphy->lock, flags); @@ -334,10 +331,7 @@ static void samsung_usb2phy_shutdown(struct usb_phy *phy) } /* De-initialize usb phy registers */ - if (sphy->drv_data->cpu_type == TYPE_EXYNOS5250) - samsung_exynos5_usb2phy_disable(sphy); - else - samsung_usb2phy_disable(sphy); + sphy->drv_data->phy_disable(sphy); /* Enable phy isolation */ if (sphy->plat && sphy->plat->pmu_isolation) @@ -448,6 +442,8 @@ static const struct samsung_usbphy_drvdata usb2phy_s3c64xx = { .devphy_en_mask = S3C64XX_USBPHY_ENABLE, .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx, .set_isolation = NULL, /* TODO */ + .phy_enable = samsung_usb2phy_enable, + .phy_disable = samsung_usb2phy_disable, }; static const struct samsung_usbphy_drvdata usb2phy_exynos4 = { @@ -456,6 +452,8 @@ static const struct samsung_usbphy_drvdata usb2phy_exynos4 = { .hostphy_en_mask = EXYNOS_USBPHY_ENABLE, .rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx, .set_isolation = samsung_usbphy_set_isolation_4210, + .phy_enable = samsung_usb2phy_enable, + .phy_disable = samsung_usb2phy_disable, }; static struct samsung_usbphy_drvdata usb2phy_exynos5 = { @@ -464,6 +462,8 @@ static struct samsung_usbphy_drvdata usb2phy_exynos5 = { .hostphy_reg_offset = EXYNOS_USBHOST_PHY_CTRL_OFFSET, .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12, .set_isolation = samsung_usbphy_set_isolation_4210, + .phy_enable = samsung_exynos5_usb2phy_enable, + .phy_disable = samsung_exynos5_usb2phy_disable, }; #ifdef CONFIG_OF diff --git a/drivers/usb/phy/phy-samsung-usb3.c b/drivers/usb/phy/phy-samsung-usb3.c index a4f4fa6..a7242e6 100644 --- a/drivers/usb/phy/phy-samsung-usb3.c +++ b/drivers/usb/phy/phy-samsung-usb3.c @@ -65,7 +65,7 @@ static u32 samsung_usb3phy_set_refclk(struct samsung_usbphy *sphy) return reg; } -static int samsung_exynos5_usb3phy_enable(struct samsung_usbphy *sphy) +static void samsung_exynos5_usb3phy_enable(struct samsung_usbphy *sphy) { void __iomem *regs = sphy->regs; u32 phyparam0; @@ -133,8 +133,6 @@ static int samsung_exynos5_usb3phy_enable(struct samsung_usbphy *sphy) phyclkrst &= ~(PHYCLKRST_PORTRESET); writel(phyclkrst, regs + EXYNOS5_DRD_PHYCLKRST); - - return 0; } static void samsung_exynos5_usb3phy_disable(struct samsung_usbphy *sphy) @@ -188,7 +186,7 @@ static int samsung_usb3phy_init(struct usb_phy *phy) sphy->drv_data->set_isolation(sphy, false); /* Initialize usb phy registers */ - samsung_exynos5_usb3phy_enable(sphy); + sphy->drv_data->phy_enable(sphy); spin_unlock_irqrestore(&sphy->lock, flags); @@ -219,7 +217,7 @@ static void samsung_usb3phy_shutdown(struct usb_phy *phy) samsung_usbphy_set_type(&sphy->phy, USB_PHY_TYPE_DEVICE); /* De-initialize usb phy registers */ - samsung_exynos5_usb3phy_disable(sphy); + sphy->drv_data->phy_disable(sphy); /* Enable phy isolation */ if (sphy->drv_data->set_isolation) @@ -314,6 +312,8 @@ static struct samsung_usbphy_drvdata usb3phy_exynos5 = { .devphy_en_mask = EXYNOS_USBPHY_ENABLE, .rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12, .set_isolation = samsung_usbphy_set_isolation_4210, + .phy_enable = samsung_exynos5_usb3phy_enable, + .phy_disable = samsung_exynos5_usb3phy_disable, }; #ifdef CONFIG_OF