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

Merge tag 'opp-5.4-support-adjust-voltages' of https://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm into next/drivers

+82
+69
drivers/opp/core.c
··· 2113 2113 } 2114 2114 2115 2115 /** 2116 + * dev_pm_opp_adjust_voltage() - helper to change the voltage of an OPP 2117 + * @dev: device for which we do this operation 2118 + * @freq: OPP frequency to adjust voltage of 2119 + * @u_volt: new OPP target voltage 2120 + * @u_volt_min: new OPP min voltage 2121 + * @u_volt_max: new OPP max voltage 2122 + * 2123 + * Return: -EINVAL for bad pointers, -ENOMEM if no memory available for the 2124 + * copy operation, returns 0 if no modifcation was done OR modification was 2125 + * successful. 2126 + */ 2127 + int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, 2128 + unsigned long u_volt, unsigned long u_volt_min, 2129 + unsigned long u_volt_max) 2130 + 2131 + { 2132 + struct opp_table *opp_table; 2133 + struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV); 2134 + int r = 0; 2135 + 2136 + /* Find the opp_table */ 2137 + opp_table = _find_opp_table(dev); 2138 + if (IS_ERR(opp_table)) { 2139 + r = PTR_ERR(opp_table); 2140 + dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r); 2141 + return r; 2142 + } 2143 + 2144 + mutex_lock(&opp_table->lock); 2145 + 2146 + /* Do we have the frequency? */ 2147 + list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { 2148 + if (tmp_opp->rate == freq) { 2149 + opp = tmp_opp; 2150 + break; 2151 + } 2152 + } 2153 + 2154 + if (IS_ERR(opp)) { 2155 + r = PTR_ERR(opp); 2156 + goto adjust_unlock; 2157 + } 2158 + 2159 + /* Is update really needed? */ 2160 + if (opp->supplies->u_volt == u_volt) 2161 + goto adjust_unlock; 2162 + 2163 + opp->supplies->u_volt = u_volt; 2164 + opp->supplies->u_volt_min = u_volt_min; 2165 + opp->supplies->u_volt_max = u_volt_max; 2166 + 2167 + dev_pm_opp_get(opp); 2168 + mutex_unlock(&opp_table->lock); 2169 + 2170 + /* Notify the voltage change of the OPP */ 2171 + blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADJUST_VOLTAGE, 2172 + opp); 2173 + 2174 + dev_pm_opp_put(opp); 2175 + goto adjust_put_table; 2176 + 2177 + adjust_unlock: 2178 + mutex_unlock(&opp_table->lock); 2179 + adjust_put_table: 2180 + dev_pm_opp_put_opp_table(opp_table); 2181 + return r; 2182 + } 2183 + 2184 + /** 2116 2185 * dev_pm_opp_enable() - Enable a specific OPP 2117 2186 * @dev: device for which we do this operation 2118 2187 * @freq: OPP frequency to enable
+13
include/linux/pm_opp.h
··· 22 22 23 23 enum dev_pm_opp_event { 24 24 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE, 25 + OPP_EVENT_ADJUST_VOLTAGE, 25 26 }; 26 27 27 28 /** ··· 113 112 unsigned long u_volt); 114 113 void dev_pm_opp_remove(struct device *dev, unsigned long freq); 115 114 void dev_pm_opp_remove_all_dynamic(struct device *dev); 115 + 116 + int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, 117 + unsigned long u_volt, unsigned long u_volt_min, 118 + unsigned long u_volt_max); 116 119 117 120 int dev_pm_opp_enable(struct device *dev, unsigned long freq); 118 121 ··· 245 240 246 241 static inline void dev_pm_opp_remove_all_dynamic(struct device *dev) 247 242 { 243 + } 244 + 245 + static inline int 246 + dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq, 247 + unsigned long u_volt, unsigned long u_volt_min, 248 + unsigned long u_volt_max) 249 + { 250 + return 0; 248 251 } 249 252 250 253 static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)