From patchwork Thu Aug 29 11:25:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 172576 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp2080058ily; Thu, 29 Aug 2019 04:25:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCUVbpoBLsFMrBJz1XQnseQ8ExXmdvC7Gj2cSI4Fo3xDcTCg6MeNN2pckYYBK3Ljb0Q4jv X-Received: by 2002:a65:5382:: with SMTP id x2mr7860190pgq.422.1567077913033; Thu, 29 Aug 2019 04:25:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567077913; cv=none; d=google.com; s=arc-20160816; b=QcBtyjoFucXXBWVK98269IjRUSucKGZ1bXkUUsgvj4pJA4oZ/+YIKGxeQr60JfR91F t0oXZKXzZom+BqottNB2yD4oOTLhDJ9yPVeNzNHvxO1DC1fS4A/kV1KaNkt3daFNmCmg 5F1Cw7QPOD/F3Xqne1TobOpa1kmZZNs6DeT79fLOohxUaSkKVwJ30kfoPkPZG6r/Ba2w +SESTSegYhtz3FJiqZQC5B2mN+R1355vb5z0w+cAIqo9FjR56UcC9D7ItfUMPmpuwuUW iXX7nrN5OD0WX1dYsSo5JuFjgBbbLUw3VhnT85cJEidvr3ooc+keKx+174sKYXs9hdZS X+xw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=2SEXw+QRJoy/Zw++CiU1hS9QPCb+vnyFD+grq4TKD4o=; b=KVOi8cjRVaeRMHrmDEi/q6JwqBDOEvcr6x1+0vJirEsOGkhZ6L3BjpW8kAJ25Y4MVT YO10hM2dhYtYk2Zek8vu+L5kRc0FGyyEr+3Pt6nm145xIHg4ixeGZqxIv3B2MBzPHXIE Z8M7GQIj8hb4wiWIbnpgTW2F1OVcFIvoOQg6GHZOPVxFFPQdHh55Oar0bYaOZLr9yrx7 sRZvrKxXnuhrb2jsG17Kt1py45MGr11ndKkThU+fQ6W9xvjKgPuYyxdmieXZcsys/ikE Bjt25cc+T/XjvyeRfBVTmtk3FtO+LN/N6uB4nVin3dOnFPbuEbYmEbWD3LITupkO7ntC XDzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ImzuAe+l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19si1875783pjs.54.2019.08.29.04.25.12; Thu, 29 Aug 2019 04:25:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ImzuAe+l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727347AbfH2LZL (ORCPT + 28 others); Thu, 29 Aug 2019 07:25:11 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45584 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726379AbfH2LZK (ORCPT ); Thu, 29 Aug 2019 07:25:10 -0400 Received: by mail-lj1-f193.google.com with SMTP id l1so2607817lji.12 for ; Thu, 29 Aug 2019 04:25:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2SEXw+QRJoy/Zw++CiU1hS9QPCb+vnyFD+grq4TKD4o=; b=ImzuAe+lRaaytGnmLlr3YyNIlg6wvfK0gNIW92d3yyBjapIQC8UYgkKKWJ+dOn8YlQ PdbCEa6KjsZlie24Bp93fBjWnKXkmtIqOe9cQaj/ftpaorxjf1g8qgPS9lRxicumFXId IOvMxDvTxIbDUbvAKazMmNTqtKP/JOFL7Hc3z0FajnBNxWDlhRLcZwTZu3QtWZfOibOf yGmb/AoKeJOFVe7wKzzWQH8MvQRGM9Sbkebdem+EWPyXliHwCpBIzU5NBRfyxyK4ZCN2 b9SUjX1UQ2crrztiaMi+GRGxV3Z1vNj1U1ikJtfLzmjYStvkEpuy9pYKQksrpmBMQ7iT DoXA== 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=2SEXw+QRJoy/Zw++CiU1hS9QPCb+vnyFD+grq4TKD4o=; b=kCFyiK5JjTXYPTfAcZk1rOIIj8/kPhBuJjsMvGIxlMTMFFjcYnZdgzj8kT4O5QMCFf Ib9/hIPSstAcia8B/WcUYgOnuVdLK/SvaVAkxYSql8trDjIxpRw/50yFF+suGBb3734k S2CikWOjzhjI/kAqlTiWFkQPr8VzHisdjanxtpFdnU7SQjJjq/yoFT+IHoU6EEybcynx hshCmwvHx3D8YkVS5uKAaOIMgsANG/aGDFP7LuY5SucPDQkrLY3N/Qaq9iW89FUe3oaJ Etkdq5ORpgGhiaoJpq4UbaReYia8vb2JS3E5e6Vq5QbcnbWmyZ2J5sk4EEIaY/4Lnxk0 m1AA== X-Gm-Message-State: APjAAAUvxTN9qHuKy0BgVM9H+7U7f4tX64+W9tsWjurSswO5ltZLqkdA HkrsXprHVBnLE9jHosUWEsdR7g== X-Received: by 2002:a2e:9a10:: with SMTP id o16mr5085094lji.104.1567077908566; Thu, 29 Aug 2019 04:25:08 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id d21sm350092lfc.73.2019.08.29.04.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 04:25:07 -0700 (PDT) From: Linus Walleij To: lee.jones@linaro.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Stephan Gerhold Subject: [PATCH] mfd: db8500-prcmu: Support the higher DB8520 ARMSS Date: Thu, 29 Aug 2019 13:25:01 +0200 Message-Id: <20190829112501.30185-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The DB8520 used in a lot of Samsung phones has a slightly higher maximum ARMSS frequency than the DB8500. In order to not confuse the OPP framework and cpufreq, make sure the PRCMU driver returns the correct frequency. Cc: Lee Jones Cc: Stephan Gerhold Signed-off-by: Linus Walleij --- drivers/mfd/db8500-prcmu.c | 40 +++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) -- 2.21.0 diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index a1e09bf06977..6c9905652e08 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c @@ -1692,21 +1692,41 @@ static long round_clock_rate(u8 clock, unsigned long rate) return rounded_rate; } -static const unsigned long armss_freqs[] = { +static const unsigned long db8500_armss_freqs[] = { 200000000, 400000000, 800000000, 998400000 }; +/* The DB8520 has slightly higher ARMSS max frequency */ +static const unsigned long db8520_armss_freqs[] = { + 200000000, + 400000000, + 800000000, + 1152000000 +}; + + + static long round_armss_rate(unsigned long rate) { unsigned long freq = 0; + const unsigned long *freqs; + int nfreqs; int i; + if (fw_info.version.project == PRCMU_FW_PROJECT_U8520) { + freqs = db8520_armss_freqs; + nfreqs = ARRAY_SIZE(db8520_armss_freqs); + } else { + freqs = db8500_armss_freqs; + nfreqs = ARRAY_SIZE(db8500_armss_freqs); + } + /* Find the corresponding arm opp from the cpufreq table. */ - for (i = 0; i < ARRAY_SIZE(armss_freqs); i++) { - freq = armss_freqs[i]; + for (i = 0; i < nfreqs; i++) { + freq = freqs[i]; if (rate <= freq) break; } @@ -1851,11 +1871,21 @@ static int set_armss_rate(unsigned long rate) { unsigned long freq; u8 opps[] = { ARM_EXTCLK, ARM_50_OPP, ARM_100_OPP, ARM_MAX_OPP }; + const unsigned long *freqs; + int nfreqs; int i; + if (fw_info.version.project == PRCMU_FW_PROJECT_U8520) { + freqs = db8520_armss_freqs; + nfreqs = ARRAY_SIZE(db8520_armss_freqs); + } else { + freqs = db8500_armss_freqs; + nfreqs = ARRAY_SIZE(db8500_armss_freqs); + } + /* Find the corresponding arm opp from the cpufreq table. */ - for (i = 0; i < ARRAY_SIZE(armss_freqs); i++) { - freq = armss_freqs[i]; + for (i = 0; i < nfreqs; i++) { + freq = freqs[i]; if (rate == freq) break; }