core.c (8f49a2fe8e6bccbd47555048def9cd08da220c74) | core.c (922ff0759a16299e24cacfc981ac07914d8f1826) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Generic OPP Interface 4 * 5 * Copyright (C) 2009-2010 Texas Instruments Incorporated. 6 * Nishanth Menon 7 * Romit Dasgupta 8 * Kevin Hilman --- 879 unchanged lines hidden (view full) --- 888 } 889 890 if (unlikely(!target_freq)) { 891 /* 892 * Some drivers need to support cases where some platforms may 893 * have OPP table for the device, while others don't and 894 * opp_set_rate() just needs to behave like clk_set_rate(). 895 */ | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Generic OPP Interface 4 * 5 * Copyright (C) 2009-2010 Texas Instruments Incorporated. 6 * Nishanth Menon 7 * Romit Dasgupta 8 * Kevin Hilman --- 879 unchanged lines hidden (view full) --- 888 } 889 890 if (unlikely(!target_freq)) { 891 /* 892 * Some drivers need to support cases where some platforms may 893 * have OPP table for the device, while others don't and 894 * opp_set_rate() just needs to behave like clk_set_rate(). 895 */ |
896 if (!_get_opp_count(opp_table)) { 897 ret = 0; 898 goto put_opp_table; 899 } | 896 if (!_get_opp_count(opp_table)) 897 return 0; |
900 901 if (!opp_table->required_opp_tables && !opp_table->regulators && 902 !opp_table->paths) { 903 dev_err(dev, "target frequency can't be 0\n"); 904 ret = -EINVAL; 905 goto put_opp_table; 906 } 907 908 ret = _set_opp_bw(opp_table, NULL, dev, true); 909 if (ret) | 898 899 if (!opp_table->required_opp_tables && !opp_table->regulators && 900 !opp_table->paths) { 901 dev_err(dev, "target frequency can't be 0\n"); 902 ret = -EINVAL; 903 goto put_opp_table; 904 } 905 906 ret = _set_opp_bw(opp_table, NULL, dev, true); 907 if (ret) |
910 goto put_opp_table; | 908 return ret; |
911 912 if (opp_table->regulator_enabled) { 913 regulator_disable(opp_table->regulators[0]); 914 opp_table->regulator_enabled = false; 915 } 916 917 ret = _set_required_opps(dev, opp_table, NULL); 918 goto put_opp_table; --- 10 unchanged lines hidden (view full) --- 929 freq = clk_round_rate(clk, target_freq); 930 if ((long)freq <= 0) 931 freq = target_freq; 932 933 old_freq = clk_get_rate(clk); 934 935 /* Return early if nothing to do */ 936 if (old_freq == freq) { | 909 910 if (opp_table->regulator_enabled) { 911 regulator_disable(opp_table->regulators[0]); 912 opp_table->regulator_enabled = false; 913 } 914 915 ret = _set_required_opps(dev, opp_table, NULL); 916 goto put_opp_table; --- 10 unchanged lines hidden (view full) --- 927 freq = clk_round_rate(clk, target_freq); 928 if ((long)freq <= 0) 929 freq = target_freq; 930 931 old_freq = clk_get_rate(clk); 932 933 /* Return early if nothing to do */ 934 if (old_freq == freq) { |
937 if (!opp_table->required_opp_tables && !opp_table->regulators && 938 !opp_table->paths) { 939 dev_dbg(dev, "%s: old/new frequencies (%lu Hz) are same, nothing to do\n", 940 __func__, freq); 941 ret = 0; 942 goto put_opp_table; 943 } | 935 dev_dbg(dev, "%s: old/new frequencies (%lu Hz) are same, nothing to do\n", 936 __func__, freq); 937 ret = 0; 938 goto put_opp_table; |
944 } 945 946 /* 947 * For IO devices which require an OPP on some platforms/SoCs 948 * while just needing to scale the clock on some others 949 * we look for empty OPP tables with just a clock handle and 950 * scale only the clk. This makes dev_pm_opp_set_rate() 951 * equivalent to a clk_set_rate() --- 339 unchanged lines hidden (view full) --- 1291 __func__, freq); 1292 } 1293 1294 /* Drop the reference taken by _find_opp_table() */ 1295 dev_pm_opp_put_opp_table(opp_table); 1296} 1297EXPORT_SYMBOL_GPL(dev_pm_opp_remove); 1298 | 939 } 940 941 /* 942 * For IO devices which require an OPP on some platforms/SoCs 943 * while just needing to scale the clock on some others 944 * we look for empty OPP tables with just a clock handle and 945 * scale only the clk. This makes dev_pm_opp_set_rate() 946 * equivalent to a clk_set_rate() --- 339 unchanged lines hidden (view full) --- 1286 __func__, freq); 1287 } 1288 1289 /* Drop the reference taken by _find_opp_table() */ 1290 dev_pm_opp_put_opp_table(opp_table); 1291} 1292EXPORT_SYMBOL_GPL(dev_pm_opp_remove); 1293 |
1299void _opp_remove_all_static(struct opp_table *opp_table) | 1294bool _opp_remove_all_static(struct opp_table *opp_table) |
1300{ 1301 struct dev_pm_opp *opp, *tmp; | 1295{ 1296 struct dev_pm_opp *opp, *tmp; |
1297 bool ret = true; |
|
1302 1303 mutex_lock(&opp_table->lock); 1304 | 1298 1299 mutex_lock(&opp_table->lock); 1300 |
1305 if (!opp_table->parsed_static_opps || --opp_table->parsed_static_opps) | 1301 if (!opp_table->parsed_static_opps) { 1302 ret = false; |
1306 goto unlock; | 1303 goto unlock; |
1304 } |
|
1307 | 1305 |
1306 if (--opp_table->parsed_static_opps) 1307 goto unlock; 1308 |
|
1308 list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) { 1309 if (!opp->dynamic) 1310 dev_pm_opp_put_unlocked(opp); 1311 } 1312 1313unlock: 1314 mutex_unlock(&opp_table->lock); | 1309 list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) { 1310 if (!opp->dynamic) 1311 dev_pm_opp_put_unlocked(opp); 1312 } 1313 1314unlock: 1315 mutex_unlock(&opp_table->lock); |
1316 1317 return ret; |
|
1315} 1316 1317/** 1318 * dev_pm_opp_remove_all_dynamic() - Remove all dynamically created OPPs 1319 * @dev: device for which we do this operation 1320 * 1321 * This function removes all dynamically created OPPs from the opp table. 1322 */ --- 1086 unchanged lines hidden (view full) --- 2409 if (error != -ENODEV) 2410 WARN(1, "%s: opp_table: %d\n", 2411 IS_ERR_OR_NULL(dev) ? 2412 "Invalid device" : dev_name(dev), 2413 error); 2414 return; 2415 } 2416 | 1318} 1319 1320/** 1321 * dev_pm_opp_remove_all_dynamic() - Remove all dynamically created OPPs 1322 * @dev: device for which we do this operation 1323 * 1324 * This function removes all dynamically created OPPs from the opp table. 1325 */ --- 1086 unchanged lines hidden (view full) --- 2412 if (error != -ENODEV) 2413 WARN(1, "%s: opp_table: %d\n", 2414 IS_ERR_OR_NULL(dev) ? 2415 "Invalid device" : dev_name(dev), 2416 error); 2417 return; 2418 } 2419 |
2417 _opp_remove_all_static(opp_table); | 2420 /* 2421 * Drop the extra reference only if the OPP table was successfully added 2422 * with dev_pm_opp_of_add_table() earlier. 2423 **/ 2424 if (_opp_remove_all_static(opp_table)) 2425 dev_pm_opp_put_opp_table(opp_table); |
2418 2419 /* Drop reference taken by _find_opp_table() */ 2420 dev_pm_opp_put_opp_table(opp_table); | 2426 2427 /* Drop reference taken by _find_opp_table() */ 2428 dev_pm_opp_put_opp_table(opp_table); |
2421 2422 /* Drop reference taken while the OPP table was added */ 2423 dev_pm_opp_put_opp_table(opp_table); | |
2424} 2425 2426/** 2427 * dev_pm_opp_remove_table() - Free all OPPs associated with the device 2428 * @dev: device pointer used to lookup OPP table. 2429 * 2430 * Free both OPPs created using static entries present in DT and the 2431 * dynamically added entries. 2432 */ 2433void dev_pm_opp_remove_table(struct device *dev) 2434{ 2435 _dev_pm_opp_find_and_remove_table(dev); 2436} 2437EXPORT_SYMBOL_GPL(dev_pm_opp_remove_table); | 2429} 2430 2431/** 2432 * dev_pm_opp_remove_table() - Free all OPPs associated with the device 2433 * @dev: device pointer used to lookup OPP table. 2434 * 2435 * Free both OPPs created using static entries present in DT and the 2436 * dynamically added entries. 2437 */ 2438void dev_pm_opp_remove_table(struct device *dev) 2439{ 2440 _dev_pm_opp_find_and_remove_table(dev); 2441} 2442EXPORT_SYMBOL_GPL(dev_pm_opp_remove_table); |