From patchwork Tue Mar 3 02:14:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11417077 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 644B5930 for ; Tue, 3 Mar 2020 02:21:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 352B22465E for ; Tue, 3 Mar 2020 02:21:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="jiYhgiOb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726946AbgCCCVO (ORCPT ); Mon, 2 Mar 2020 21:21:14 -0500 Received: from mail-eopbgr60081.outbound.protection.outlook.com ([40.107.6.81]:40120 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726859AbgCCCVO (ORCPT ); Mon, 2 Mar 2020 21:21:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IPzYBHPdXGSMSqx4u6cVFwf0TtvScRGhBJtSvQtEyuFlWMJgiTxPwO2pBZQIWxF3KkSk/WJINmVUgLG13wLMkI3Zn2HqhAPLW3yzBqHnuvGZHT/yWpvKnkySRT9jnnIsWr2sggbVOXNrTJ5HHMASJgimJUeZZks64BoGmYshO8zgujW4dxVKh8+dqWTXGZ2px8YiZ65guhHf96VhZoWN1QtQPUZnxW+bsnl2qD0oF4Wnfiy44kTmalJJIlNodFl2DFvEpm+2xp6j8QJbKtWBTec078ALGesErxCUjcAwfdM04glIVkRepNgQaRY5Vr9vsd0d6Yg9mjEgk6rehGfQhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FCrYa6UVr535yA6gud++b1JoFowyzn2rIiirvMltnyI=; b=lSuOTtgMHmS+vUWfD8WECYnB+ebKsfTEMc8gsy7w79zda6sWLvgLH+lScdjD/MJUJD9dw/Z9RnoCUJquBPvVumkMFgt4OmDkKZamQBSiI7FKcsJMB435MkOZ4bdPP9sfRdPWaGBESzqsbquWc9omW7uVOXjtK9IvWibRT22IuoElbXmNaNoMM+g9rrotWBI+pzqTa8EpZaqzYzb1RbKOGrcffXMswSZ9pe8HGqiZ0Vb7fQjRZC2HvdEgJZTNXhGNKkg0EBto+i1DbxTj1Lt4eLMbRV4b/pjwEWBeFyi3Ek5ema3fDEKz2f9qalF6Dccb6ZP0Hi/iQbACxc6895Qjxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FCrYa6UVr535yA6gud++b1JoFowyzn2rIiirvMltnyI=; b=jiYhgiObGBgNqwI6Vf93qUwMmKsUIl/OnvxMQ6tpl3hYLyem1yl0F5PP3+YlW+NyeKXQ9Yw0oOFHeEN1jfXNACxKNDLd+pVtJZB9gvYDuQCT8VZmvgsuzsOW1SUJrirg33rJPH2Aa5zy8NVq/ztpQJ4fWVY9U7duqSCzSKqtCHw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB5283.eurprd04.prod.outlook.com (20.176.215.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.19; Tue, 3 Mar 2020 02:21:10 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::91e2:17:b3f4:d422]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::91e2:17:b3f4:d422%3]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 02:21:09 +0000 From: peng.fan@nxp.com To: viresh.kumar@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, Anson.Huang@nxp.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org, Peng Fan Subject: [PATCH 1/3] ARM: dts: imx: add nvmem property for cpu0 Date: Tue, 3 Mar 2020 10:14:48 +0800 Message-Id: <1583201690-16068-2-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583201690-16068-1-git-send-email-peng.fan@nxp.com> References: <1583201690-16068-1-git-send-email-peng.fan@nxp.com> X-ClientProxiedBy: SG2P153CA0018.APCP153.PROD.OUTLOOK.COM (2603:1096::28) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2P153CA0018.APCP153.PROD.OUTLOOK.COM (2603:1096::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2814.1 via Frontend Transport; Tue, 3 Mar 2020 02:21:06 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ba817743-a1dd-4bbe-90e4-08d7bf198973 X-MS-TrafficTypeDiagnostic: AM0PR04MB5283:|AM0PR04MB5283: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:415; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(366004)(346002)(376002)(39860400002)(136003)(199004)(189003)(69590400007)(36756003)(66476007)(66556008)(66946007)(2616005)(956004)(52116002)(6486002)(6506007)(5660300002)(6512007)(6666004)(9686003)(16526019)(26005)(8676002)(186003)(478600001)(8936002)(7416002)(4326008)(2906002)(316002)(86362001)(81156014)(81166006);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB5283;H:AM0PR04MB4481.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RWmENS3oQVOPlJO5XPN0NAsDnEsKzcc8cafJsVDEpPsEScE/SXkAf4O22sekAEgUzZ2HQu/VZvlWjaFnhwF/E4OxinHtDQMXktYxW+dsV2SkF0ijYPhlpZzprxMMUkmcQchlu5ZmOfkHOscyCOnX3FXHPFaBhb1KxoTi6OY/hBXxmkomVpF/vfTB8qlugXbjR7MtY6lurnkeJQKDvFXhKPe243KmDCRBN5OyONU4JFbMiBzjrUVENfYKE5Q21gRSA3zosxfariP17ID6ikb8lRhvW/RSySKFsmQG/97gRCahpURjGj86U7DEudBgsvH/N8+nrQKQxV+hiN2c+RonZ5ZBnzGM0hm43OHbJSrO1NxlVr2msUyp7yfOixAekBeXWDRbXT/SRHEOiNDwkjmY6Jm+nolyx0FAfGBx2MS+5klHHfAsTiFUxsZAPzCqvByKtkAlYFaGIsZ2mqSqq6Yjpvg4Q0v/oas+ebjAtXKQi92wS9Am4u9LLbe6hhydbgAO X-MS-Exchange-AntiSpam-MessageData: kTgzw8nsnLVuoKrNsVKYyKuTPChXAn/FVYAfg9kzaJYwdx882e4MgXBG+7TyR+C6lyEw/b1wyzskMS4X/0H4R5+DNoMMvpGxkDXEBhdjZbAdEEH7MJWaEbbsbXGCDDJr3A2GyCoKBEnPp08DEub8/Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba817743-a1dd-4bbe-90e4-08d7bf198973 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 02:21:09.9483 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: o2b3j1lItYKk+lQ87kNKpYAUBhWQEzC8P7EOnLGMdsprTVp+DI17xEea+QsYuID9Z7Yr29oEXyRnnAt8o/5/vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5283 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Peng Fan Add nvmem related property for cpu0, then nvmem API could be used to read cpu speed grading to avoid directly read OCOTP registers mapped which could not handle defer probe. Signed-off-by: Peng Fan --- arch/arm/boot/dts/imx6dl.dtsi | 2 ++ arch/arm/boot/dts/imx6q.dtsi | 2 ++ arch/arm/boot/dts/imx6qdl.dtsi | 7 +++++++ arch/arm/boot/dts/imx6sl.dtsi | 9 +++++++++ arch/arm/boot/dts/imx6sll.dtsi | 6 ++++++ arch/arm/boot/dts/imx6sx.dtsi | 6 ++++++ 6 files changed, 32 insertions(+) diff --git a/arch/arm/boot/dts/imx6dl.dtsi b/arch/arm/boot/dts/imx6dl.dtsi index 4b3a128d9260..055f1d875bac 100644 --- a/arch/arm/boot/dts/imx6dl.dtsi +++ b/arch/arm/boot/dts/imx6dl.dtsi @@ -44,6 +44,8 @@ arm-supply = <®_arm>; pu-supply = <®_pu>; soc-supply = <®_soc>; + nvmem-cells = <&cpu_speed_grade>; + nvmem-cell-names = "speed_grade"; }; cpu@1 { diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi index 0fad13f9d336..d3ba9d4a1290 100644 --- a/arch/arm/boot/dts/imx6q.dtsi +++ b/arch/arm/boot/dts/imx6q.dtsi @@ -49,6 +49,8 @@ arm-supply = <®_arm>; pu-supply = <®_pu>; soc-supply = <®_soc>; + nvmem-cells = <&cpu_speed_grade>; + nvmem-cell-names = "speed_grade"; }; cpu1: cpu@1 { diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi index 70fb8b56b1d7..982f546b0b89 100644 --- a/arch/arm/boot/dts/imx6qdl.dtsi +++ b/arch/arm/boot/dts/imx6qdl.dtsi @@ -1165,6 +1165,13 @@ compatible = "fsl,imx6q-ocotp", "syscon"; reg = <0x021bc000 0x4000>; clocks = <&clks IMX6QDL_CLK_IIM>; + + #address-cells = <1>; + #size-cells = <1>; + + cpu_speed_grade: speed-grade@10 { + reg = <0x10 4>; + }; }; tzasc@21d0000 { /* TZASC1 */ diff --git a/arch/arm/boot/dts/imx6sl.dtsi b/arch/arm/boot/dts/imx6sl.dtsi index c8ec46fe8302..de943341e4f2 100644 --- a/arch/arm/boot/dts/imx6sl.dtsi +++ b/arch/arm/boot/dts/imx6sl.dtsi @@ -74,6 +74,8 @@ arm-supply = <®_arm>; pu-supply = <®_pu>; soc-supply = <®_soc>; + nvmem-cells = <&cpu_speed_grade>; + nvmem-cell-names = "speed_grade"; }; }; @@ -953,6 +955,13 @@ compatible = "fsl,imx6sl-ocotp", "syscon"; reg = <0x021bc000 0x4000>; clocks = <&clks IMX6SL_CLK_OCOTP>; + + #address-cells = <1>; + #size-cells = <1>; + + cpu_speed_grade: speed-grade@10 { + reg = <0x10 4>; + }; }; audmux: audmux@21d8000 { diff --git a/arch/arm/boot/dts/imx6sll.dtsi b/arch/arm/boot/dts/imx6sll.dtsi index 797f850492fe..6b7fb3cec9f6 100644 --- a/arch/arm/boot/dts/imx6sll.dtsi +++ b/arch/arm/boot/dts/imx6sll.dtsi @@ -72,6 +72,8 @@ <&clks IMX6SLL_CLK_PLL1_SYS>; clock-names = "arm", "pll2_pfd2_396m", "step", "pll1_sw", "pll1_sys"; + nvmem-cells = <&cpu_speed_grade>; + nvmem-cell-names = "speed_grade"; }; }; @@ -791,6 +793,10 @@ reg = <0x021bc000 0x4000>; clocks = <&clks IMX6SLL_CLK_OCOTP>; + cpu_speed_grade: speed-grade@10 { + reg = <0x10 4>; + }; + tempmon_calib: calib@38 { reg = <0x38 4>; }; diff --git a/arch/arm/boot/dts/imx6sx.dtsi b/arch/arm/boot/dts/imx6sx.dtsi index e47d346a3543..63aa19d81b42 100644 --- a/arch/arm/boot/dts/imx6sx.dtsi +++ b/arch/arm/boot/dts/imx6sx.dtsi @@ -87,6 +87,8 @@ "pll1_sw", "pll1_sys"; arm-supply = <®_arm>; soc-supply = <®_soc>; + nvmem-cells = <&cpu_speed_grade>; + nvmem-cell-names = "speed_grade"; }; }; @@ -1058,6 +1060,10 @@ reg = <0x021bc000 0x4000>; clocks = <&clks IMX6SX_CLK_OCOTP>; + cpu_speed_grade: speed-grade@10 { + reg = <0x10 4>; + }; + tempmon_calib: calib@38 { reg = <0x38 4>; }; From patchwork Tue Mar 3 02:14:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11417079 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F3F5174A for ; Tue, 3 Mar 2020 02:21:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69A8D21D56 for ; Tue, 3 Mar 2020 02:21:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="RUKUWUQr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726968AbgCCCVS (ORCPT ); Mon, 2 Mar 2020 21:21:18 -0500 Received: from mail-eopbgr70080.outbound.protection.outlook.com ([40.107.7.80]:46926 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727126AbgCCCVS (ORCPT ); Mon, 2 Mar 2020 21:21:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j1AQFoueGloaMmptVBsM77jo5YGEkdxQrMcQjwpNOZTHlOL68l3xns/7UqpZBGi2GVudlAtIvdHnPdAjDfqcXZQY7cSwaRvF0Lx/Izj9Pgv9DBolI9NtIR0ptZyVuZ/dH1UJx/faoJ8kqjjlrDZ4UYfqu8+e7x3xEjrK2MVoX1f0G64wTVpSpE6YstwWz5/UIPjC+C1YiJpvE6LH2a7ku0ISWg2uBHhkSOwxNhZtKgYvva2XinLJRlk7mUgMgJttdXWrqc1zJTwCtij4TMKlkFPwQQiupt7+wnKN6rANJXlVNmKJ0y8zM+IQGNgDNEkbVbYEGI/UsIs2B2Au9tP9Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yNlA0OCnPTptS4fdXh7mXivtjAf/lGmp6g0bhe4T8Bk=; b=MML0i71p3f64Q46mmN0fEato2WKXgo+/BEib45zUAKXvuGtllZIRWMOIukRmmAO2S2OpQnP6zbhG0ag86tpm14yvrTSAP1hQ4he6mSNG9p0kpeqRSuYeObj62UxPrav0xHi3QrE24vw/oM+Z2Y26oUrpDyGh6SMxlGexVJdtlqCtxiW1gmuf+Zg171aDV+EVgKcKFaowr9X3V7m1n7K4QjbF31e3f3dfA++Ygt132VHlWFTKkidS+dxyKbuYencaVt73jX9rTxQwO6Nx/DYllIvdMvC0vL1TwbklEAt/zAh/miKfY6Gu+W/KvbmQYRypl709Zh4cp49FEb3/F/75zg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yNlA0OCnPTptS4fdXh7mXivtjAf/lGmp6g0bhe4T8Bk=; b=RUKUWUQrhzkA5DZt9arIqtvUK+tbnTbb7ioleOuDKVrDT/ftZuGRjANaKfaPXRPtPtsm//4PXDlYc5Bh99ymvK7xWyrfzbvsfEls5jxHsIG187BbZYrO9al9C7HgKe+eTpRgIqW4VCauvnAs7ZeImHQMOM252tZ7FFUyJhcY1ec= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB5283.eurprd04.prod.outlook.com (20.176.215.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.19; Tue, 3 Mar 2020 02:21:14 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::91e2:17:b3f4:d422]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::91e2:17:b3f4:d422%3]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 02:21:14 +0000 From: peng.fan@nxp.com To: viresh.kumar@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, Anson.Huang@nxp.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org, Peng Fan Subject: [PATCH 2/3] cpufreq: imx6q: fix error handling Date: Tue, 3 Mar 2020 10:14:49 +0800 Message-Id: <1583201690-16068-3-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583201690-16068-1-git-send-email-peng.fan@nxp.com> References: <1583201690-16068-1-git-send-email-peng.fan@nxp.com> X-ClientProxiedBy: SG2P153CA0018.APCP153.PROD.OUTLOOK.COM (2603:1096::28) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2P153CA0018.APCP153.PROD.OUTLOOK.COM (2603:1096::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2814.1 via Frontend Transport; Tue, 3 Mar 2020 02:21:10 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 21d5fd73-d1ff-4b71-6050-08d7bf198be2 X-MS-TrafficTypeDiagnostic: AM0PR04MB5283:|AM0PR04MB5283: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(366004)(346002)(376002)(39860400002)(136003)(199004)(189003)(69590400007)(36756003)(66476007)(66556008)(66946007)(2616005)(956004)(52116002)(6486002)(6506007)(5660300002)(6512007)(6666004)(9686003)(16526019)(26005)(8676002)(186003)(478600001)(8936002)(7416002)(4326008)(2906002)(316002)(86362001)(81156014)(81166006)(32563001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB5283;H:AM0PR04MB4481.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tF9eEmdmuFXp4FsiK2RDX6TW+4CX/ygDW3hPFZ4FMgzQJcpOx4SH4eb8ed/wCTVHoOuA/hfovWTL8/PTBvc0HT0SlZp8bZArSUD+/ja8f7iy5yRfSq6PJGqT8dpLJWjTlOZB7JnQSbNbncA9P0q+CNTiB5x3p1qnf8AjX/rAFO1gDZAgAJXVyZdh9V3KBkCofno3CGyUyQD3JtZmqZgBNSh+ux3VeSESTzd4P/s/2xMUyZHO76uT+YyHE1QC6wWSY0BVtePjef+CPKUxZh2QU6HvhHYshq9mvK9aZe0J5quMQ53LypZOF82zGW6OqWNKa1oo0yTZNiHSQVcYtwmYyf5gCTqwMLRP29PDdrmpzl8Ia3egM5zIfxD/C7vbDjKfvs0zNhYwtvuparawCG5N1amIL5iviBpm8RuNWkAw0aUZxgR1Gh7azGFKM87Gv2VnkWi/8JelIVHyqNZYmV5AL5PEYDdw/Txd5rO8OvUmVzDYzoiiuZFXqTeY4QU9DXrrBwfxTtkP3j+trKnroheELA== X-MS-Exchange-AntiSpam-MessageData: TL8uyB9Fwa8c+3urxkcJroY++al98I4rQsqujmcjZbgT1s//luJdhdNufrnLozco9pNKFC2mEwAc99QexHXW3fCEqxeSF6iLjNmlqvKc9HEYM4b3CGnHVa1l/D2iOrF+rLH46NjLRuzwAMsfgcQiJg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21d5fd73-d1ff-4b71-6050-08d7bf198be2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 02:21:14.1968 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XbLSbltwPoe93/gjqNC6q4B8z1LLGkjrkyA0VAeWgFY5B8AqXPasb0lHoXRImyotBCaIVLebAaXzDHoc0XmVPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5283 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Peng Fan When speed checking failed, direclty jumping to put_node label is not correct. Need jump to out_free_opp to avoid resources leak. Fixes: 2733fb0d0699 ("cpufreq: imx6q: read OCOTP through nvmem for imx6ul/imx6ull") Signed-off-by: Peng Fan --- drivers/cpufreq/imx6q-cpufreq.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 648a09a1778a..b634a73d1f8f 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -378,23 +378,24 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) goto put_reg; } + /* Because we have added the OPPs here, we must free them */ + free_opp = true; + if (of_machine_is_compatible("fsl,imx6ul") || of_machine_is_compatible("fsl,imx6ull")) { ret = imx6ul_opp_check_speed_grading(cpu_dev); if (ret) { if (ret == -EPROBE_DEFER) - goto put_node; + goto out_free_opp; dev_err(cpu_dev, "failed to read ocotp: %d\n", ret); - goto put_node; + goto out_free_opp; } } else { imx6q_opp_check_speed_grading(cpu_dev); } - /* Because we have added the OPPs here, we must free them */ - free_opp = true; num = dev_pm_opp_get_opp_count(cpu_dev); if (num < 0) { ret = num; From patchwork Tue Mar 3 02:14:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11417083 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC58D109A for ; Tue, 3 Mar 2020 02:21:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1DDA24677 for ; Tue, 3 Mar 2020 02:21:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="pjshkVxP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727085AbgCCCVX (ORCPT ); Mon, 2 Mar 2020 21:21:23 -0500 Received: from mail-eopbgr70051.outbound.protection.outlook.com ([40.107.7.51]:27328 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726979AbgCCCVW (ORCPT ); Mon, 2 Mar 2020 21:21:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B5jjpqgXLVPZSfrjZiRYHtdlKXDh4zzTdOX0jXNmNYSNWL6BYobaHn71wd5VrdrCyf8VMRnWCTJ9MISg8Q/qJvcIm1zjqSb5ypexCl8Rl5dsUNCyMqX0qkpdSKT3G0F759imPipWpN2VjhII6lgQJwC0fU0jREBEnnGMl221ALshmJ5XKRzUD4scUHKiyMV0IxmUs9wEDJ5xImvW3Mj/nrqst4XpwKEIa94HjGNagtnwk6PRlk3Fg669RyhsXJUlKj4KQFbqOe/xFLpTtpYyHJWU28cLHGVs1SZ+ddl4EpULfwzHtzj70mfFimeW/sKhviO6z3o4ZVznOT9yOhATnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dcIjfMNSszkRgswGErQhD6UiZ9vloNM9seQptmVWLBE=; b=ZaYdKIhXu5F0jBIoqWGWXrt2q5d2Y9jo0Z2Kr9d5rUwalCxUrXyDH01RzpKhiOhOiTFrZafxD0wXGfCfLQPKcF1jm4LNJcnwgde5qrA3RNbupQ0aHVYSWbfc1vL+SlM7g0U9jIoPjwaw+VCIt2R+Z7hSg6cCAzlaNlIx5Lp+9tvFtYc1wVjD5aF5y+hmNv96sjcgfPUnS14C8C8Xytx7RIB5nfi5LLZKoQNzUjWgUia3rfkBGkUUIaLGL9+0RV98f+7liKro9kCkYHnyMPQ1OYbxiuR9ZiTw4dNbj8WdxeX4xqSXyTX1G0wPTUPvTkS/8PYrMb6j6+h3mpmbJB2/zA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dcIjfMNSszkRgswGErQhD6UiZ9vloNM9seQptmVWLBE=; b=pjshkVxPQ0kkoZi74PVVLOExb7Q6ezTBudf3rEGCVqriWCwo4Y3lYQRBk/llvmYu/B82VTljNeNknP28rhqXGqE9DeRMCX0OtCo1HYkU4OoCVh11VQwmC1gCqiSW7hlf1/B9dO5N6TIA74g8P6OAi3P7gwRV5nZrLgLOI04YSBI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB5283.eurprd04.prod.outlook.com (20.176.215.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.19; Tue, 3 Mar 2020 02:21:18 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::91e2:17:b3f4:d422]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::91e2:17:b3f4:d422%3]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 02:21:18 +0000 From: peng.fan@nxp.com To: viresh.kumar@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, Anson.Huang@nxp.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org, Peng Fan Subject: [PATCH 3/3] cpufreq: imx6q: read OCOTP through nvmem for imx6q Date: Tue, 3 Mar 2020 10:14:50 +0800 Message-Id: <1583201690-16068-4-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1583201690-16068-1-git-send-email-peng.fan@nxp.com> References: <1583201690-16068-1-git-send-email-peng.fan@nxp.com> X-ClientProxiedBy: SG2P153CA0018.APCP153.PROD.OUTLOOK.COM (2603:1096::28) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2P153CA0018.APCP153.PROD.OUTLOOK.COM (2603:1096::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2814.1 via Frontend Transport; Tue, 3 Mar 2020 02:21:14 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e3be7ea0-eb06-4329-91c4-08d7bf198e6b X-MS-TrafficTypeDiagnostic: AM0PR04MB5283:|AM0PR04MB5283: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(366004)(346002)(376002)(39860400002)(136003)(199004)(189003)(69590400007)(36756003)(66476007)(66556008)(66946007)(2616005)(956004)(52116002)(6486002)(6506007)(5660300002)(6512007)(6666004)(9686003)(16526019)(26005)(8676002)(186003)(478600001)(8936002)(7416002)(4326008)(2906002)(316002)(86362001)(81156014)(81166006)(32563001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB5283;H:AM0PR04MB4481.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O6eK7zhP6iWYlqwTMXS+vzboxj9j+GpLTuL/pjked1/XeW9CYDWUZyGQWeK0DRWfUPOdB5y9q1oKs15DpNeXVlUSkbdVh8ygxH7d0C96BoiGc2pHAHTb8KM4PsDYr6/BgTuLEdLZwHjJPYf+C6XpwANIeqcsYWMwcCwo+eI7vVhDTT5gjXPoD0gmpuRc27WAVx01xvcHobcHlR+lzMdzF+2zBJWKpekCuKE9YNsQM/iECb0Z4rTv7ykd+SBJcHMpAgo8bZ2NI8NbL2XskJvU5JAXf2oHtAOtYtvWGH9yG+ksh7ZMYQG8zfxklevN9RDzTR8JSaBpv3uC0KjmS0ULSl2HxBlGCfobLL7ZKQS4siTTjSttgnP9+4vR79LDVCQAclskvSzBfbLsNdzhWrG34l1KeroHP0zTcWxmHT8xh7hC/wh9Ig3D80lycqrXMeJFzs2xRiGZUkSBCxnn1mcMZ904uHN2973jF6QiKQ4RdXaEU9Bf5bCVnoZGkJXhRQEZk4LpKH22S1gY/jMAJxYRfQ== X-MS-Exchange-AntiSpam-MessageData: zDmUIeL/awM2hv+j0PEO0XxclT8IWI5UY1qYdkArbQlWrAcoJd/CDdRiVaf8jahFdnd90yoE9UbhEDum0qlE7aRTHJsXOOvpNStpB73FJL7NwTpaSMvN4AokUg7ue9WLlFBGJ9aobEzsS8ZVhPjsKw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3be7ea0-eb06-4329-91c4-08d7bf198e6b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 02:21:18.2995 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: E4s41txjSufHWlnKH57eHASCOVSzEyIjDbO83pix35WQeK/t1jnZVq5Xmi+bQ6TfY7OAVUCZQ8YtCri10WKIlA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5283 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Peng Fan Directly accessing OCOTP registers should be avoided, because it could not handle OCOTP clks and could not handle defer proper. With nvmem API, it is safe to access OCOTP registers. To make sure old dtb could work, the original code still kept. Signed-off-by: Peng Fan --- drivers/cpufreq/imx6q-cpufreq.c | 67 +++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index b634a73d1f8f..183c03a44187 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -216,31 +216,41 @@ static struct cpufreq_driver imx6q_cpufreq_driver = { #define OCOTP_CFG3_SPEED_996MHZ 0x2 #define OCOTP_CFG3_SPEED_852MHZ 0x1 -static void imx6q_opp_check_speed_grading(struct device *dev) +static int imx6q_opp_check_speed_grading(struct device *dev) { struct device_node *np; void __iomem *base; u32 val; + int ret; - np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ocotp"); - if (!np) - return; + if (of_find_property(dev->of_node, "nvmem-cells", NULL)) { + ret = nvmem_cell_read_u32(dev, "speed_grade", &val); + if (ret) + return ret; + } else { + np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ocotp"); + if (!np) + return -ENOENT; - base = of_iomap(np, 0); - if (!base) { - dev_err(dev, "failed to map ocotp\n"); - goto put_node; + base = of_iomap(np, 0); + of_node_put(np); + if (!base) { + dev_err(dev, "failed to map ocotp\n"); + return -EFAULT; + } + + /* + * SPEED_GRADING[1:0] defines the max speed of ARM: + * 2b'11: 1200000000Hz; + * 2b'10: 996000000Hz; + * 2b'01: 852000000Hz; -- i.MX6Q Only, exclusive with 996MHz. + * 2b'00: 792000000Hz; + * We need to set the max speed of ARM according to fuse map. + */ + val = readl_relaxed(base + OCOTP_CFG3); + iounmap(base); } - /* - * SPEED_GRADING[1:0] defines the max speed of ARM: - * 2b'11: 1200000000Hz; - * 2b'10: 996000000Hz; - * 2b'01: 852000000Hz; -- i.MX6Q Only, exclusive with 996MHz. - * 2b'00: 792000000Hz; - * We need to set the max speed of ARM according to fuse map. - */ - val = readl_relaxed(base + OCOTP_CFG3); val >>= OCOTP_CFG3_SPEED_SHIFT; val &= 0x3; @@ -257,9 +267,8 @@ static void imx6q_opp_check_speed_grading(struct device *dev) if (dev_pm_opp_disable(dev, 1200000000)) dev_warn(dev, "failed to disable 1.2GHz OPP\n"); } - iounmap(base); -put_node: - of_node_put(np); + + return 0; } #define OCOTP_CFG3_6UL_SPEED_696MHZ 0x2 @@ -384,16 +393,16 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) if (of_machine_is_compatible("fsl,imx6ul") || of_machine_is_compatible("fsl,imx6ull")) { ret = imx6ul_opp_check_speed_grading(cpu_dev); - if (ret) { - if (ret == -EPROBE_DEFER) - goto out_free_opp; - - dev_err(cpu_dev, "failed to read ocotp: %d\n", - ret); - goto out_free_opp; - } } else { - imx6q_opp_check_speed_grading(cpu_dev); + ret = imx6q_opp_check_speed_grading(cpu_dev); + } + if (ret) { + if (ret == -EPROBE_DEFER) + goto out_free_opp; + + dev_err(cpu_dev, "failed to read ocotp: %d\n", + ret); + goto out_free_opp; } num = dev_pm_opp_get_opp_count(cpu_dev);