From patchwork Thu Jul 30 14:13:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 11693163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4510C13B1 for ; Thu, 30 Jul 2020 14:16:05 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1D53D2070B for ; Thu, 30 Jul 2020 14:16:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="U9kBUlXG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D53D2070B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=B3t73Gdem7OJcvWhOWu2ZY3UyM7y0RQclMHaTDaAtHo=; b=U9kBUlXGzUReg0vtXFaiIDmoV/ IOb9tfmLS2SxigyKXdJ0Q0mS+CweAhih+jWPLLp8E3sUUoyaUjlx/Qyuj4LcUTbMfIE6RH18joJav Ufdt7U6xjaOnmKq22Ye2UaeIKWqI9gSDuKmtxulSre0hStA0WQTwcgb7C3YMFnpKYQD+18A/Pa8ui KhQEBk0DcyG0wto92/5pISjnw8ZSFqwElyhbtgQaT0wBgmbYh0OrRYruBtH4QQPCIVRUVWxi59Ndp nonGyZvPljaJ3tHIAWxQiq1ZQt9cZmOD9CQDFqxx1u7ClmBI7XdvbDAmyb3bAF/U+WGACpisgmyy7 OYR3aQlA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k19Je-00027s-Pk; Thu, 30 Jul 2020 14:13:50 +0000 Received: from mx2.suse.de ([195.135.220.15]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k19Jb-000277-NV; Thu, 30 Jul 2020 14:13:48 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7647FAB3E; Thu, 30 Jul 2020 14:13:55 +0000 (UTC) From: Nicolas Saenz Julienne To: Nicolas Saenz Julienne , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Eric Anholt , Matthias Brugger , Stefan Wahren Subject: [PATCH] clk: bcm2835: Do not use prediv with bcm2711's PLLs Date: Thu, 30 Jul 2020 16:13:37 +0200 Message-Id: <20200730141337.12753-1-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_101347_960366_3E79D430 X-CRM114-Status: GOOD ( 15.48 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [195.135.220.15 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [195.135.220.15 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Boyd , kernel-list@raspberrypi.com, Michael Turquette , linux-kernel@vger.kernel.org, pbrobinson@gmail.com, Nathan Chancellor , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Contrary to previous SoCs, bcm2711 doesn't have a prescaler in the PLL feedback loop. Bypass it by zeroing fb_prediv_mask. Note that, since the prediv configuration bits were re-purposed, this was triggering a miscalculation on all clock hanging from the VPU clock, notably the aux UART, making its output unintelligible. Fixes: 42de9ad400af ("clk: bcm2835: Add BCM2711_CLOCK_EMMC2 support") Reported-by: Nathan Chancellor Signed-off-by: Nicolas Saenz Julienne --- FYI relevant discussion with RPi engineers: https://github.com/raspberrypi/firmware/issues/1435#issuecomment-666242077 drivers/clk/bcm/clk-bcm2835.c | 79 +++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 4 deletions(-) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 027eba31f793..acf499d26263 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -454,6 +454,16 @@ static const struct bcm2835_pll_ana_bits bcm2835_ana_default = { .fb_prediv_mask = BIT(14), }; +static const struct bcm2835_pll_ana_bits bcm2711_ana_default = { + .mask0 = 0, + .set0 = 0, + .mask1 = A2W_PLL_KI_MASK | A2W_PLL_KP_MASK, + .set1 = (2 << A2W_PLL_KI_SHIFT) | (8 << A2W_PLL_KP_SHIFT), + .mask3 = A2W_PLL_KA_MASK, + .set3 = (2 << A2W_PLL_KA_SHIFT), + .fb_prediv_mask = 0, /* No prediv in bcm2711 */ +}; + static const struct bcm2835_pll_ana_bits bcm2835_ana_pllh = { .mask0 = A2W_PLLH_KA_MASK | A2W_PLLH_KI_LOW_MASK, .set0 = (2 << A2W_PLLH_KA_SHIFT) | (2 << A2W_PLLH_KI_LOW_SHIFT), @@ -1631,7 +1641,7 @@ static const struct bcm2835_clk_desc clk_desc_array[] = { * AUDIO domain is on. */ [BCM2835_PLLA] = REGISTER_PLL( - SOC_ALL, + SOC_BCM2835, .name = "plla", .cm_ctrl_reg = CM_PLLA, .a2w_ctrl_reg = A2W_PLLA_CTRL, @@ -1642,6 +1652,21 @@ static const struct bcm2835_clk_desc clk_desc_array[] = { .ana = &bcm2835_ana_default, + .min_rate = 600000000u, + .max_rate = 2400000000u, + .max_fb_rate = BCM2835_MAX_FB_RATE), + [BCM2835_PLLA] = REGISTER_PLL( + SOC_BCM2711, + .name = "plla", + .cm_ctrl_reg = CM_PLLA, + .a2w_ctrl_reg = A2W_PLLA_CTRL, + .frac_reg = A2W_PLLA_FRAC, + .ana_reg_base = A2W_PLLA_ANA0, + .reference_enable_mask = A2W_XOSC_CTRL_PLLA_ENABLE, + .lock_mask = CM_LOCK_FLOCKA, + + .ana = &bcm2711_ana_default, + .min_rate = 600000000u, .max_rate = 2400000000u, .max_fb_rate = BCM2835_MAX_FB_RATE), @@ -1687,7 +1712,7 @@ static const struct bcm2835_clk_desc clk_desc_array[] = { /* PLLB is used for the ARM's clock. */ [BCM2835_PLLB] = REGISTER_PLL( - SOC_ALL, + SOC_BCM2835, .name = "pllb", .cm_ctrl_reg = CM_PLLB, .a2w_ctrl_reg = A2W_PLLB_CTRL, @@ -1698,6 +1723,22 @@ static const struct bcm2835_clk_desc clk_desc_array[] = { .ana = &bcm2835_ana_default, + .min_rate = 600000000u, + .max_rate = 3000000000u, + .max_fb_rate = BCM2835_MAX_FB_RATE, + .flags = CLK_GET_RATE_NOCACHE), + [BCM2835_PLLB] = REGISTER_PLL( + SOC_BCM2711, + .name = "pllb", + .cm_ctrl_reg = CM_PLLB, + .a2w_ctrl_reg = A2W_PLLB_CTRL, + .frac_reg = A2W_PLLB_FRAC, + .ana_reg_base = A2W_PLLB_ANA0, + .reference_enable_mask = A2W_XOSC_CTRL_PLLB_ENABLE, + .lock_mask = CM_LOCK_FLOCKB, + + .ana = &bcm2711_ana_default, + .min_rate = 600000000u, .max_rate = 3000000000u, .max_fb_rate = BCM2835_MAX_FB_RATE, @@ -1720,7 +1761,7 @@ static const struct bcm2835_clk_desc clk_desc_array[] = { * AUDIO domain is on. */ [BCM2835_PLLC] = REGISTER_PLL( - SOC_ALL, + SOC_BCM2835, .name = "pllc", .cm_ctrl_reg = CM_PLLC, .a2w_ctrl_reg = A2W_PLLC_CTRL, @@ -1731,6 +1772,21 @@ static const struct bcm2835_clk_desc clk_desc_array[] = { .ana = &bcm2835_ana_default, + .min_rate = 600000000u, + .max_rate = 3000000000u, + .max_fb_rate = BCM2835_MAX_FB_RATE), + [BCM2835_PLLC] = REGISTER_PLL( + SOC_BCM2711, + .name = "pllc", + .cm_ctrl_reg = CM_PLLC, + .a2w_ctrl_reg = A2W_PLLC_CTRL, + .frac_reg = A2W_PLLC_FRAC, + .ana_reg_base = A2W_PLLC_ANA0, + .reference_enable_mask = A2W_XOSC_CTRL_PLLC_ENABLE, + .lock_mask = CM_LOCK_FLOCKC, + + .ana = &bcm2711_ana_default, + .min_rate = 600000000u, .max_rate = 3000000000u, .max_fb_rate = BCM2835_MAX_FB_RATE), @@ -1782,7 +1838,7 @@ static const struct bcm2835_clk_desc clk_desc_array[] = { * AUDIO domain is on. */ [BCM2835_PLLD] = REGISTER_PLL( - SOC_ALL, + SOC_BCM2835, .name = "plld", .cm_ctrl_reg = CM_PLLD, .a2w_ctrl_reg = A2W_PLLD_CTRL, @@ -1793,6 +1849,21 @@ static const struct bcm2835_clk_desc clk_desc_array[] = { .ana = &bcm2835_ana_default, + .min_rate = 600000000u, + .max_rate = 2400000000u, + .max_fb_rate = BCM2835_MAX_FB_RATE), + [BCM2835_PLLD] = REGISTER_PLL( + SOC_BCM2711, + .name = "plld", + .cm_ctrl_reg = CM_PLLD, + .a2w_ctrl_reg = A2W_PLLD_CTRL, + .frac_reg = A2W_PLLD_FRAC, + .ana_reg_base = A2W_PLLD_ANA0, + .reference_enable_mask = A2W_XOSC_CTRL_DDR_ENABLE, + .lock_mask = CM_LOCK_FLOCKD, + + .ana = &bcm2711_ana_default, + .min_rate = 600000000u, .max_rate = 2400000000u, .max_fb_rate = BCM2835_MAX_FB_RATE),