From patchwork Sun Jun 26 07:28:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 70873 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp555838qgy; Sun, 26 Jun 2016 00:33:23 -0700 (PDT) X-Received: by 10.66.249.161 with SMTP id yv1mr22402310pac.39.1466926403053; Sun, 26 Jun 2016 00:33:23 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fb10si12382531pab.212.2016.06.26.00.33.22; Sun, 26 Jun 2016 00:33:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752326AbcFZHdO (ORCPT + 30 others); Sun, 26 Jun 2016 03:33:14 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:35689 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752071AbcFZH3F (ORCPT ); Sun, 26 Jun 2016 03:29:05 -0400 Received: by mail-pa0-f52.google.com with SMTP id hl6so49474182pac.2 for ; Sun, 26 Jun 2016 00:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hVdFe9/csY39mVwFc+1RcTCpyVKSEHGmwSzv+pdc1N8=; b=eh0mzNqAAWhyf9e7U8Wk04LBGH4mXQoPUXA4QjEPvnyFxjDGy3Qulh+9GfIvSD9bVF UaOo/f7hnZ3smS4EbMEUho/aO5eFCcbvpm6rHbsntEKMzajOHWZRdWTTezkCCQx+K7vg fDt0shh/thci6jeGnJ8S3/MxBCew1RnQpjcdU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hVdFe9/csY39mVwFc+1RcTCpyVKSEHGmwSzv+pdc1N8=; b=ZGUyy1wizPMmrUFcnBbSNWiIqi/xhhMVHq+L3QLDYNeenFNSfP/27uSCXRGXJilJoK 4gY9vS2oUNewjLBhIxFYvruMC2vmhQZeWUnm9dVwHPK9WRmGcWVAjg8No/Q2kqEbPAYW xkim2buB8ok/hIeAVLJ9Mf+bG4R0WqXtVOgsBqlTtlSD3Aohm4Az0lgb/Ggekw/fTM4f 5kJmpn5uclL3DSfhiHPL9zS7WtuOzsDKAU+dNcBP2LkLXFqB8OwIZWCx6FGNa28X8zHw P4bCfVIUgbqDZtxR8JTgd3Jh0pLMJsxhhpUDRT1xiguMxomNgFqO7W0r1S7DQU+5pzlc xUyw== X-Gm-Message-State: ALyK8tLBMxwn9rHyAQBpQNcCTUVVWtjN9y4oiRkk0+SafogDWq8/GiJXfyBKmD6J4KdkhbMM X-Received: by 10.66.80.3 with SMTP id n3mr22850735pax.92.1466926145003; Sun, 26 Jun 2016 00:29:05 -0700 (PDT) Received: from localhost.localdomain (ip68-101-172-78.sd.sd.cox.net. [68.101.172.78]) by smtp.gmail.com with ESMTPSA id f138sm3790495pfa.17.2016.06.26.00.29.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Jun 2016 00:29:04 -0700 (PDT) From: Stephen Boyd To: linux-usb@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , Bjorn Andersson , Neil Armstrong , Arnd Bergmann , Felipe Balbi , Peter Chen , Greg Kroah-Hartman Subject: [PATCH 18/21] usb: chipidea: msm: Add reset controller for PHY POR bit Date: Sun, 26 Jun 2016 00:28:35 -0700 Message-Id: <20160626072838.28082-19-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d In-Reply-To: <20160626072838.28082-1-stephen.boyd@linaro.org> References: <20160626072838.28082-1-stephen.boyd@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The MSM chipidea wrapper has two bits that are used to reset the first or second phy. Add support for these bits via the reset controller framework, so that phy drivers can reset their hardware at the right time during initialization. Cc: Peter Chen Cc: Greg Kroah-Hartman Signed-off-by: Stephen Boyd --- drivers/usb/chipidea/ci_hdrc_msm.c | 43 +++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) -- 2.9.0.rc2.8.ga28705d diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index fb4340f02c16..7d191928e55b 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -14,14 +14,17 @@ #include #include #include +#include #include #include #include "ci.h" #define HS_PHY_AHB_MODE 0x0098 +#define HS_PHY_CTRL 0x0240 #define HS_PHY_SEC_CTRL 0x0278 # define HS_PHY_DIG_CLAMP_N BIT(16) +# define HS_PHY_POR_ASSERT BIT(0) #define HS_PHY_GENCONFIG 0x009c # define HS_PHY_TXFIFO_IDLE_FORCE_DIS BIT(4) @@ -38,11 +41,38 @@ struct ci_hdrc_msm { struct clk *iface_clk; struct extcon_dev *vbus_edev; struct ci_hdrc_platform_data pdata; + struct reset_controller_dev rcdev; bool secondary_phy; bool hsic; void __iomem *base; }; +static int +ci_hdrc_msm_por_reset(struct reset_controller_dev *r, unsigned long id) +{ + struct ci_hdrc_msm *ci_msm = container_of(r, struct ci_hdrc_msm, rcdev); + void __iomem *addr = ci_msm->base; + u32 val; + + if (id) + addr += HS_PHY_SEC_CTRL; + else + addr += HS_PHY_CTRL; + + val = readl_relaxed(addr); + val |= HS_PHY_POR_ASSERT; + writel_relaxed(val, addr); + udelay(12); + val &= ~HS_PHY_POR_ASSERT; + writel(val, addr); + + return 0; +} + +static const struct reset_control_ops ci_hdrc_msm_reset_ops = { + .reset = ci_hdrc_msm_por_reset, +}; + static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) { struct device *dev = ci->dev->parent; @@ -176,13 +206,21 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) ci->vbus_edev = NULL; } + ci->rcdev.owner = THIS_MODULE; + ci->rcdev.ops = &ci_hdrc_msm_reset_ops; + ci->rcdev.of_node = pdev->dev.of_node; + ci->rcdev.nr_resets = 2; + ret = reset_controller_register(&ci->rcdev); + if (ret) + return ret; + reset_control_assert(reset); usleep_range(10000, 12000); reset_control_deassert(reset); ret = clk_prepare_enable(ci->core_clk); if (ret) - return ret; + goto err_core; ret = clk_prepare_enable(ci->iface_clk); if (ret) @@ -220,6 +258,8 @@ err_mux: clk_disable_unprepare(ci->iface_clk); err_iface: clk_disable_unprepare(ci->core_clk); +err_core: + reset_controller_unregister(&ci->rcdev); return ret; } @@ -232,6 +272,7 @@ static int ci_hdrc_msm_remove(struct platform_device *pdev) ci_hdrc_remove_device(ci->ci); clk_disable_unprepare(ci->iface_clk); clk_disable_unprepare(ci->core_clk); + reset_controller_unregister(&ci->rcdev); return 0; }