Received: by 10.192.165.148 with SMTP id m20csp4739844imm; Tue, 24 Apr 2018 07:41:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+xlZbd5R1zIHaJrs8H/Ihtl3e4XcE7qMCUuTn5cR+172MFwMOykQZAb5F3r4A3j8thpEJh X-Received: by 10.99.123.17 with SMTP id w17mr20440554pgc.8.1524580893835; Tue, 24 Apr 2018 07:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524580893; cv=none; d=google.com; s=arc-20160816; b=JWD4HMjCbzPjc5WQIkPEkfoHeaKLOzfOwIueUQGZdI3lLoOHq+yQBLXPjxxp8kt+Rp O/1QbK5m51WLteC01BLdesFHtFA8SPeqT7pmSX7OGGGp/VYoW9HAl31GrN5oQJKtKOf4 pk1sq7iRTC6558Psg/irm7GJpkQJjfSok0YSQ//yagyksxskWVnk5yWgqU/RjUp7OEts Y23pI8pYYd+XkFQRfmHBss2NDCET/RkHdXwTcI3PEXZDfnNJrPDk+a7a7mrozNQF8ZQa 1aHSWQPelBdvXLvP+lzdggplIFS3XR1pOeVwp+FUZDJCvAcwvsEbkZKUzi/k70Z8Nxgn KNyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=HaSRY2a0c3OLGC/4APThWiFFXgpd6gMrGSqdy26Xa/o=; b=ygayXKmTARuadrPBwm6iXgXqrgNy06oUiYWgYPfowJ+8n3iePS+ItwXFsrqiMS8wjt CiFq2w7ljajVDBExv1A2SlGuteltgOBEghj252qkxU4JUDApWGYRgU1mtuJE9fi39E2F ICeKrrA4LthHOZdHQ7w4oNWE+7Pf/ODphcrI0DEO+s/xHRDuWF4ZgU55zPL9gvsqDK8i FeTWHkdP5WjTOzIXkHyVaR17K87AAPvlmmeP5z58er5nMebvd8gl4kmyarhKmmHIPc1Z AtLuQ3MJgsi0sheoe1ewZRxMBOqwdK7O6xiprN/GkRUje6XFGQOuZxhMuQ+/7zaC6cXV NOiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QDIp2sAl; 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 sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7si324782pgt.200.2018.04.24.07.41.18; Tue, 24 Apr 2018 07:41:33 -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=@gmail.com header.s=20161025 header.b=QDIp2sAl; 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 sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752902AbeDXOi7 (ORCPT + 99 others); Tue, 24 Apr 2018 10:38:59 -0400 Received: from mail-lf0-f47.google.com ([209.85.215.47]:40065 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752769AbeDXOir (ORCPT ); Tue, 24 Apr 2018 10:38:47 -0400 Received: by mail-lf0-f47.google.com with SMTP id j16-v6so3440061lfb.7; Tue, 24 Apr 2018 07:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HaSRY2a0c3OLGC/4APThWiFFXgpd6gMrGSqdy26Xa/o=; b=QDIp2sAlzXDobb/Y/Rwr2XeGdwk4ZsLgJj8oJhdZUxeLXNO9tNx6GzsqPbrP/7ui30 AkeaqvtJpbQCeh53jLHsT9JwEkYwJ4Fq+/oYRpn7LfZzEZX8EyUA6KUNZ7Kni8Up0UxN w0Xn09fgjov+/S66TMsnQi2ILins/vbsvON5Zczkz+Ez3cDhkkq7OzisQcWK9mS5RUL4 ZDHZkBTg23SbiQOtEgsAPkFPhco95BzSgbcvFhHvCMXa20NOQANYjUQ2QN/ZH+joBnQo POv1lB6fxnlIlpdPqXwqZByFUUawE31aplRg7KaL1z/fu3rsxRN2wJqxgRfi3M3nFD8J 9Xow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=HaSRY2a0c3OLGC/4APThWiFFXgpd6gMrGSqdy26Xa/o=; b=Hatm5V7Hj50hN61tAR9HF4Bf5gipz/bvgMkcWCmOPUBXJ5ua0vu5ymYx0p/yjmfaBs Ay9+HiWRqOlLMARU8AKKcPLht0olNsV0tjvbCcIuToqCl4VnGHVfnGz5ztkXIq1NqSPo q1Ya5d6K0iQ/Zka1nyDquZv35MULwwccjHjaA58wq7cK5SelQSA4Y1Vjj8l5lxYmvjCS kU5sz/YYbBVT0gjDUXijePNVUFTk0zPXFtYoaFKLx4+2zpQWFNxrUYue0HTn2hioXzRd xG2AV2kf//gho/odeEpx22DZE48eZX65Mu7m6LLIGgCKcYSQWoV2EwLQY1BAsa2GfdTE n5xg== X-Gm-Message-State: ALQs6tDpMkijs1aewrE+FAHZdUWyDgEaErCcCTOxvqjBZzTGd67C7e91 xe83yOx3l1kB651yJfNF0qa1HpOI X-Received: by 2002:a19:d015:: with SMTP id h21-v6mr11362255lfg.124.1524580724689; Tue, 24 Apr 2018 07:38:44 -0700 (PDT) Received: from [192.168.1.145] (ppp109-252-91-130.pppoe.spdop.ru. [109.252.91.130]) by smtp.googlemail.com with ESMTPSA id o82sm559361lja.67.2018.04.24.07.38.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 07:38:43 -0700 (PDT) Subject: Re: [PATCH] ARM: tegra: fix ulpi regression on tegra20 To: Marcel Ziswiler , "marvin24@gmx.de" , Peter De Schrijver , Thierry Reding , Jon Hunter Cc: "linux-kernel@vger.kernel.org" , "robh+dt@kernel.org" , "jonathanh@nvidia.com" , "devicetree@vger.kernel.org" , "linux@armlinux.org.uk" , "thierry.reding@gmail.com" , "mark.rutland@arm.com" , "linux-arm-kernel@lists.infradead.org" , "linux-tegra@vger.kernel.org" References: <20180219151252.29289-1-marcel@ziswiler.com> <6600596.BijQW1iq1K@ax5200p> <4f2ac009-8618-4b4d-e137-a5fd4907a56f@gmail.com> <1524521136.4493.70.camel@toradex.com> From: Dmitry Osipenko Openpgp: preference=signencrypt Autocrypt: addr=digetx@gmail.com; prefer-encrypt=mutual; keydata= xsBNBFpX5TwBCADQhg+lBnTunWSPbP5I+rM9q6EKPm5fu2RbqyVAh/W3fRvLyghdb58Yrmjm KpDYUhBIZvAQoFLEL1IPAgJBtmPvemO1XUGPxfYNh/3BlcDFBAgERrI3BfA/6pk7SAFn8u84 p+J1TW4rrPYcusfs44abJrn8CH0GZKt2AZIsGbGQ79O2HHXKHr9V95ZEPWH5AR0UtL6wxg6o O56UNG3rIzSL5getRDQW3yCtjcqM44mz6GPhSE2sxNgqureAbnzvr4/93ndOHtQUXPzzTrYB z/WqLGhPdx5Ouzn0Q0kSVCQiqeExlcQ7i7aKRRrELz/5/IXbCo2O+53twlX8xOps9iMfABEB AAHNIkRtaXRyeSBPc2lwZW5rbyA8ZGlnZXR4QGdtYWlsLmNvbT7CwJQEEwEIAD4WIQSczHcO 3uc4K1eb3yvTNNaPsNRzvAUCWlflPAIbAwUJA8JnAAULCQ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fivDsjKIq7qQ c5eR+JJtyLEA0Jt4cQGhpzHtWB0yB3XxXzHVa4QUp00BNVWyiJ/t9JHT4S5mdyLfcKm7ddc9 Message-ID: Date: Tue, 24 Apr 2018 17:38:41 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1524521136.4493.70.camel@toradex.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marcel, On 24.04.2018 01:05, Marcel Ziswiler wrote: > Hi Dmitry > > On Fri, 2018-04-20 at 13:50 +0300, Dmitry Osipenko wrote: >> ... >> I managed to find CDEV clocks in TRM this time. > > And where exactly in which TRM? In all my attempts at finding anything > CDEV2 is just a pad group which includes the DAP_MCLK2 pad in question. That's the DEV2 clock you're talking about below. >> Seems assigning CDEV2 clock to >> "ulpi-link" was correct > > Sorry, but I do really not see how you can get to any such conclusion. > > Whatever that CDEV2 clock exactly is. Its offset 93 points towards the > CLK_RST_CONTROLLER_CLK_OUT_ENB_U_0 register which has CLK_ENB_DEV2_OUT > at bit position 29 reading "Enable clock to DEV2 pad". While the TRM > misses further documenting what exactly that DEV2 pad should be I guess > it may point towards our suspected DAP_MCLK2. So for some reason > besides PLL_P_OUT4 which is what that pad is actually muxed to also > some additional DEV2 pad clock needs enabling. In addition there would > be a CLK_RST_CONTROLLER_MISC_CLK_ENB_0 register where one could also > specify a DEV2_OSC_DIV_SEL but I would assume that one only applies if > the pad in question being muxed to OSC which is not the case at least > in all device trees I have looked at. > >> and both CDEV2 and PLL_P_OUT4 should be enabled, > > Agreed, basically the DAP_MCLK2 pad seems gated by an additional enable > called CLK_ENB_DEV2_OUT. > >> CDEV2 >> should gate the PLL_P_OUT4 that feeds USB HW and PLL_P_OUT4 should be >> always-enabled because it is enabled by init_table, but apparently it >> is getting >> disabled erroneously. > > At least that was the case back when I had trouble getting ULPI to work > on T20. Strangely latest -next right now does no longer seem to suffer > from that same issue even if my patch is reverted but as mentioned > before nobody stops the required PLL_P_OUT4 which is what is actually > driving DAP_MCLK2 to not be changed behind the scenes breaking the > whole thing again. > >> Marcel, could you please revert your patch, add >> "trace_event=clk_enable,clk_disable,clk_set_parent tp_printk" to >> kernels cmdline >> and post the log? > > Yes, the only difference in those traces is whether or not that non- > existent CDEV2 clock is enabled or not: > > [ 1.897521] clk_enable: cdev2_fixed > [ 1.901008] clk_enable: cdev2 > > I also do have an explanation why it kept working in my case. Probably > the boot ROM or U-Boot is already setting that bit. > >> It looks like there is some clk framework bug, > > My conclusion is that there should be a DAP_MCLK2 clock which is gated > by that CLK_ENB_DEV2_OUT but really outputs a T20 internal clock > according to its pin muxing which if set to OSC may be further divided > down by DEV2_OSC_DIV_SEL. Could be that DEV2_OSC_DIV_SEL is only relevant when DAP_MCLK2 is mux'ed to OSC. Maybe Peter could clarify everything. >> but just in case please also try >> to apply this patch: >> >> diff --git a/drivers/clk/tegra/clk-tegra-periph.c >> b/drivers/clk/tegra/clk-tegra-periph.c >> index 2acba2986bc6..407bd0c0ac2f 100644 >> --- a/drivers/clk/tegra/clk-tegra-periph.c >> +++ b/drivers/clk/tegra/clk-tegra-periph.c >> @@ -1024,7 +1024,7 @@ static void __init init_pllp(void __iomem >> *clk_base, void >> __iomem *pmc_base, >> if (dt_clk) { >> clk = >> tegra_clk_register_pll_out("pll_p_out4", >> "pll_p_out4_div", clk_base + >> PLLP_OUTB, >> - 17, 16, CLK_IGNORE_UNUSED | >> + 17, 16, CLK_IS_CRITICAL | >> CLK_SET_RATE_PARENT, 0, >> &PLLP_OUTB_lock); >> *dt_clk = clk; > > I did not have to do any such but maybe that would at least prevent any > further issues on PLL_P_OUT4. However I still believe this is kind of > wrong as PLL_P_OUT4 is what drives DAP_MCLK2 in its current muxing > which is connected to the ULPI transceivers REFCLK pin. > > BTW: That pin is usually to be driven at 24 MHz and not 26 MHz which > CDEV2 claims to be at. Pin is driven by the PLL_P_OUT4, which is set to 24 MHz via the init_table. The clock tree is invalid in that regards because Tegra's clock driver defines non-existent "cdev2_fixed" 26 MHz clock source and sets it as a parent for the "cdev2" clock, while "cdev2" should be a gate (and maybe divider?) for the real parent clock (PLL_P_OUT4 in our case). > What do you think? It looks to me that a clock signal coming from the mux'ed CDEV2 pin is routed to the DEV2 of CLK controller (which can gate it) and then it goes out to DAP_MCLK2. PLL_P_OUT4 ---> PINMUX_CDEV2 ---> CLK_DEV2 ---> DAP_MCLK2 But it also could be that CLK_ENB_DEV2_OUT is indeed some internal pinmux-related clock-gate. I think Peter should have a clue. Anyway the implementation details do not really matter for us, what matters is that PLL_P_OUT4 clk and DEV2 clk-gate must be enabled. Seems indeed ideally would be to have DAP_MCLK2 for the USB controller's "ulpi-link" clock and then DEV2 will be enable bit for the DAP_MCLK2. But also information about parent clock of the DAP_MCLK2 needs to be conducted to the clk driver via DT, that probably would require backward-incompatible change of the binding which is undesirable. One tolerable solution could be to remove fake "cdev2_fixed" clock in the driver and hardcode PLL_P_OUT4 for the parent of "cdev2". (Note that cdev1 also has a fake parent) index 0ee56dd04cec..4708653dedeb 100644 --- a/drivers/clk/tegra/clk-tegra20.c +++ b/drivers/clk/tegra/clk-tegra20.c @@ -838,8 +838,7 @@ static void __init tegra20_periph_clk_init(void) clks[TEGRA20_CLK_CDEV1] = clk; /* cdev2 */ - clk = clk_register_fixed_rate(NULL, "cdev2_fixed", NULL, 0, 26000000); - clk = tegra_clk_register_periph_gate("cdev2", "cdev2_fixed", 0, + clk = tegra_clk_register_periph_gate("cdev2", "pll_p_out4", 0, clk_base, 0, 93, periph_clk_enb_refcnt); clks[TEGRA20_CLK_CDEV2] = clk; Now the real problem is that PLL_P_OUT4 was getting disabled. We had CDEV2 clock in the DT for "ulpi-link" and PLL_P_OUT4 was permanently enabled (supposedly) by the Tegra's clock driver using init_table. Apparently PLL_P_OUT4 was disabled on SCLK re-parenting, as you mentioned in the commit description. This should be considered as a bug because one of two purposes (permanently enable and setup default clock rate) of the init_table is defeated. Could you please try to bisect to the point when erroneous PLL_P_OUT4 disable issue is fixed->broken? It is quite important to know what commit changed the behaviour. If it was some common clk issue that got fixed - that should be a good case for us, if it was some unrelated change that obscured the issue - that's not good and we should go back and fix the real bug.