Received: by 10.223.185.116 with SMTP id b49csp5956036wrg; Wed, 7 Mar 2018 22:36:10 -0800 (PST) X-Google-Smtp-Source: AG47ELtAwS8O1y3cIQwuYiYB6tjE/Ok5M8Bl+izHY1CG1AJ3r5bIksE+dFipwemrTWZwU5tC9zAY X-Received: by 10.98.13.211 with SMTP id 80mr25418305pfn.69.1520490970822; Wed, 07 Mar 2018 22:36:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520490970; cv=none; d=google.com; s=arc-20160816; b=eCl0L0g/2odmmY9SSHkcKT0Bgq992hpI7tOj8HDPXzS4PQyVCDLUSFFpSDIkQNK0MI 9kuzAAAoKy9wVf30AuN9rP0UPi9O2htyqgJ24A5xoDst4/wlOyZSU0dH33tUggWn4Kdd pz4FiSqhbTFmzc0E+VTpS1RfaMT+rKcsrn95Uov5yL/I40tpysWgsY+cfPtva7njjmNj uugoF5H6XQhZubGvrGpf6gdKLOVcjdJUEmnpRj9h9XrqDJQIWWGGWfTJ6CSYRDtNJQNI Fu4wgGvMbRbkZIBz9kl3S8Qw6uKKRiHJP2Zme2X2nEDh5cyukSNTNtV2HsQAjYoMrKCY 4F9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=+qTeDtncnSuKzkBfbB+KGYk1CMEdZ7IK8yC85C2CtaQ=; b=YiAssbcJe7zox1uTgT6NtgyxsBxshMSq/9uEQr6qZicDIh8kooyta8ZPST1cPFCcs6 fCH9UMS+DzP0OzArVgq29MU2efNXjm7cpS5TQQtgp52O3rXh1+qm4aAbbtljQ7hc1nBZ fm3yjyzwYE+wDRK8SlkheTmnlvf3UtJWq6K1lD8P05aUZKZyJxF9V4UEOJCauYRAMwzW L5qdTTMqL0LdZwazHhORgPq4PoFFi/6kQyYTaIMjlfd5jkhHPQQDTjNhM4Yd8kiO5PUU r68zemvz8ZM+TxByQ19krLNM3N4nlQCJp4I5U7W2Voau0RNWzkcG4sb6ipP5FFUjAJz1 DomQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=bTvuRGgK; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si12394000pgb.805.2018.03.07.22.35.56; Wed, 07 Mar 2018 22:36:10 -0800 (PST) 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=@microsoft.com header.s=selector1 header.b=bTvuRGgK; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965547AbeCHFAB (ORCPT + 99 others); Thu, 8 Mar 2018 00:00:01 -0500 Received: from mail-bl2nam02on0092.outbound.protection.outlook.com ([104.47.38.92]:59552 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964809AbeCHE7v (ORCPT ); Wed, 7 Mar 2018 23:59:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+qTeDtncnSuKzkBfbB+KGYk1CMEdZ7IK8yC85C2CtaQ=; b=bTvuRGgK0ZFrvbV6SiY9rP3wLRe72QLo+uTKkRefVKs5ymRp6tAhaLoj2P/kySApiCeyGuez4I7ybZiAacOT0L7vBcY7mFtUhPDQntU7WBJbFlLb2supb1fM1YnH+JtqJHwJDP0ncnpw/6lfYWmG+n25Ue8u5z0tbTYyXJN2N4A= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0920.namprd21.prod.outlook.com (52.132.132.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.3; Thu, 8 Mar 2018 04:59:48 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0588.008; Thu, 8 Mar 2018 04:59:48 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Lars-Peter Clausen , Stephen Boyd , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 64/67] clk: axi-clkgen: Correctly handle nocount bit in recalc_rate() Thread-Topic: [PATCH AUTOSEL for 4.14 64/67] clk: axi-clkgen: Correctly handle nocount bit in recalc_rate() Thread-Index: AQHTtpoIWry0wdBYgE6uK47WLUPgKQ== Date: Thu, 8 Mar 2018 04:58:01 +0000 Message-ID: <20180308045641.7814-64-alexander.levin@microsoft.com> References: <20180308045641.7814-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045641.7814-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0920;7:xRnyk6kJ31Z87yfkC6Plt/e/Ffb+8LNv3GgeuxJ+0mRNvFo99KG2+GgXF8fEZAat370oJM6eRsk68iXcUkwoRH+G0BwFo9L0tYoyTG8gt8XuggDBKYzSTITLliEzIdx4leLLyOlmT4IM2styJocX4BMWOY6x9vu4sRzA2/+Ds2PKYYtq8oBySQZaiMKS2N0wWoWIRymQHMfsZn0ZbNkAvy9hWwOFJifANJQP47cxeybIg16UITfXqjiE6AEOABSz;20:KrE77kGKpR2PKxm7MeoxkGqAnW/G/+X4j5umJ6+mK82QnQbAl+t4WAL69hWw80dd2WSouXgn1/jQ3mBNpMvSnUMz6geOpAfXF+WIlfxA0eYDk8iPFB3MR4ThpOjBHSMYPYy2ZZSgUjkj2X089k1wFSJSUc3Jh+o1b1WBfRl/TnA= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: bb443ae0-075e-4e9a-90cd-08d584b16b3e x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0920; x-ms-traffictypediagnostic: DM5PR2101MB0920: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231220)(944501244)(52105095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0920;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0920; x-forefront-prvs: 060503E79B x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(979002)(39860400002)(396003)(39380400002)(346002)(366004)(376002)(189003)(199004)(81156014)(81166006)(5250100002)(8936002)(54906003)(2501003)(305945005)(8676002)(107886003)(110136005)(97736004)(99286004)(6436002)(36756003)(316002)(72206003)(76176011)(14454004)(6486002)(7736002)(478600001)(10290500003)(186003)(22452003)(68736007)(105586002)(2950100002)(106356001)(102836004)(26005)(6506007)(86362001)(3660700001)(5660300001)(2906002)(10090500001)(1076002)(25786009)(2900100001)(53936002)(4326008)(66066001)(6512007)(6666003)(6116002)(3280700002)(3846002)(86612001)(22906009)(217873001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0920;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: +wYjhBKic8v8elPBSNYlwUC7tpnfkhcaCnt21tuFu2pE2urztKLz+sd7zJOR1HgRfQV2CDop+Ip+CQsITsTfV6w4hrAdNKSvp2e/DecyEt6mszgsA6ihdoGd7sT6JYOslzzLJODtEuvmxBhrP7bwFMKLlNMHmNudZIZDWo38hudLgr1Quts71DIoO88VeRReh3TydbcK82sv8dMul1xQh8gsap7JiLw1vpP5J/1GwoqD9xMIaVWkJLWNoonllAqv1qFqa0MPD75WqiJdJm7RJ3J4JSeFzBBwygD3kLwh/EmNTWRgyGuHzjDMsUL6gqK498C87u4LUTrfvOgQILv2xg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb443ae0-075e-4e9a-90cd-08d584b16b3e X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2018 04:58:01.0554 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0920 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lars-Peter Clausen [ Upstream commit 063578dc5f407f67d149133818efabe457daafda ] If the nocount bit is set the divider is bypassed and the settings for the divider count should be ignored and a divider value of 1 should be assumed. Handle this correctly in the driver recalc_rate() callback. While the driver sets up the part so that the read back dividers values yield the correct result the power-on reset settings of the part might not reflect this and hence calling e.g. clk_get_rate() without prior calls to clk_set_rate() will yield the wrong result. Signed-off-by: Lars-Peter Clausen Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/clk-axi-clkgen.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c index 5e918e7afaba..95a6e9834392 100644 --- a/drivers/clk/clk-axi-clkgen.c +++ b/drivers/clk/clk-axi-clkgen.c @@ -40,6 +40,10 @@ #define MMCM_REG_FILTER1 0x4e #define MMCM_REG_FILTER2 0x4f =20 +#define MMCM_CLKOUT_NOCOUNT BIT(6) + +#define MMCM_CLK_DIV_NOCOUNT BIT(12) + struct axi_clkgen { void __iomem *base; struct clk_hw clk_hw; @@ -315,12 +319,27 @@ static unsigned long axi_clkgen_recalc_rate(struct cl= k_hw *clk_hw, unsigned int reg; unsigned long long tmp; =20 - axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_1, ®); - dout =3D (reg & 0x3f) + ((reg >> 6) & 0x3f); + axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_2, ®); + if (reg & MMCM_CLKOUT_NOCOUNT) { + dout =3D 1; + } else { + axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_1, ®); + dout =3D (reg & 0x3f) + ((reg >> 6) & 0x3f); + } + axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_DIV, ®); - d =3D (reg & 0x3f) + ((reg >> 6) & 0x3f); - axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB1, ®); - m =3D (reg & 0x3f) + ((reg >> 6) & 0x3f); + if (reg & MMCM_CLK_DIV_NOCOUNT) + d =3D 1; + else + d =3D (reg & 0x3f) + ((reg >> 6) & 0x3f); + + axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB2, ®); + if (reg & MMCM_CLKOUT_NOCOUNT) { + m =3D 1; + } else { + axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB1, ®); + m =3D (reg & 0x3f) + ((reg >> 6) & 0x3f); + } =20 if (d =3D=3D 0 || dout =3D=3D 0) return 0; --=20 2.14.1