Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp974751ybt; Wed, 17 Jun 2020 19:36:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6YRPLs9/TJqhflKVwgk/sqPC2RIh8SZ/AzfIE2ga/KN0KEafbE8DQZ+Tro7bnrVWiUQX3 X-Received: by 2002:a50:cd1c:: with SMTP id z28mr2027475edi.257.1592447817618; Wed, 17 Jun 2020 19:36:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592447817; cv=none; d=google.com; s=arc-20160816; b=Uf26SP/EFMi8t837cveqF7O6auMnSkn7BrtEhHspQTMjchfJJtd9NTG6R6ITufTIMB vFo9QQzop+ljd1zsTq7ZZADJQfahCOxmBEHJSVGhvc67/crx1/gHFwK0L7yetHCyKq3+ MRejqaGw2K0cNBnAtV4i/HEbDMaxOsb+qlk8TgABViyuAZPQnAZgQo3+Z6p0viSp+hUP lxORElXMc7gt1HlTWtSE1jUQA9wdvWVBY+ABZy2zr54UCYgx2eVqPnYQFfyfJ3aimyFg mzK0DLNpB6a1wMKgQ1mZylFhsglKaIqXAXwaWTljFLSe3UuSw9uSi31Gxcf3qZhMfWte rbnw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PHU9mRhRlQURL8OI8FPAzTMsNCvNCrO88h8otunAKUs=; b=hBkRwC43ho2BfK/ueZ2RI/4j9ugY4HWSDISQzQiKwdo+pJr4Yy1dp2ZplaVFwF7lcQ bG29MP3+NCaRrmEz7cA65z94t7V5gNxegjfrxsxcvFfylqITpNzgTKh05yr3hKIfnNtS 0zSnEPFvJoJXHkiLzWLHQSjWcCFuPjs1JhHtFcceaVNREiFDpxYyBpGQnKlTx2/v167s DUk5YbKGsDj2rlgCO8Kojf+y+H+NjanXYASSIsEvMmUz5cHy4OD30oeLyyiHZxBHNS+x /J3tkwDVcGbzjUwYlLAqq/O0gxwXPMU8AnNpAyQmeWoDP88I40DjYkmZ1+pTeLOPtkTp xRtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="tThE2/P6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si1208025edj.537.2020.06.17.19.36.35; Wed, 17 Jun 2020 19:36:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="tThE2/P6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729564AbgFRCfA (ORCPT + 99 others); Wed, 17 Jun 2020 22:35:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:44054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727777AbgFRBOX (ORCPT ); Wed, 17 Jun 2020 21:14:23 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 136B9221F0; Thu, 18 Jun 2020 01:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592442862; bh=yxjlZXBHSwssaqDKkjpPc3u3wRsrsKwzGkwMtEVmXMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tThE2/P6lgln4Nj0KFtkreybaiC0tWn/b2VYDR/5lYndMbdPvZkU2VK/6tSrYqDJm KOmHiWbh2+wXA+1MGVS+PDtfBNVu0HNhQkhx4gsNvCbIEbnBgYPblwZaLwsOJ/S5VR J+dbygA3/XSQk3vZTar4SrQ4FImtshLKft+ibHwE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Eddie James , Stephen Boyd , Sasha Levin , linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 291/388] clk: ast2600: Fix AHB clock divider for A1 Date: Wed, 17 Jun 2020 21:06:28 -0400 Message-Id: <20200618010805.600873-291-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618010805.600873-1-sashal@kernel.org> References: <20200618010805.600873-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eddie James [ Upstream commit 2d491066ccd4286538450c227fc5094ceb04b494 ] The latest specs for the AST2600 A1 chip include some different bit definitions for calculating the AHB clock divider. Implement these in order to get the correct AHB clock value in Linux. Signed-off-by: Eddie James Link: https://lkml.kernel.org/r/20200408203616.4031-1-eajames@linux.ibm.com Fixes: d3d04f6c330a ("clk: Add support for AST2600 SoC") Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/clk-ast2600.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c index 392d01705b97..99afc949925f 100644 --- a/drivers/clk/clk-ast2600.c +++ b/drivers/clk/clk-ast2600.c @@ -642,14 +642,22 @@ static const u32 ast2600_a0_axi_ahb_div_table[] = { 2, 2, 3, 5, }; -static const u32 ast2600_a1_axi_ahb_div_table[] = { - 4, 6, 2, 4, +static const u32 ast2600_a1_axi_ahb_div0_tbl[] = { + 3, 2, 3, 4, +}; + +static const u32 ast2600_a1_axi_ahb_div1_tbl[] = { + 3, 4, 6, 8, +}; + +static const u32 ast2600_a1_axi_ahb200_tbl[] = { + 3, 4, 3, 4, 2, 2, 2, 2, }; static void __init aspeed_g6_cc(struct regmap *map) { struct clk_hw *hw; - u32 val, div, chip_id, axi_div, ahb_div; + u32 val, div, divbits, chip_id, axi_div, ahb_div; clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, 25000000); @@ -679,11 +687,22 @@ static void __init aspeed_g6_cc(struct regmap *map) else axi_div = 2; + divbits = (val >> 11) & 0x3; regmap_read(map, ASPEED_G6_SILICON_REV, &chip_id); - if (chip_id & BIT(16)) - ahb_div = ast2600_a1_axi_ahb_div_table[(val >> 11) & 0x3]; - else + if (chip_id & BIT(16)) { + if (!divbits) { + ahb_div = ast2600_a1_axi_ahb200_tbl[(val >> 8) & 0x3]; + if (val & BIT(16)) + ahb_div *= 2; + } else { + if (val & BIT(16)) + ahb_div = ast2600_a1_axi_ahb_div1_tbl[divbits]; + else + ahb_div = ast2600_a1_axi_ahb_div0_tbl[divbits]; + } + } else { ahb_div = ast2600_a0_axi_ahb_div_table[(val >> 11) & 0x3]; + } hw = clk_hw_register_fixed_factor(NULL, "ahb", "hpll", 0, 1, axi_div * ahb_div); aspeed_g6_clk_data->hws[ASPEED_CLK_AHB] = hw; -- 2.25.1