From patchwork Mon Jul 29 07:04:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ivan T. Ivanov" X-Patchwork-Id: 2834828 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C47CEC0319 for ; Mon, 29 Jul 2013 07:06:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67AE4201FB for ; Mon, 29 Jul 2013 07:06:07 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E5CB5201EE for ; Mon, 29 Jul 2013 07:06:05 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V3hWu-0006T9-2A; Mon, 29 Jul 2013 07:06:04 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V3hWr-0001lr-OW; Mon, 29 Jul 2013 07:06:01 +0000 Received: from ns.mm-sol.com ([212.124.72.66] helo=extserv.mm-sol.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V3hWn-0001jo-CY for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2013 07:05:59 +0000 Received: from iivanov-dev.int.mm-sol.com (unknown [172.18.0.3]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 907C7C68B; Mon, 29 Jul 2013 10:05:31 +0300 (EEST) From: "Ivan T. Ivanov" To: balbi@ti.com, gregkh@linuxfoundation.org Subject: [PATCH v2 1/6] usb: phy: msm: Move mach depndend code to platform data Date: Mon, 29 Jul 2013 10:04:19 +0300 Message-Id: <1375081464-14206-2-git-send-email-iivanov@mm-sol.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1375081464-14206-1-git-send-email-iivanov@mm-sol.com> References: <1375081464-14206-1-git-send-email-iivanov@mm-sol.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130729_030557_767753_CE90B1E3 X-CRM114-Status: GOOD ( 19.07 ) X-Spam-Score: -3.4 (---) Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Bryan Huntsman , "Ivan T. Ivanov" , Daniel Walker , David Brown , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 From: "Ivan T. Ivanov" This patch fix compilation error and is an intermediate step before the addition of DeviceTree support for newer targets. Fix suggested here: https://lkml.org/lkml/2013/6/19/381 Cc: David Brown Cc: Daniel Walker Cc: Bryan Huntsman Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: linux-usb@vger.kernel.org Signed-off-by: Ivan T. Ivanov Acked-by: David Brown --- arch/arm/mach-msm/board-msm7x30.c | 35 +++++++++++++++++++++++ arch/arm/mach-msm/board-qsd8x50.c | 35 +++++++++++++++++++++++ drivers/usb/phy/phy-msm-usb.c | 55 ++++++++++--------------------------- include/linux/usb/msm_hsusb.h | 3 ++ 4 files changed, 87 insertions(+), 41 deletions(-) diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c index db3d8c0..6b35953 100644 --- a/arch/arm/mach-msm/board-msm7x30.c +++ b/arch/arm/mach-msm/board-msm7x30.c @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -61,10 +62,44 @@ static int hsusb_phy_init_seq[] = { -1 }; +static int hsusb_link_clk_reset(struct clk *link_clk, bool assert) +{ + int ret; + + if (assert) { + ret = clk_reset(link_clk, CLK_RESET_ASSERT); + if (ret) + pr_err("usb hs_clk assert failed\n"); + } else { + ret = clk_reset(link_clk, CLK_RESET_DEASSERT); + if (ret) + pr_err("usb hs_clk deassert failed\n"); + } + return ret; +} + +static int hsusb_phy_clk_reset(struct clk *phy_clk) +{ + int ret; + + ret = clk_reset(phy_clk, CLK_RESET_ASSERT); + if (ret) { + pr_err("usb phy clk assert failed\n"); + return ret; + } + usleep_range(10000, 12000); + ret = clk_reset(phy_clk, CLK_RESET_DEASSERT); + if (ret) + pr_err("usb phy clk deassert failed\n"); + return ret; +} + static struct msm_otg_platform_data msm_otg_pdata = { .phy_init_seq = hsusb_phy_init_seq, .mode = USB_PERIPHERAL, .otg_control = OTG_PHY_CONTROL, + .link_clk_reset = hsusb_link_clk_reset, + .phy_clk_reset = hsusb_phy_clk_reset, }; struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS] = { diff --git a/arch/arm/mach-msm/board-qsd8x50.c b/arch/arm/mach-msm/board-qsd8x50.c index f14a73d..eb013f7 100644 --- a/arch/arm/mach-msm/board-qsd8x50.c +++ b/arch/arm/mach-msm/board-qsd8x50.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "devices.h" @@ -82,10 +83,44 @@ static int hsusb_phy_init_seq[] = { -1 }; +static int hsusb_link_clk_reset(struct clk *link_clk, bool assert) +{ + int ret; + + if (assert) { + ret = clk_reset(link_clk, CLK_RESET_ASSERT); + if (ret) + pr_err("usb hs_clk assert failed\n"); + } else { + ret = clk_reset(link_clk, CLK_RESET_DEASSERT); + if (ret) + pr_err("usb hs_clk deassert failed\n"); + } + return ret; +} + +static int hsusb_phy_clk_reset(struct clk *phy_clk) +{ + int ret; + + ret = clk_reset(phy_clk, CLK_RESET_ASSERT); + if (ret) { + pr_err("usb phy clk assert failed\n"); + return ret; + } + usleep_range(10000, 12000); + ret = clk_reset(phy_clk, CLK_RESET_DEASSERT); + if (ret) + pr_err("usb phy clk deassert failed\n"); + return ret; +} + static struct msm_otg_platform_data msm_otg_pdata = { .phy_init_seq = hsusb_phy_init_seq, .mode = USB_PERIPHERAL, .otg_control = OTG_PHY_CONTROL, + .link_clk_reset = hsusb_link_clk_reset, + .phy_clk_reset = hsusb_phy_clk_reset, }; static struct platform_device *devices[] __initdata = { diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index d08f334..7b74b26 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -40,8 +40,6 @@ #include #include -#include - #define MSM_USB_BASE (motg->regs) #define DRIVER_NAME "msm_otg" @@ -306,51 +304,20 @@ static void ulpi_init(struct msm_otg *motg) } } -static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert) -{ - int ret; - - if (assert) { - ret = clk_reset(motg->clk, CLK_RESET_ASSERT); - if (ret) - dev_err(motg->phy.dev, "usb hs_clk assert failed\n"); - } else { - ret = clk_reset(motg->clk, CLK_RESET_DEASSERT); - if (ret) - dev_err(motg->phy.dev, "usb hs_clk deassert failed\n"); - } - return ret; -} - -static int msm_otg_phy_clk_reset(struct msm_otg *motg) -{ - int ret; - - ret = clk_reset(motg->phy_reset_clk, CLK_RESET_ASSERT); - if (ret) { - dev_err(motg->phy.dev, "usb phy clk assert failed\n"); - return ret; - } - usleep_range(10000, 12000); - ret = clk_reset(motg->phy_reset_clk, CLK_RESET_DEASSERT); - if (ret) - dev_err(motg->phy.dev, "usb phy clk deassert failed\n"); - return ret; -} - static int msm_otg_phy_reset(struct msm_otg *motg) { + struct msm_otg_platform_data *pdata = motg->pdata; u32 val; int ret; int retries; - ret = msm_otg_link_clk_reset(motg, 1); + ret = pdata->link_clk_reset(motg->clk, true); if (ret) return ret; - ret = msm_otg_phy_clk_reset(motg); + ret = pdata->phy_clk_reset(motg->phy_reset_clk); if (ret) return ret; - ret = msm_otg_link_clk_reset(motg, 0); + ret = pdata->link_clk_reset(motg->clk, false); if (ret) return ret; @@ -362,7 +329,7 @@ static int msm_otg_phy_reset(struct msm_otg *motg) ULPI_CLR(ULPI_FUNC_CTRL)); if (!ret) break; - ret = msm_otg_phy_clk_reset(motg); + ret = pdata->phy_clk_reset(motg->phy_reset_clk); if (ret) return ret; } @@ -370,7 +337,7 @@ static int msm_otg_phy_reset(struct msm_otg *motg) return -ETIMEDOUT; /* This reset calibrates the phy, if the above write succeeded */ - ret = msm_otg_phy_clk_reset(motg); + ret = pdata->phy_clk_reset(motg->phy_reset_clk); if (ret) return ret; @@ -378,7 +345,7 @@ static int msm_otg_phy_reset(struct msm_otg *motg) ret = ulpi_read(&motg->phy, ULPI_DEBUG); if (ret != -ETIMEDOUT) break; - ret = msm_otg_phy_clk_reset(motg); + ret = pdata->phy_clk_reset(motg->phy_reset_clk); if (ret) return ret; } @@ -1414,16 +1381,22 @@ static void msm_otg_debugfs_cleanup(void) static int __init msm_otg_probe(struct platform_device *pdev) { int ret = 0; + struct msm_otg_platform_data *pdata = pdev->dev.platform_data; struct resource *res; struct msm_otg *motg; struct usb_phy *phy; dev_info(&pdev->dev, "msm_otg probe\n"); - if (!pdev->dev.platform_data) { + if (!pdata) { dev_err(&pdev->dev, "No platform data given. Bailing out\n"); return -ENODEV; } + if (!pdata->phy_clk_reset || !pdata->link_clk_reset) { + dev_err(&pdev->dev, "No phy or link clock reset methods\n"); + return -ENODEV; + } + motg = kzalloc(sizeof(struct msm_otg), GFP_KERNEL); if (!motg) { dev_err(&pdev->dev, "unable to allocate msm_otg\n"); diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h index 22a396c..3275483 100644 --- a/include/linux/usb/msm_hsusb.h +++ b/include/linux/usb/msm_hsusb.h @@ -20,6 +20,7 @@ #include #include +#include /** * Supported USB modes @@ -135,6 +136,8 @@ struct msm_otg_platform_data { enum msm_usb_phy_type phy_type; void (*setup_gpio)(enum usb_otg_state state); char *pclk_src_name; + int (*link_clk_reset)(struct clk *link_clk, bool assert); + int (*phy_clk_reset)(struct clk *phy_clk); }; /**