Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc/tegra: Migrate to dev_pm_opp_set_config()

The OPP core now provides a unified API for setting all configuration
types, i.e. dev_pm_opp_set_config().

Lets start using it.

Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

+35 -25
+35 -25
drivers/soc/tegra/common.c
··· 107 107 { 108 108 u32 hw_version; 109 109 int err; 110 + /* 111 + * The clk's connection id to set is NULL and this is a NULL terminated 112 + * array, hence two NULL entries. 113 + */ 114 + const char *clk_names[] = { NULL, NULL }; 115 + struct dev_pm_opp_config config = { 116 + /* 117 + * For some devices we don't have any OPP table in the DT, and 118 + * in order to use the same code path for all the devices, we 119 + * create a dummy OPP table for them via this. The dummy OPP 120 + * table is only capable of doing clk_set_rate() on invocation 121 + * of dev_pm_opp_set_rate() and doesn't provide any other 122 + * functionality. 123 + */ 124 + .clk_names = clk_names, 125 + }; 126 + 127 + if (of_machine_is_compatible("nvidia,tegra20")) { 128 + hw_version = BIT(tegra_sku_info.soc_process_id); 129 + config.supported_hw = &hw_version; 130 + config.supported_hw_count = 1; 131 + } else if (of_machine_is_compatible("nvidia,tegra30")) { 132 + hw_version = BIT(tegra_sku_info.soc_speedo_id); 133 + config.supported_hw = &hw_version; 134 + config.supported_hw_count = 1; 135 + } 136 + 137 + err = devm_pm_opp_set_config(dev, &config); 138 + if (err) { 139 + dev_err(dev, "failed to set OPP config: %d\n", err); 140 + return err; 141 + } 110 142 111 143 /* 112 - * For some devices we don't have any OPP table in the DT, and in order 113 - * to use the same code path for all the devices, we create a dummy OPP 114 - * table for them via this call. The dummy OPP table is only capable of 115 - * doing clk_set_rate() on invocation of dev_pm_opp_set_rate() and 116 - * doesn't provide any other functionality. 144 + * Tegra114+ doesn't support OPP yet, return early for non tegra20/30 145 + * case. 117 146 */ 118 - err = devm_pm_opp_set_clkname(dev, NULL); 119 - if (err) { 120 - dev_err(dev, "failed to set OPP clk: %d\n", err); 121 - return err; 122 - } 123 - 124 - /* Tegra114+ doesn't support OPP yet */ 125 - if (!of_machine_is_compatible("nvidia,tegra20") && 126 - !of_machine_is_compatible("nvidia,tegra30")) 147 + if (!config.supported_hw) 127 148 return -ENODEV; 128 - 129 - if (of_machine_is_compatible("nvidia,tegra20")) 130 - hw_version = BIT(tegra_sku_info.soc_process_id); 131 - else 132 - hw_version = BIT(tegra_sku_info.soc_speedo_id); 133 - 134 - err = devm_pm_opp_set_supported_hw(dev, &hw_version, 1); 135 - if (err) { 136 - dev_err(dev, "failed to set OPP supported HW: %d\n", err); 137 - return err; 138 - } 139 149 140 150 /* 141 151 * Older device-trees have an empty OPP table, we will get