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: 10495341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0D154601BE for ; Thu, 28 Jun 2018 23:16:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F089229BE8 for ; Thu, 28 Jun 2018 23:16:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E418B29BB7; Thu, 28 Jun 2018 23:16:14 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham 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 7F3CB29BB7 for ; Thu, 28 Jun 2018 23:16:14 +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=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 1fYg90-00031d-Oa; Thu, 28 Jun 2018 23:16:06 +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-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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)