From patchwork Thu Apr 11 13:55:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10896059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C52761708 for ; Thu, 11 Apr 2019 13:56:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A646A286B0 for ; Thu, 11 Apr 2019 13:56:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A45C028D24; Thu, 11 Apr 2019 13:56:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3CAE328D9B for ; Thu, 11 Apr 2019 13:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=DF6ukrx8Hwvebdt5w4gN/QYYKCEw1cJ+rPk+h5AgBgY=; b=Sb5y7iXfMghxnh HEGf8T2+0jx5XPx53ugRK/JxyGAHsVwwCrn6y15Qv6Mtx83AMWKsPynOF1oJXxA3Ovui5WmYJTadU X/nCRmECGtBjq0n38yi4tgi6Q1whhFQ4FEVAZHfe90bhaHsCL7VyjHbIiF5WKBLFxe4PLJpvsLD7K PYyQpMp+n1ktyKAkodke3CVWKg4kXYN9vdx561fu9gECeLbtswfF3qxyfCFeQvH2VApMcRbHaj5s8 q/35fyOI1Wt31Ga0cIo56ILwHPLwJYGAeFG2JOeuZwit2FEqxjj08Q3n74ytnS8BclmD9EP+PgGpO HWKYe1ZZ5D1Esnbzk0Hg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEaBu-0003gJ-6w; Thu, 11 Apr 2019 13:56:34 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEaBm-0003Ye-2p for linux-rockchip@lists.infradead.org; Thu, 11 Apr 2019 13:56:27 +0000 Received: by mail-pl1-x641.google.com with SMTP id cv12so3458200plb.9 for ; Thu, 11 Apr 2019 06:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6ClUU+SVRlGfqKXGcUvbdevlNJHckubkDnT0pIeXVGo=; b=Y+IULaGQZPcgXGJKaO5x/3c7/CS7b90tbNi6x4SdpFMvxU4a5RglgbAZVSN55QDhup 6GWTZmjKDYPmeU74rNmCh9Vqkhnvgfia5fespuvh1mJKf8h/E4GHD1I9X9QTCCZ7u515 zwqxIRaEvJv9z+w6CLpB0Bswnof/T2ORp5u0A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6ClUU+SVRlGfqKXGcUvbdevlNJHckubkDnT0pIeXVGo=; b=Z6i4P835HjoCIusObWZ2g6LWisnKSrBoGVJpUwoFzqJ3vo/IMWLkJA/5KVLmHzX+E7 vasesT1zIjOBwP5Rwv0KNevcPJ54qxhd50VZoI58qGWBtYNjLOHqYuKAcMglFJC86WmL Vn9hRFgPa15t/POPtqiDVHXUBbyOeCaYocbW1FVV+ELb6horvoOaB/UstJzLLAg3HDha X5LSd7hAZv+syyO/74+eiCJZzuc6UFYR2QxSvRIlJHMyoHVGbbk6dxXiBsY7PAiY/XjC 2/7U4moPN2drjfW0cvQ7rXzsL5XNtHymqCKzaVSwSyg8pBaWWwEyT+6DaZWBCyP5uuBy VXCA== X-Gm-Message-State: APjAAAX7RUnmgm2SNeJ9mrJ8I1phSVFTMj+uKB++Qw4ZVTsqF5Z0wOup x4FpA7TbOHUA3J9yW6pAPhQdMw== X-Google-Smtp-Source: APXvYqxdkm3c+ME8kedFIAhaOjckgUmY14dX6xlRAn1S2d2DSoin0DQYAjnnqNzJDm8fzIwl6ZRw/g== X-Received: by 2002:a17:902:4381:: with SMTP id j1mr48303199pld.75.1554990985257; Thu, 11 Apr 2019 06:56:25 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id v189sm90797218pgd.77.2019.04.11.06.56.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 06:56:24 -0700 (PDT) From: Douglas Anderson To: Heiko Stuebner Subject: [PATCH v2] clk: rockchip: Fix video codec clocks on rk3288 Date: Thu, 11 Apr 2019 06:55:55 -0700 Message-Id: <20190411135555.235625-1-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190411_065626_150215_EE19B997 X-CRM114-Status: GOOD ( 17.09 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ziyuan Xu , Jonas Karlman , Stephen Boyd , linux-kernel@vger.kernel.org, Michael Turquette , Randy Li , Douglas Anderson , Tomasz Figa , linux-rockchip@lists.infradead.org, mka@chromium.org, ryandcase@chromium.org, Elaine Zhang , Ezequiel Garcia , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP It appears that there is a typo in the rk3288 TRM. For GRF_SOC_CON0[7] it says that 0 means "vepu" and 1 means "vdpu". It's the other way around. How do I know? Here's my evidence: 1. Prior to commit 4d3e84f99628 ("clk: rockchip: describe aclk_vcodec using the new muxgrf type on rk3288") we always pretended that we were using "aclk_vdpu" and the comment in the code said that this matched the default setting in the system. In fact the default setting is 0 according to the TRM and according to reading memory at bootup. In addition rk3288-based Chromebooks ran like this and the video codecs worked. 2. With the existing clock code if you boot up and try to enable the new VIDEO_ROCKCHIP_VPU as a module (and without "clk_ignore_unused" on the command line), you get errors like "failed to get ack on domain 'pd_video', val=0x80208". After flipping vepu/vdpu things init OK. 3. If I export and add both the vepu and vdpu to the list of clocks for RK3288_PD_VIDEO I can get past the power domain errors, but now I freeze when the vpu_mmu gets initted. 4. If I just mark the "vdpu" as IGNORE_UNUSED then everything boots up and probes OK showing that somehow the "vdpu" was important to keep enabled. This is because we were actually using it as a parent. 5. After this change I can hack "aclk_vcodec_pre" to parent from "aclk_vepu" using assigned-clocks and the video codec still probes OK. 6. Rockchip has said so on the mailing list [1]. ...so let's fix it. Let's also add CLK_SET_RATE_PARENT to "aclk_vcodec_pre" as suggested by Jonas Karlman. Prior to the same commit you could do clk_set_rate() on "aclk_vcodec" and it would change "aclk_vdpu". That's because "aclk_vcodec" was a simple gate clock (always gets CLK_SET_RATE_PARENT) and its direct parent was "aclk_vdpu". After that commit "aclk_vcodec_pre" gets in the way so we need to add CLK_SET_RATE_PARENT to it too. [1] https://lkml.kernel.org/r/1d17b015-9e17-34b9-baf8-c285dc1957aa@rock-chips.com Fixes: 4d3e84f99628 ("clk: rockchip: describe aclk_vcodec using the new muxgrf type on rk3288") Suggested-by: Jonas Karlman Suggested-by: Randy Li Signed-off-by: Douglas Anderson --- Changes in v2: - Now also has CLK_SET_RATE_PARENT for "aclk_vcodec_pre" - Added Suggested-by tags for prior work - Added link to Elaine saying that this is indeed correct drivers/clk/rockchip/clk-rk3288.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c index 5a67b7869960..51e8e799debb 100644 --- a/drivers/clk/rockchip/clk-rk3288.c +++ b/drivers/clk/rockchip/clk-rk3288.c @@ -219,7 +219,7 @@ PNAME(mux_hsadcout_p) = { "hsadc_src", "ext_hsadc" }; PNAME(mux_edp_24m_p) = { "ext_edp_24m", "xin24m" }; PNAME(mux_tspout_p) = { "cpll", "gpll", "npll", "xin27m" }; -PNAME(mux_aclk_vcodec_pre_p) = { "aclk_vepu", "aclk_vdpu" }; +PNAME(mux_aclk_vcodec_pre_p) = { "aclk_vdpu", "aclk_vepu" }; PNAME(mux_usbphy480m_p) = { "sclk_otgphy1_480m", "sclk_otgphy2_480m", "sclk_otgphy0_480m" }; PNAME(mux_hsicphy480m_p) = { "cpll", "gpll", "usbphy480m_src" }; @@ -420,7 +420,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = { COMPOSITE(0, "aclk_vdpu", mux_pll_src_cpll_gpll_usb480m_p, 0, RK3288_CLKSEL_CON(32), 14, 2, MFLAGS, 8, 5, DFLAGS, RK3288_CLKGATE_CON(3), 11, GFLAGS), - MUXGRF(0, "aclk_vcodec_pre", mux_aclk_vcodec_pre_p, 0, + MUXGRF(0, "aclk_vcodec_pre", mux_aclk_vcodec_pre_p, CLK_SET_RATE_PARENT, RK3288_GRF_SOC_CON(0), 7, 1, MFLAGS), GATE(ACLK_VCODEC, "aclk_vcodec", "aclk_vcodec_pre", 0, RK3288_CLKGATE_CON(9), 0, GFLAGS),