Lines Matching defs:drv
39 static int mtk_ccifreq_set_voltage(struct mtk_ccifreq_drv *drv, int new_voltage)
41 const struct mtk_ccifreq_platform_data *soc_data = drv->soc_data;
42 struct device *dev = drv->dev;
44 int retry_max = drv->vtrack_max;
46 if (!drv->sram_reg) {
47 ret = regulator_set_voltage(drv->proc_reg, new_voltage,
48 drv->soc_data->proc_max_volt);
52 pre_voltage = regulator_get_voltage(drv->proc_reg);
58 pre_vsram = regulator_get_voltage(drv->sram_reg);
71 ret = regulator_set_voltage(drv->sram_reg, vsram,
82 ret = regulator_set_voltage(drv->proc_reg, voltage,
85 regulator_set_voltage(drv->sram_reg, pre_vsram,
92 ret = regulator_set_voltage(drv->proc_reg, voltage,
103 ret = regulator_set_voltage(drv->sram_reg, vsram,
106 regulator_set_voltage(drv->proc_reg, pre_voltage,
128 struct mtk_ccifreq_drv *drv = dev_get_drvdata(dev);
134 if (!drv)
137 if (drv->pre_freq == *freq)
140 inter_voltage = drv->inter_voltage;
141 cci_pll = clk_get_parent(drv->cci_clk);
150 mutex_lock(&drv->reg_lock);
155 pre_voltage = regulator_get_voltage(drv->proc_reg);
165 ret = mtk_ccifreq_set_voltage(drv, target_voltage);
173 ret = clk_set_parent(drv->cci_clk, drv->inter_clk);
183 clk_set_parent(drv->cci_clk, cci_pll);
188 ret = clk_set_parent(drv->cci_clk, cci_pll);
191 mtk_ccifreq_set_voltage(drv, inter_voltage);
200 ret = mtk_ccifreq_set_voltage(drv, voltage);
207 drv->pre_freq = *freq;
208 mutex_unlock(&drv->reg_lock);
213 mtk_ccifreq_set_voltage(drv, pre_voltage);
216 mutex_unlock(&drv->reg_lock);
224 struct mtk_ccifreq_drv *drv;
227 drv = container_of(nb, struct mtk_ccifreq_drv, opp_nb);
232 mutex_lock(&drv->reg_lock);
234 if (freq == drv->pre_freq) {
236 mtk_ccifreq_set_voltage(drv, volt);
238 mutex_unlock(&drv->reg_lock);
251 struct mtk_ccifreq_drv *drv;
257 drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL);
258 if (!drv)
261 drv->dev = dev;
262 drv->soc_data = (const struct mtk_ccifreq_platform_data *)
264 mutex_init(&drv->reg_lock);
265 platform_set_drvdata(pdev, drv);
267 drv->cci_clk = devm_clk_get(dev, "cci");
268 if (IS_ERR(drv->cci_clk)) {
269 ret = PTR_ERR(drv->cci_clk);
273 drv->inter_clk = devm_clk_get(dev, "intermediate");
274 if (IS_ERR(drv->inter_clk)) {
275 ret = PTR_ERR(drv->inter_clk);
280 drv->proc_reg = devm_regulator_get_optional(dev, "proc");
281 if (IS_ERR(drv->proc_reg)) {
282 ret = PTR_ERR(drv->proc_reg);
287 ret = regulator_enable(drv->proc_reg);
293 drv->sram_reg = devm_regulator_get_optional(dev, "sram");
294 if (IS_ERR(drv->sram_reg)) {
295 ret = PTR_ERR(drv->sram_reg);
299 drv->sram_reg = NULL;
301 ret = regulator_enable(drv->sram_reg);
313 drv->vtrack_max = 3 * DIV_ROUND_UP(max(drv->soc_data->sram_max_volt,
314 drv->soc_data->proc_max_volt),
315 drv->soc_data->min_volt_shift);
317 ret = clk_prepare_enable(drv->cci_clk);
327 rate = clk_get_rate(drv->inter_clk);
334 drv->inter_voltage = dev_pm_opp_get_voltage(opp);
338 opp = dev_pm_opp_find_freq_floor(drv->dev, &rate);
347 ret = mtk_ccifreq_set_voltage(drv, opp_volt);
361 drv->devfreq = devm_devfreq_add_device(dev, &mtk_ccifreq_profile,
364 if (IS_ERR(drv->devfreq)) {
367 PTR_ERR(drv->devfreq));
371 drv->opp_nb.notifier_call = mtk_ccifreq_opp_notifier;
372 ret = dev_pm_opp_register_notifier(dev, &drv->opp_nb);
383 clk_disable_unprepare(drv->cci_clk);
386 if (regulator_is_enabled(drv->proc_reg))
387 regulator_disable(drv->proc_reg);
388 if (drv->sram_reg && regulator_is_enabled(drv->sram_reg))
389 regulator_disable(drv->sram_reg);
397 struct mtk_ccifreq_drv *drv;
399 drv = platform_get_drvdata(pdev);
401 dev_pm_opp_unregister_notifier(dev, &drv->opp_nb);
403 clk_disable_unprepare(drv->cci_clk);
404 regulator_disable(drv->proc_reg);
405 if (drv->sram_reg)
406 regulator_disable(drv->sram_reg);