From patchwork Thu Jun 28 23:15:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 936553 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uvgVKqmM"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bJDsK2t/"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GwdJ2jhRz9s01 for ; Fri, 29 Jun 2018 09:16:15 +1000 (AEST) 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=cbcvvQzkN9Up2qQVJXhgYVQw8LdtveVBF3GvtXc/ZTw=; b=uvgVKqmMp7fXpA UvZcQnL35bjTI7LttF0ZNdFRlAjBsO4Is9ienwyjw+ew842uSyRVy9M0RX9BHg8FxB/MeV357fGNb vShj+4+BIQgdqfUAi1d9e9MC8/RABYMkVAqq00eKnZ9kxdWItL+oRAPehsw8VQ5mkBimN9bt/uFWF icTZF8yJ9hU0w6yJMuKs3Z0PYGuDKQQjwjg/1ER4hyqPlqdyIyFHpJ1cYVrPySNzupWIoqGJxQ8gk 7RhPxqoaa5qdfRsELMAr8BeaGIhNWqpkqS0FiRHEKkzTam63Qq9mKAFFSqj0ju8laePCkZa3XUL7N LHi4SGLFCBxTU/ggzpFQ==; 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 1fYg91-00031d-Ol; Thu, 28 Jun 2018 23:16:07 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYg8v-00030I-PF for linux-arm-kernel@lists.infradead.org; Thu, 28 Jun 2018 23:16:04 +0000 Received: by mail-pg0-x243.google.com with SMTP id o11-v6so3116098pgv.4 for ; Thu, 28 Jun 2018 16:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GYHmEfwyTRZ2qUDtn+3Srp2bHdRirZCZ1+7PwhwO5Yw=; b=bJDsK2t/b2eO+wapQnUgAn2kb2/gACPDaGEA+jNOA8yyOttUubToqkyTn907OVigW1 sidqEHbabFsBlpZIySUbmJ4CZ5H26/xTqDvAgNTdwZfYnTpMEUL1PiTSklSMakNkPGoi RJHGvvKvJHhPyu3PnCASlnVEweuFCswlOIiuMkeJmjXaKtudUNMbML5w+fMad1iuZl5r 8aBCHRUAsLOJn8q0A6TpINSlSFzwOPwgq8nhyYMfhlf34BMY0IN/ilmt0G4vXYlJDRcu UtsNlggFZvl+Ak1M6+73aK2tWMm4DLe40fgzCTybMJKbFQR4wDmm0XQUdZ0/bD9dqL5d aQsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=GYHmEfwyTRZ2qUDtn+3Srp2bHdRirZCZ1+7PwhwO5Yw=; b=KZwJXOcx22cOPQxGqvnB8281fPDrjcHIz03ghzxUQfXv1fKLBpi5FYj5eVyvpQyz9q i6Vftfij8sDhReFEv38048BLWdROWFMROltbY0MQ9gEUEiIHBudRNQDtzZ4y7ydABxZ6 FTq3nTWd4nCUqqvTWgHq+o6oDp8WuTgI4N3WgGTmAIYPQFc0W9RzpEC9w9auk5TTmV6+ qX8CwIoSSe4JwoAq8Sli9zMMbfYLjmYmFNGcVPDUuox/307A7iCBWGpI9iG/g3rAHTCY Fie3aRBpbyuHdMudJhRl8e1+iXF1Taa6Fb2CbxlAqSaVtSH0tKITPc6WcZ6cd4LnnS89 R45g== X-Gm-Message-State: APt69E0frpQ5haEqyCCSDq89rJH2rzHcPlHeLLiglQ2CvhhY+KQlxaw1 i/Zsme61Xam74IfUIi7LeQwXLVDt X-Google-Smtp-Source: ADUXVKKysZC1UX+252EUEE1WC3cuimzFQlTjYoIpHShYayHIlBuI61JN3F5OWkz9DKrUUPPbu4LoJg== X-Received: by 2002:a65:63cd:: with SMTP id n13-v6mr10345735pgv.185.1530227750412; Thu, 28 Jun 2018 16:15:50 -0700 (PDT) Received: from aurora.jms.id.au ([203.0.153.9]) by smtp.gmail.com with ESMTPSA id m7-v6sm7993378pfj.25.2018.06.28.16.15.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jun 2018 16:15:49 -0700 (PDT) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Fri, 29 Jun 2018 08:45:43 +0930 From: Joel Stanley To: Michael Turquette , Stephen Boyd Subject: [PATCH] clk: aspeed: Support HPLL strapping on ast2400 Date: Fri, 29 Jun 2018 08:45:40 +0930 Message-Id: <20180628231540.26633-1-joel@jms.id.au> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180628_161601_824241_CAD3CCC0 X-CRM114-Status: GOOD ( 15.84 ) X-Spam-Score: 0.5 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c05:0:0:0:243 listed in] [list.dnswl.org] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (joel.stan[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed@lists.ozlabs.org, Andrew Jeffery , linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org The HPLL can be configured through a register (SCU24), however some platforms chose to configure it through the strapping settings and do not use the register. This was not noticed as the logic for bit 18 in SCU24 was confused: set means programmed, but the driver read it as set means strapped. This gives us the correct HPLL value on Palmetto systems, from which most of the peripheral clocks are generated. Fixes: 5eda5d79e4be ("clk: Add clock driver for ASPEED BMC SoCs") Cc: stable@vger.kernel.org # v4.15 Reviewed-by: Cédric Le Goater Signed-off-by: Joel Stanley --- drivers/clk/clk-aspeed.c | 42 +++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/drivers/clk/clk-aspeed.c b/drivers/clk/clk-aspeed.c index 38b366b00c57..2ef4ad7bdbdc 100644 --- a/drivers/clk/clk-aspeed.c +++ b/drivers/clk/clk-aspeed.c @@ -24,7 +24,7 @@ #define ASPEED_MPLL_PARAM 0x20 #define ASPEED_HPLL_PARAM 0x24 #define AST2500_HPLL_BYPASS_EN BIT(20) -#define AST2400_HPLL_STRAPPED BIT(18) +#define AST2400_HPLL_PROGRAMMED BIT(18) #define AST2400_HPLL_BYPASS_EN BIT(17) #define ASPEED_MISC_CTRL 0x2c #define UART_DIV13_EN BIT(12) @@ -565,29 +565,45 @@ builtin_platform_driver(aspeed_clk_driver); static void __init aspeed_ast2400_cc(struct regmap *map) { struct clk_hw *hw; - u32 val, freq, div; + u32 val, div, clkin, hpll; + const u16 hpll_rates[][4] = { + {384, 360, 336, 408}, + {400, 375, 350, 425}, + }; + int rate; /* * CLKIN is the crystal oscillator, 24, 48 or 25MHz selected by * strapping */ regmap_read(map, ASPEED_STRAP, &val); - if (val & CLKIN_25MHZ_EN) - freq = 25000000; - else if (val & AST2400_CLK_SOURCE_SEL) - freq = 48000000; - else - freq = 24000000; - hw = clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, freq); - pr_debug("clkin @%u MHz\n", freq / 1000000); + rate = (val >> 8) & 3; + if (val & CLKIN_25MHZ_EN) { + clkin = 25000000; + hpll = hpll_rates[1][rate]; + } else if (val & AST2400_CLK_SOURCE_SEL) { + clkin = 48000000; + hpll = hpll_rates[0][rate]; + } else { + clkin = 24000000; + hpll = hpll_rates[0][rate]; + } + hw = clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, clkin); + pr_debug("clkin @%u MHz\n", clkin / 1000000); /* * High-speed PLL clock derived from the crystal. This the CPU clock, - * and we assume that it is enabled + * and we assume that it is enabled. It can be configured through the + * HPLL_PARAM register, or set to a specified frequency by strapping. */ regmap_read(map, ASPEED_HPLL_PARAM, &val); - WARN(val & AST2400_HPLL_STRAPPED, "hpll is strapped not configured"); - aspeed_clk_data->hws[ASPEED_CLK_HPLL] = aspeed_ast2400_calc_pll("hpll", val); + if (val & AST2400_HPLL_PROGRAMMED) + hw = aspeed_ast2400_calc_pll("hpll", val); + else + hw = clk_hw_register_fixed_rate(NULL, "hpll", "clkin", 0, + hpll * 1000000); + + aspeed_clk_data->hws[ASPEED_CLK_HPLL] = hw; /* * Strap bits 11:10 define the CPU/AHB clock frequency ratio (aka HCLK)