Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932540AbdHWQKx (ORCPT ); Wed, 23 Aug 2017 12:10:53 -0400 Received: from mail-cys01nam02on0078.outbound.protection.outlook.com ([104.47.37.78]:63852 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932182AbdHWQKt (ORCPT ); Wed, 23 Aug 2017 12:10:49 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Dong Aisheng To: CC: , , , , , , , , , Dong Aisheng Subject: [PATCH 5/7] PM / OPP: Add dev_pm_opp_get_cur_clk() Date: Thu, 24 Aug 2017 00:10:08 +0800 Message-ID: <1503504610-12880-6-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503504610-12880-1-git-send-email-aisheng.dong@nxp.com> References: <1503504610-12880-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131479782340890243;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39860400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(97736004)(50466002)(48376002)(2351001)(33646002)(356003)(68736007)(7416002)(5003940100001)(305945005)(6916009)(36756003)(106466001)(54906002)(4326008)(105606002)(189998001)(2906002)(77096006)(110136004)(53936002)(50986999)(76176999)(81166006)(47776003)(8676002)(626005)(6666003)(50226002)(8656003)(8936002)(498600001)(104016004)(85426001)(5660300001)(2950100002)(86362001)(81156014);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR03MB2261;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11OLC008;1:vNFA5p+Fmyz4kbcK1yc0ZUy7/uKnvfCPa7IzM9+cSdW1G09gEgzkrkZFCcnlZjLyPHhzhpZaJRcbk7ynKQHq6ETX7QoMCFfrldwcSupxqBFVhbJsrHg0mxFzV0OBEvC2 MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6714b276-4d4d-4795-ad26-08d4ea417c07 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603186)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CO2PR03MB2261; X-Microsoft-Exchange-Diagnostics: 1;CO2PR03MB2261;3:bBv+/XjnUJ5XaLOaarsdtq1N1CiQDz6TL66k9V/XS2QU3E2LmECZ6kKocjL46jzT3JRerY/cCKrJjGH5VPJ6NWeZK2xLHQoVb3+Az8TR6UXgMRkj+eUC0jnv59aWdQ5W4H0H1yURqifXdbrojkYqutLCEn92QpMCVur1YWmPL9yqQrZo/LHKNQQCH0Y/9lEPfXG+EqWH7PePZt50G//iubZy3d3X4TEW6EAks/BgcXr7ZI9GYO1gkEbofXThlN/fyso1UmWPV0fkCrBTFwceU4he7POwppDIygjPIsjauH4l+PBszUxXD8zhEkQkLFHOqskjNgSgHHg3pDJFE6WycVKNzORvfjbKajw3dhE0seo=;25:+d8XO78tjPVUzPApL8VrfDhOaevR3EuZKOH2c5d4homDa3cTsn0Ha9T+O5OUExEedvjr+sr5eDfyrzWZXxG+oqtJ8XjJej3hNAg6GD6u23F/fUq6XuNZfBPFuK4czZ2SDp9FKgGMPbkUsCyGrvo6Lu2bTLGcg2Y0hgSeu8MSwo9inxL+tlER7sDuor6uYhChFcPg0SI2jF0EneksaxDuel7oS4Tt1T7OHrG6W6CRMZpKRJoCvOOVLrozp061Z89O+Mn9myy2s1bGZHKCFX2oX7CkP7Nj23lXPLPIl6JT1HMDwWaXpyZPmzVE82vXZADYIBpWEreeQPS6lLgGobrlxA== X-MS-TrafficTypeDiagnostic: CO2PR03MB2261: X-Microsoft-Exchange-Diagnostics: 1;CO2PR03MB2261;31:+XTlaMBdevVazYYUwXtHXvtccvpGld+YxDqQRFOrRqUYDHm5Xd5WF5jvwZ8XYXHW5+9q9WBFTAdHOXf4f3Seb5V3rfb7HQDY5uqJbf3C3npBwrt8y61nXhp+i7THhQdy85EgKjXZFlE1LuECAfS7JrD7aB9M/xsD9Lvo48nYVMzSVGVy1TwKSQdCcKFbB0GlRRr7IkUvpctSD01Fhqt059VRZ5xLc/l2F+SZ2Ub5XlE=;4:t+NJs/q4D+9Riim9nxcsMv6Qqm4D0BXGoFhP3OL7tYnzaehMoUDPjIUHFxhm9mDUq5pIPUpnUxQASK7W3Y2mNMtHma7G/rQmEYRfYfreQOBqEKk68GCoPDYIwev1XFRQ2qTSXyhcCIrIxV2NQtOUlntZlZp1M5MGj2LomR/ixgETPmdbLUn+Gm20Z1YZcUKix4OrXCIDVgxc+Gpks+wxYQ5tQCyRvoptWmLskp73sVSQmmqpc3qYbOaHq0RRHrOxhjpChWRjHOKzb2safHynF9wk09qW3n/PT88MN8af5z7phBjK2KHD3RUvoGuU5ucJpXTlMo1SUeXdjFwHtBZfCg== X-Exchange-Antispam-Report-Test: UriScan:(31051911155226)(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(13018025)(8121501046)(5005006)(13016025)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6096035)(20161123559100)(20161123563025)(20161123556025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123561025)(20161123565025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CO2PR03MB2261;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CO2PR03MB2261; X-Forefront-PRVS: 040866B734 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CO2PR03MB2261;23:r4JH4796PRQ2d3qe322I8AvkTdAmn2uA+SmDRU4xg?= =?us-ascii?Q?IAZI4v+v9UYmV5rsLdxcw+SRN6+qMip4Fy3k9wfotAV217cGojMq8pXVi9E3?= =?us-ascii?Q?E5bkScYLLfNpbX8QrpbeTtVouDeCRNWQQs/Jdice7nRGDSbQlSsG9CQQGV9D?= =?us-ascii?Q?dv1ngiP8+EXm2Tg5fvJQPTt9KGJmqv55SVwpnQrRZtftnLKEm3iilG+kSoGg?= =?us-ascii?Q?ahLVI3YRb7ShYH0rr5nREcB8MZ4L7jV8wOrT4Mj0hE6muaMBChOQONG8vVzg?= =?us-ascii?Q?YKJTY2U/d2MNRHc7yTgsfJNKYRdRJVI52crnXfdC2imYSHeGLLv7aRtUcgUV?= =?us-ascii?Q?Oqtgo/jjhJTY02ORdzSUx0QurMZLvT56dXZ35lkR7CLMnlmV59d5e38TJoVt?= =?us-ascii?Q?z9cyvnK5eonX89ZZUp1KOA6b+D34vB1bJl8Dd8Z140wAsz5sONl+34oG8pVl?= =?us-ascii?Q?olhYM0hZ9aDaXft4TIW109rh0JHQ2l+J34LM4Otv2jEi0c4EE5Fh5JwMCC7E?= =?us-ascii?Q?ekRbij1tmAs4ov0WfELqlRSma+DJuimL0AlmJra1Fr/DICh2KKzD/J2unT35?= =?us-ascii?Q?pxmd0GhH//21PTa30zFDTWAJHA6hU8ZDB4erMt4BeUvjgmvndcyPUjHUXOdO?= =?us-ascii?Q?SdTXknJ7o5c9WSI2y8ZuWMXhwdeo7gEqIHbTThlz3FvHQA2oNnPRqeZH7UGf?= =?us-ascii?Q?PAe3zefPYNdzPI08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==;24:Flb1GASxv96+iLqAGgaTTOIh/m0ZjHa7bvLqSzsT8V7hrKzyiZlr5byrD49y84ZJNIKdgIVB10Z4/ZojV7KwO9jgTJ4jo/fh6Zy5geY+6CU=;7:9rXbRdoPuUm0ZZ3FfhFpHlZEx2oJ+k5vAWFAcqvLAXgYWq644dGTuuPdrxrlE2MEf6DC3jTGoc9F9oFnQBgZRPrST5vw+DlkYftWd5vFqfdPL+SpS46wluzLaRlpo29qlhTtuJIMtGS/hMqJlTWlD9D47jWyM1Y1P0slNxdPYhAgEsss3CHpwC2QAh6WnxoGF74jsBpnK1YLqnF1hju38HMkzQE6ENjYcSgb2iTe58U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 16:10:33.9174 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR03MB2261 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2806 Lines: 77 User may need to know the current OPP clock for updating policy clk accordingly. e.g. cpufreq policy clock. This function does the work. Cc: Viresh Kumar Cc: Nishanth Menon Cc: Stephen Boyd Cc: "Rafael J. Wysocki" Signed-off-by: Dong Aisheng --- drivers/base/power/opp/core.c | 29 +++++++++++++++++++++++++++++ include/linux/pm_opp.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index d4656cc..a425f98 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -1441,6 +1441,35 @@ void dev_pm_opp_put_clkname(struct opp_table *opp_table) EXPORT_SYMBOL_GPL(dev_pm_opp_put_clkname); /** + * dev_pm_opp_get_cur_clk() - Get the current OPP clock the device is running + * @dev: device for which we do this operation + * + * This must be called before any OPPs are initialized for the device. + */ +struct clk *dev_pm_opp_get_cur_clk(struct device *dev) +{ + struct opp_table *opp_table; + int ret; + + opp_table = dev_pm_opp_get_opp_table(dev); + if (!opp_table) + return ERR_PTR(-ENOMEM); + + if (IS_ERR(opp_table->cur_clk)) { + ret = -ENODEV; + goto err; + } + + return opp_table->cur_clk; + +err: + dev_pm_opp_put_opp_table(opp_table); + + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_cur_clk); + +/** * dev_pm_opp_register_set_opp_helper() - Register custom set OPP helper * @dev: Device for which the helper is getting registered. * @set_opp: Custom set OPP helper. diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index a8b1e4d..e20d090 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -123,6 +123,7 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev, const char * con void dev_pm_opp_put_regulators(struct opp_table *opp_table); struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char * name); void dev_pm_opp_put_clkname(struct opp_table *opp_table); +struct clk *dev_pm_opp_get_cur_clk(struct device *dev); struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); void dev_pm_opp_register_put_opp_helper(struct opp_table *opp_table); struct opp_table *dev_pm_opp_register_set_clk_helper(struct device *dev, int (*set_clk)(struct device *dev, struct clk *clk, @@ -279,6 +280,8 @@ static inline struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const static inline void dev_pm_opp_put_clkname(struct opp_table *opp_table) {} +static inline struct clk *dev_pm_opp_get_cur_clk(struct device *dev) {} + static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) { return -ENOTSUPP; -- 2.7.4