From patchwork Wed Jun 29 19:28:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 71208 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp22315qgy; Wed, 29 Jun 2016 12:30:35 -0700 (PDT) X-Received: by 10.98.152.210 with SMTP id d79mr14589101pfk.2.1467228635668; Wed, 29 Jun 2016 12:30:35 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id h9si5673642pap.227.2016.06.29.12.30.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jun 2016 12:30:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bILAw-0002Sz-EI; Wed, 29 Jun 2016 19:29:30 +0000 Received: from mail-pf0-x230.google.com ([2607:f8b0:400e:c00::230]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bILAs-0002SL-O7 for linux-arm-kernel@lists.infradead.org; Wed, 29 Jun 2016 19:29:27 +0000 Received: by mail-pf0-x230.google.com with SMTP id t190so21048116pfb.3 for ; Wed, 29 Jun 2016 12:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:content-transfer-encoding:to:from:in-reply-to:cc :references:message-id:user-agent:subject:date; bh=bXkWPtD2lZuv8PNJA81weRmYjI1fxBFcHhwLfOEnvWc=; b=ZXsxokedzCj53FwmrL6jE1uytTgy46FxzWICGYfBmFoRK3lmas7e7hHbkAvqs57M0i yHY5bABqv8WchicXXt7luz3nm2KX02yhebOjFsbwxNqAycQURlegk+RJDyULCsIM0PXN Yhmqy+gBkwWLQQq0MGRiyxpEKaH6V3uHwne+I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:content-transfer-encoding:to:from :in-reply-to:cc:references:message-id:user-agent:subject:date; bh=bXkWPtD2lZuv8PNJA81weRmYjI1fxBFcHhwLfOEnvWc=; b=MJsaSFV4LZVnI76XCx6JIGCOOEveWt5tmkBNwuZvrDcEcVWnbWNu5Hr9dR4IyVLKAh 56lRTRN0HAj//MsAF3DcGr2fRxwnCYmZqRHqTtwBTTkLmfsC1G5qm6NNwfgiM50PMn7Q p6b9pEvVHXPzV/ovAKLXd6tQWvhjZpXfxmn1O43E1W7jZFWxWuoDzfqGiZkmpmaDzZMy RQA+ovsOv5oni7N8wtHRrRMBkB2yJ56qkvig+XNeIR/vi4FJqfYZeiyjZ0EhCo0leZpI lv1P7m2cHZurBXXq/uXaf0az1B6/yWPHJerd8+Ctlf6EOCOkPB0FzpROLw3JT0QfHARy N1xQ== X-Gm-Message-State: ALyK8tKPhM/u6DsDZsu6gaLRQN+ki+v/R9HPOYCWJmWENHXAUlwI8GTANesCiboGnCy9efMB X-Received: by 10.98.205.79 with SMTP id o76mr14412906pfg.37.1467228544990; Wed, 29 Jun 2016 12:29:04 -0700 (PDT) Received: from localhost (pat_11.qualcomm.com. [192.35.156.11]) by smtp.gmail.com with ESMTPSA id 144sm7807776pfu.83.2016.06.29.12.29.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jun 2016 12:29:04 -0700 (PDT) MIME-Version: 1.0 To: Peter Chen , From: Stephen Boyd In-Reply-To: <20160629080852.GJ25236@shlinux2> References: <20160626072838.28082-1-stephen.boyd@linaro.org> <20160626072838.28082-16-stephen.boyd@linaro.org> <20160629080852.GJ25236@shlinux2> Message-ID: <146722853892.16253.6137643683844696922@sboyd-linaro> User-Agent: alot/0.3.7 Subject: Re: [PATCH 15/21] usb: chipidea: msm: Mux over secondary phy at the right time Date: Wed, 29 Jun 2016 12:28:58 -0700 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160629_122926_984086_498238AC X-CRM114-Status: GOOD ( 24.54 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c00:0:0:0:230 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Felipe Balbi , Arnd Bergmann , Neil Armstrong , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Peter Chen , Greg Kroah-Hartman , Andy Gross , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Quoting Peter Chen (2016-06-29 01:08:52) > On Sun, Jun 26, 2016 at 12:28:32AM -0700, Stephen Boyd wrote: > > We need to pick the correct phy at runtime based on how the SoC > > has been wired onto the board. If the secondary phy is used, take > > it out of reset and mux over to it by writing into the TCSR > > register. Make sure to do this on reset too, because this > > register is reset to the default value (primary phy) after the > > RESET bit is set in USBCMD. > > > > I am curious when you need the secondary phy? > > > Cc: Peter Chen > > Cc: Greg Kroah-Hartman > > Signed-off-by: Stephen Boyd > > --- > > drivers/usb/chipidea/ci_hdrc_msm.c | 78 +++++++++++++++++++++++++++++++++++--- > > 1 file changed, 73 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c > > index 40249b0e3e93..df0f8b31db4f 100644 > > --- a/drivers/usb/chipidea/ci_hdrc_msm.c > > +++ b/drivers/usb/chipidea/ci_hdrc_msm.c > > @@ -8,30 +8,40 @@ > > #include > > #include > > #include > > -#include > > #include > > #include > > #include > > +#include > > +#include > > +#include > > > > #include "ci.h" > > > > #define HS_PHY_AHB_MODE 0x0098 > > +#define HS_PHY_SEC_CTRL 0x0278 > > +# define HS_PHY_DIG_CLAMP_N BIT(16) > > > > One space at the beginning, and keep alignment. > > > struct ci_hdrc_msm { > > struct platform_device *ci; > > struct clk *core_clk; > > struct clk *iface_clk; > > + bool secondary_phy; > > + void __iomem *base; > > }; > > > > static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) > > { > > - struct device *dev = ci->gadget.dev.parent; > > + struct device *dev = ci->dev->parent; > > + struct ci_hdrc_msm *msm_ci = dev_get_drvdata(dev); > > > > switch (event) { > > case CI_HDRC_CONTROLLER_RESET_EVENT: > > dev_dbg(dev, "CI_HDRC_CONTROLLER_RESET_EVENT received\n"); > > /* use AHB transactor, allow posted data writes */ > > hw_write_id_reg(ci, HS_PHY_AHB_MODE, 0xffffffff, 0x8); > > + if (msm_ci->secondary_phy) > > + hw_write_id_reg(ci, HS_PHY_SEC_CTRL, HS_PHY_DIG_CLAMP_N, > > + HS_PHY_DIG_CLAMP_N); > > break; > > default: > > dev_dbg(dev, "unknown ci_hdrc event\n"); > > @@ -49,12 +59,58 @@ static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = { > > .notify_event = ci_hdrc_msm_notify_event, > > }; > > > > +static int ci_hdrc_msm_mux_phy(struct ci_hdrc_msm *ci, > > + struct platform_device *pdev) > > +{ > > + struct regmap *regmap; > > + struct device_node *syscon; > > + struct device *dev = &pdev->dev; > > + u32 off, val; > > + int ret; > > + > > + syscon = of_parse_phandle(dev->of_node, "phy-select", 0); > > + if (!syscon) > > + return 0; > > + > > + regmap = syscon_node_to_regmap(syscon); > > + if (IS_ERR(regmap)) > > + return PTR_ERR(regmap); > > + > > + ret = of_property_read_u32_index(dev->of_node, "phy-select", 1, &off); > > + if (ret < 0) { > > + dev_err(dev, "no offset in syscon\n"); > > + return -EINVAL; > > + } > > + > > + ret = of_property_read_u32_index(dev->of_node, "phy-select", 2, &val); > > + if (ret < 0) { > > + dev_err(dev, "no value in syscon\n"); > > + return -EINVAL; > > + } > > + > > + ret = regmap_write(regmap, off, val); > > + if (ret) > > + return ret; > > + > > + ci->secondary_phy = !!val; > > + if (ci->secondary_phy) { > > + val = readl_relaxed(ci->base + HS_PHY_SEC_CTRL); > > + val |= HS_PHY_DIG_CLAMP_N; > > + writel_relaxed(val, ci->base + HS_PHY_SEC_CTRL); > > + } > > + > > + return 0; > > +} > > + > > static int ci_hdrc_msm_probe(struct platform_device *pdev) > > { > > struct ci_hdrc_msm *ci; > > struct platform_device *plat_ci; > > struct clk *clk; > > struct reset_control *reset; > > + struct resource *res; > > + void __iomem *base; > > + resource_size_t size; > > int ret; > > > > dev_dbg(&pdev->dev, "ci_hdrc_msm_probe\n"); > > @@ -76,6 +132,15 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) > > if (IS_ERR(clk)) > > return PTR_ERR(clk); > > > > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > + if (!res) > > + return -ENODEV; > > + > > + size = resource_size(res); > > + ci->base = base = devm_ioremap(&pdev->dev, res->start, size); > > + if (!base) > > + return -ENOMEM; > > + > > The core will do the ioremap too, you can't remap io address two times. You can ioremap an address twice, but it's not a great solution. On ARM, at least, we detect the double mapping and return the same virtual address the second time. > The offset larger than 0x200 is vendor specific, you can map it as > the second io region. Ok. That would mean we need to adjust the binding then to have to reg properties? Or we can limit the size of the resource in the core and the size of the resource here can be bumped up by 0x200. So DT still says one resource for the entire ci address space but we don't map anything more than what we use. Something like this? ---8<---- _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index 4c70fa6fdc34..1121cf3e3fdc 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -190,8 +190,9 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) if (!res) return -ENODEV; - size = resource_size(res); - ci->base = base = devm_ioremap(&pdev->dev, res->start, size); + res->start += 0x200; + res->end -= 0x200; + ci->base = base = devm_ioremap_resource(&pdev->dev, res); if (!base) return -ENOMEM; diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 298029a9ffce..8f5782913b11 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -887,6 +887,8 @@ static int ci_hdrc_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (resource_size(res) > 0x200) + res->end = res->start + 0x200; base = devm_ioremap_resource(dev, res); if (IS_ERR(base)) return PTR_ERR(base);