• Home
  • Raw
  • Download

Lines Matching +full:clk +full:- +full:out +full:- +full:frequency

2  * Generic Exynos Bus frequency driver with DEVFREQ Framework
7 * This driver support Exynos Bus frequency feature by using
15 #include <linux/clk.h>
17 #include <linux/devfreq-event.h>
41 struct clk *clk; member
47 * Control the devfreq-event device to get the current state of bus
54 for (i = 0; i < bus->edev_count; i++) { \
55 if (!bus->edev[i]) \
57 ret = devfreq_event_##ops(bus->edev[i]); \
75 for (i = 0; i < bus->edev_count; i++) { in exynos_bus_get_event()
76 if (!bus->edev[i]) in exynos_bus_get_event()
79 ret = devfreq_event_get_event(bus->edev[i], &event_data); in exynos_bus_get_event()
89 edata->load_count = load_count; in exynos_bus_get_event()
90 edata->total_count = total_count; in exynos_bus_get_event()
96 * Must necessary function for devfreq simple-ondemand governor
105 /* Get new opp-bus instance according to new bus clock */ in exynos_bus_target()
116 old_freq = bus->curr_freq; in exynos_bus_target()
120 tol = new_volt * bus->voltage_tolerance / 100; in exynos_bus_target()
122 /* Change voltage and frequency according to new OPP level */ in exynos_bus_target()
123 mutex_lock(&bus->lock); in exynos_bus_target()
126 ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol); in exynos_bus_target()
128 dev_err(bus->dev, "failed to set voltage\n"); in exynos_bus_target()
129 goto out; in exynos_bus_target()
133 ret = clk_set_rate(bus->clk, new_freq); in exynos_bus_target()
136 clk_set_rate(bus->clk, old_freq); in exynos_bus_target()
137 goto out; in exynos_bus_target()
141 ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol); in exynos_bus_target()
143 dev_err(bus->dev, "failed to set voltage\n"); in exynos_bus_target()
144 goto out; in exynos_bus_target()
147 bus->curr_freq = new_freq; in exynos_bus_target()
149 dev_dbg(dev, "Set the frequency of bus (%luHz -> %luHz, %luHz)\n", in exynos_bus_target()
150 old_freq, new_freq, clk_get_rate(bus->clk)); in exynos_bus_target()
151 out: in exynos_bus_target()
152 mutex_unlock(&bus->lock); in exynos_bus_target()
164 stat->current_frequency = bus->curr_freq; in exynos_bus_get_dev_status()
168 stat->total_time = stat->busy_time = 0; in exynos_bus_get_dev_status()
172 stat->busy_time = (edata.load_count * 100) / bus->ratio; in exynos_bus_get_dev_status()
173 stat->total_time = edata.total_count; in exynos_bus_get_dev_status()
175 dev_dbg(dev, "Usage of devfreq-event : %lu/%lu\n", stat->busy_time, in exynos_bus_get_dev_status()
176 stat->total_time); in exynos_bus_get_dev_status()
181 dev_err(dev, "failed to set event to devfreq-event devices\n"); in exynos_bus_get_dev_status()
195 dev_warn(dev, "failed to disable the devfreq-event devices\n"); in exynos_bus_exit()
198 clk_disable_unprepare(bus->clk); in exynos_bus_exit()
199 if (bus->regulator) in exynos_bus_exit()
200 regulator_disable(bus->regulator); in exynos_bus_exit()
214 /* Get new opp-bus instance according to new bus clock */ in exynos_bus_passive_target()
224 old_freq = bus->curr_freq; in exynos_bus_passive_target()
229 /* Change the frequency according to new OPP level */ in exynos_bus_passive_target()
230 mutex_lock(&bus->lock); in exynos_bus_passive_target()
232 ret = clk_set_rate(bus->clk, new_freq); in exynos_bus_passive_target()
235 goto out; in exynos_bus_passive_target()
239 bus->curr_freq = new_freq; in exynos_bus_passive_target()
241 dev_dbg(dev, "Set the frequency of bus (%luHz -> %luHz, %luHz)\n", in exynos_bus_passive_target()
242 old_freq, new_freq, clk_get_rate(bus->clk)); in exynos_bus_passive_target()
243 out: in exynos_bus_passive_target()
244 mutex_unlock(&bus->lock); in exynos_bus_passive_target()
254 clk_disable_unprepare(bus->clk); in exynos_bus_passive_exit()
260 struct device *dev = bus->dev; in exynos_bus_parent_parse_of()
264 bus->regulator = devm_regulator_get(dev, "vdd"); in exynos_bus_parent_parse_of()
265 if (IS_ERR(bus->regulator)) { in exynos_bus_parent_parse_of()
267 return PTR_ERR(bus->regulator); in exynos_bus_parent_parse_of()
270 ret = regulator_enable(bus->regulator); in exynos_bus_parent_parse_of()
277 * Get the devfreq-event devices to get the current utilization of in exynos_bus_parent_parse_of()
282 dev_err(dev, "failed to get the count of devfreq-event dev\n"); in exynos_bus_parent_parse_of()
286 bus->edev_count = count; in exynos_bus_parent_parse_of()
288 size = sizeof(*bus->edev) * count; in exynos_bus_parent_parse_of()
289 bus->edev = devm_kzalloc(dev, size, GFP_KERNEL); in exynos_bus_parent_parse_of()
290 if (!bus->edev) { in exynos_bus_parent_parse_of()
291 ret = -ENOMEM; in exynos_bus_parent_parse_of()
296 bus->edev[i] = devfreq_event_get_edev_by_phandle(dev, i); in exynos_bus_parent_parse_of()
297 if (IS_ERR(bus->edev[i])) { in exynos_bus_parent_parse_of()
298 ret = -EPROBE_DEFER; in exynos_bus_parent_parse_of()
305 * When measuring the utilization of each AXI bus with devfreq-event in exynos_bus_parent_parse_of()
308 * simple-ondemand governor might not decide to change the current in exynos_bus_parent_parse_of()
309 * frequency due to too utilization (= real cycle/total cycle). in exynos_bus_parent_parse_of()
313 if (of_property_read_u32(np, "exynos,saturation-ratio", &bus->ratio)) in exynos_bus_parent_parse_of()
314 bus->ratio = DEFAULT_SATURATION_RATIO; in exynos_bus_parent_parse_of()
316 if (of_property_read_u32(np, "exynos,voltage-tolerance", in exynos_bus_parent_parse_of()
317 &bus->voltage_tolerance)) in exynos_bus_parent_parse_of()
318 bus->voltage_tolerance = DEFAULT_VOLTAGE_TOLERANCE; in exynos_bus_parent_parse_of()
323 regulator_disable(bus->regulator); in exynos_bus_parent_parse_of()
331 struct device *dev = bus->dev; in exynos_bus_parse_of()
337 bus->clk = devm_clk_get(dev, "bus"); in exynos_bus_parse_of()
338 if (IS_ERR(bus->clk)) { in exynos_bus_parse_of()
340 return PTR_ERR(bus->clk); in exynos_bus_parse_of()
343 ret = clk_prepare_enable(bus->clk); in exynos_bus_parse_of()
356 rate = clk_get_rate(bus->clk); in exynos_bus_parse_of()
364 bus->curr_freq = dev_pm_opp_get_freq(opp); in exynos_bus_parse_of()
372 clk_disable_unprepare(bus->clk); in exynos_bus_parse_of()
379 struct device *dev = &pdev->dev; in exynos_bus_probe()
380 struct device_node *np = dev->of_node, *node; in exynos_bus_probe()
392 return -EINVAL; in exynos_bus_probe()
395 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); in exynos_bus_probe()
397 return -ENOMEM; in exynos_bus_probe()
398 mutex_init(&bus->lock); in exynos_bus_probe()
399 bus->dev = &pdev->dev; in exynos_bus_probe()
404 return -ENOMEM; in exynos_bus_probe()
406 node = of_parse_phandle(dev->of_node, "devfreq", 0); in exynos_bus_probe()
416 /* Parse the device-tree to get the resource information */ in exynos_bus_probe()
425 profile->polling_ms = 50; in exynos_bus_probe()
426 profile->target = exynos_bus_target; in exynos_bus_probe()
427 profile->get_dev_status = exynos_bus_get_dev_status; in exynos_bus_probe()
428 profile->exit = exynos_bus_exit; in exynos_bus_probe()
432 ret = -ENOMEM; in exynos_bus_probe()
435 ondemand_data->upthreshold = 40; in exynos_bus_probe()
436 ondemand_data->downdifferential = 5; in exynos_bus_probe()
439 bus->devfreq = devm_devfreq_add_device(dev, profile, in exynos_bus_probe()
442 if (IS_ERR(bus->devfreq)) { in exynos_bus_probe()
444 ret = PTR_ERR(bus->devfreq); in exynos_bus_probe()
449 ret = devm_devfreq_register_opp_notifier(dev, bus->devfreq); in exynos_bus_probe()
456 * Enable devfreq-event to get raw data which is used to determine in exynos_bus_probe()
461 dev_err(dev, "failed to enable devfreq-event devices\n"); in exynos_bus_probe()
467 dev_err(dev, "failed to set event to devfreq-event devices\n"); in exynos_bus_probe()
471 goto out; in exynos_bus_probe()
474 profile->target = exynos_bus_passive_target; in exynos_bus_probe()
475 profile->exit = exynos_bus_passive_exit; in exynos_bus_probe()
480 ret = -EPROBE_DEFER; in exynos_bus_probe()
486 ret = -ENOMEM; in exynos_bus_probe()
489 passive_data->parent = parent_devfreq; in exynos_bus_probe()
492 bus->devfreq = devm_devfreq_add_device(dev, profile, DEVFREQ_GOV_PASSIVE, in exynos_bus_probe()
494 if (IS_ERR(bus->devfreq)) { in exynos_bus_probe()
497 ret = PTR_ERR(bus->devfreq); in exynos_bus_probe()
501 out: in exynos_bus_probe()
502 max_state = bus->devfreq->profile->max_state; in exynos_bus_probe()
503 min_freq = (bus->devfreq->profile->freq_table[0] / 1000); in exynos_bus_probe()
504 max_freq = (bus->devfreq->profile->freq_table[max_state - 1] / 1000); in exynos_bus_probe()
505 pr_info("exynos-bus: new bus device registered: %s (%6ld KHz ~ %6ld KHz)\n", in exynos_bus_probe()
512 clk_disable_unprepare(bus->clk); in exynos_bus_probe()
515 regulator_disable(bus->regulator); in exynos_bus_probe()
528 dev_err(dev, "failed to enable the devfreq-event devices\n"); in exynos_bus_resume()
542 dev_err(dev, "failed to disable the devfreq-event devices\n"); in exynos_bus_suspend()
555 { .compatible = "samsung,exynos-bus", },
563 .name = "exynos-bus",
570 MODULE_DESCRIPTION("Generic Exynos Bus frequency driver");