Lines Matching full:bus
3 * Generic Exynos Bus frequency driver with DEVFREQ Framework
8 * This driver support Exynos Bus frequency feature by using
42 * Control the devfreq-event device to get the current state of bus
45 static int exynos_bus_##ops(struct exynos_bus *bus) \
49 for (i = 0; i < bus->edev_count; i++) { \
50 if (!bus->edev[i]) \
52 ret = devfreq_event_##ops(bus->edev[i]); \
63 static int exynos_bus_get_event(struct exynos_bus *bus, in exynos_bus_get_event() argument
70 for (i = 0; i < bus->edev_count; i++) { in exynos_bus_get_event()
71 if (!bus->edev[i]) in exynos_bus_get_event()
74 ret = devfreq_event_get_event(bus->edev[i], &event_data); in exynos_bus_get_event()
95 struct exynos_bus *bus = dev_get_drvdata(dev); in exynos_bus_target() local
99 /* Get correct frequency for bus. */ in exynos_bus_target()
109 mutex_lock(&bus->lock); in exynos_bus_target()
112 bus->curr_freq = *freq; in exynos_bus_target()
114 mutex_unlock(&bus->lock); in exynos_bus_target()
122 struct exynos_bus *bus = dev_get_drvdata(dev); in exynos_bus_get_dev_status() local
126 stat->current_frequency = bus->curr_freq; in exynos_bus_get_dev_status()
128 ret = exynos_bus_get_event(bus, &edata); in exynos_bus_get_dev_status()
134 stat->busy_time = (edata.load_count * 100) / bus->ratio; in exynos_bus_get_dev_status()
141 ret = exynos_bus_set_event(bus); in exynos_bus_get_dev_status()
152 struct exynos_bus *bus = dev_get_drvdata(dev); in exynos_bus_exit() local
155 ret = exynos_bus_disable_edev(bus); in exynos_bus_exit()
160 clk_disable_unprepare(bus->clk); in exynos_bus_exit()
161 if (bus->opp_table) { in exynos_bus_exit()
162 dev_pm_opp_put_regulators(bus->opp_table); in exynos_bus_exit()
163 bus->opp_table = NULL; in exynos_bus_exit()
169 struct exynos_bus *bus = dev_get_drvdata(dev); in exynos_bus_passive_exit() local
172 clk_disable_unprepare(bus->clk); in exynos_bus_passive_exit()
176 struct exynos_bus *bus) in exynos_bus_parent_parse_of() argument
178 struct device *dev = bus->dev; in exynos_bus_parent_parse_of()
190 bus->opp_table = opp_table; in exynos_bus_parent_parse_of()
202 bus->edev_count = count; in exynos_bus_parent_parse_of()
204 size = sizeof(*bus->edev) * count; in exynos_bus_parent_parse_of()
205 bus->edev = devm_kzalloc(dev, size, GFP_KERNEL); in exynos_bus_parent_parse_of()
206 if (!bus->edev) { in exynos_bus_parent_parse_of()
212 bus->edev[i] = devfreq_event_get_edev_by_phandle(dev, i); in exynos_bus_parent_parse_of()
213 if (IS_ERR(bus->edev[i])) { in exynos_bus_parent_parse_of()
221 * When measuring the utilization of each AXI bus with devfreq-event in exynos_bus_parent_parse_of()
223 * total cycle of bus during sampling rate. In result, the devfreq in exynos_bus_parent_parse_of()
229 if (of_property_read_u32(np, "exynos,saturation-ratio", &bus->ratio)) in exynos_bus_parent_parse_of()
230 bus->ratio = DEFAULT_SATURATION_RATIO; in exynos_bus_parent_parse_of()
235 dev_pm_opp_put_regulators(bus->opp_table); in exynos_bus_parent_parse_of()
236 bus->opp_table = NULL; in exynos_bus_parent_parse_of()
242 struct exynos_bus *bus) in exynos_bus_parse_of() argument
244 struct device *dev = bus->dev; in exynos_bus_parse_of()
249 /* Get the clock to provide each bus with source clock */ in exynos_bus_parse_of()
250 bus->clk = devm_clk_get(dev, "bus"); in exynos_bus_parse_of()
251 if (IS_ERR(bus->clk)) { in exynos_bus_parse_of()
252 dev_err(dev, "failed to get bus clock\n"); in exynos_bus_parse_of()
253 return PTR_ERR(bus->clk); in exynos_bus_parse_of()
256 ret = clk_prepare_enable(bus->clk); in exynos_bus_parse_of()
262 /* Get the freq and voltage from OPP table to scale the bus freq */ in exynos_bus_parse_of()
269 rate = clk_get_rate(bus->clk); in exynos_bus_parse_of()
277 bus->curr_freq = dev_pm_opp_get_freq(opp); in exynos_bus_parse_of()
285 clk_disable_unprepare(bus->clk); in exynos_bus_parse_of()
298 struct exynos_bus *bus; in exynos_bus_probe() local
308 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); in exynos_bus_probe()
309 if (!bus) in exynos_bus_probe()
311 mutex_init(&bus->lock); in exynos_bus_probe()
312 bus->dev = &pdev->dev; in exynos_bus_probe()
313 platform_set_drvdata(pdev, bus); in exynos_bus_probe()
324 ret = exynos_bus_parent_parse_of(np, bus); in exynos_bus_probe()
330 ret = exynos_bus_parse_of(np, bus); in exynos_bus_probe()
351 /* Add devfreq device to monitor and handle the exynos bus */ in exynos_bus_probe()
352 bus->devfreq = devm_devfreq_add_device(dev, profile, in exynos_bus_probe()
355 if (IS_ERR(bus->devfreq)) { in exynos_bus_probe()
357 ret = PTR_ERR(bus->devfreq); in exynos_bus_probe()
362 ret = devm_devfreq_register_opp_notifier(dev, bus->devfreq); in exynos_bus_probe()
370 * current bus load. in exynos_bus_probe()
372 ret = exynos_bus_enable_edev(bus); in exynos_bus_probe()
378 ret = exynos_bus_set_event(bus); in exynos_bus_probe()
404 /* Add devfreq device for exynos bus with passive governor */ in exynos_bus_probe()
405 bus->devfreq = devm_devfreq_add_device(dev, profile, DEVFREQ_GOV_PASSIVE, in exynos_bus_probe()
407 if (IS_ERR(bus->devfreq)) { in exynos_bus_probe()
410 ret = PTR_ERR(bus->devfreq); in exynos_bus_probe()
415 max_state = bus->devfreq->profile->max_state; in exynos_bus_probe()
416 min_freq = (bus->devfreq->profile->freq_table[0] / 1000); in exynos_bus_probe()
417 max_freq = (bus->devfreq->profile->freq_table[max_state - 1] / 1000); in exynos_bus_probe()
418 pr_info("exynos-bus: new bus device registered: %s (%6ld KHz ~ %6ld KHz)\n", in exynos_bus_probe()
425 clk_disable_unprepare(bus->clk); in exynos_bus_probe()
428 dev_pm_opp_put_regulators(bus->opp_table); in exynos_bus_probe()
429 bus->opp_table = NULL; in exynos_bus_probe()
437 struct exynos_bus *bus = dev_get_drvdata(&pdev->dev); in exynos_bus_shutdown() local
439 devfreq_suspend_device(bus->devfreq); in exynos_bus_shutdown()
445 struct exynos_bus *bus = dev_get_drvdata(dev); in exynos_bus_resume() local
448 ret = exynos_bus_enable_edev(bus); in exynos_bus_resume()
459 struct exynos_bus *bus = dev_get_drvdata(dev); in exynos_bus_suspend() local
462 ret = exynos_bus_disable_edev(bus); in exynos_bus_suspend()
477 { .compatible = "samsung,exynos-bus", },
486 .name = "exynos-bus",
493 MODULE_DESCRIPTION("Generic Exynos Bus frequency driver");