Lines Matching +full:always +full:- +full:turbo

1 // SPDX-License-Identifier: GPL-2.0+
5 * Even though clk-bcm2835 provides an interface to the hardware registers for
8 * over-temperature and under-voltage protections provided by the firmware.
14 #include <linux/clk-provider.h>
19 #include <soc/bcm2835/raspberrypi-firmware.h>
35 [RPI_FIRMWARE_PIXEL_BVB_CLK_ID] = "pixel-bvb",
83 * always use the minimum the drivers will let us.
107 * driver instances, let's always use the minimum the
132 * clock (pllb) which we enable by default as turbo mode will alter multiple
141 * https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
154 .id = cpu_to_le32(data->id), in raspberrypi_clock_property()
173 struct raspberrypi_clk *rpi = data->rpi; in raspberrypi_fw_is_prepared()
177 ret = raspberrypi_clock_property(rpi->firmware, data, in raspberrypi_fw_is_prepared()
191 struct raspberrypi_clk *rpi = data->rpi; in raspberrypi_fw_get_rate()
195 ret = raspberrypi_clock_property(rpi->firmware, data, in raspberrypi_fw_get_rate()
208 struct raspberrypi_clk *rpi = data->rpi; in raspberrypi_fw_set_rate()
212 ret = raspberrypi_clock_property(rpi->firmware, data, in raspberrypi_fw_set_rate()
215 dev_err_ratelimited(rpi->dev, "Failed to change %s frequency: %d\n", in raspberrypi_fw_set_rate()
226 struct raspberrypi_clk_variant *variant = data->variant; in raspberrypi_fw_dumb_determine_rate()
234 req->rate = clamp(req->rate, req->min_rate, req->max_rate); in raspberrypi_fw_dumb_determine_rate()
241 if (variant->minimize && req->min_rate > 0) in raspberrypi_fw_dumb_determine_rate()
242 req->rate = req->min_rate; in raspberrypi_fw_dumb_determine_rate()
264 data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL); in raspberrypi_clk_register()
266 return ERR_PTR(-ENOMEM); in raspberrypi_clk_register()
267 data->rpi = rpi; in raspberrypi_clk_register()
268 data->id = id; in raspberrypi_clk_register()
269 data->variant = variant; in raspberrypi_clk_register()
271 init.name = devm_kasprintf(rpi->dev, GFP_KERNEL, in raspberrypi_clk_register()
272 "fw-clk-%s", in raspberrypi_clk_register()
277 data->hw.init = &init; in raspberrypi_clk_register()
279 ret = raspberrypi_clock_property(rpi->firmware, data, in raspberrypi_clk_register()
283 dev_err(rpi->dev, "Failed to get clock %d min freq: %d\n", in raspberrypi_clk_register()
288 ret = raspberrypi_clock_property(rpi->firmware, data, in raspberrypi_clk_register()
292 dev_err(rpi->dev, "Failed to get clock %d max freq: %d\n", in raspberrypi_clk_register()
297 ret = devm_clk_hw_register(rpi->dev, &data->hw); in raspberrypi_clk_register()
301 clk_hw_set_rate_range(&data->hw, min_rate, max_rate); in raspberrypi_clk_register()
303 if (variant->clkdev) { in raspberrypi_clk_register()
304 ret = devm_clk_hw_register_clkdev(rpi->dev, &data->hw, in raspberrypi_clk_register()
305 NULL, variant->clkdev); in raspberrypi_clk_register()
307 dev_err(rpi->dev, "Failed to initialize clkdev\n"); in raspberrypi_clk_register()
312 if (variant->min_rate) { in raspberrypi_clk_register()
315 clk_hw_set_rate_range(&data->hw, variant->min_rate, max_rate); in raspberrypi_clk_register()
317 rate = raspberrypi_fw_get_rate(&data->hw, 0); in raspberrypi_clk_register()
318 if (rate < variant->min_rate) { in raspberrypi_clk_register()
319 ret = raspberrypi_fw_set_rate(&data->hw, variant->min_rate, 0); in raspberrypi_clk_register()
325 return &data->hw; in raspberrypi_clk_register()
344 clks = devm_kcalloc(rpi->dev, in raspberrypi_discover_clocks()
348 return -ENOMEM; in raspberrypi_discover_clocks()
350 ret = rpi_firmware_property(rpi->firmware, RPI_FIRMWARE_GET_CLOCKS, in raspberrypi_discover_clocks()
356 while (clks->id) { in raspberrypi_discover_clocks()
359 if (clks->id >= RPI_FIRMWARE_NUM_CLK_ID) { in raspberrypi_discover_clocks()
360 dev_err(rpi->dev, "Unknown clock id: %u (max: %u)\n", in raspberrypi_discover_clocks()
361 clks->id, RPI_FIRMWARE_NUM_CLK_ID - 1); in raspberrypi_discover_clocks()
362 return -EINVAL; in raspberrypi_discover_clocks()
365 variant = &raspberrypi_clk_variants[clks->id]; in raspberrypi_discover_clocks()
366 if (variant->export) { in raspberrypi_discover_clocks()
369 hw = raspberrypi_clk_register(rpi, clks->parent, in raspberrypi_discover_clocks()
370 clks->id, variant); in raspberrypi_discover_clocks()
374 data->num = clks->id + 1; in raspberrypi_discover_clocks()
375 data->hws[clks->id] = hw; in raspberrypi_discover_clocks()
388 struct device *dev = &pdev->dev; in raspberrypi_clk_probe()
394 * We can be probed either through the an old-fashioned in raspberrypi_clk_probe()
398 if (dev->of_node) in raspberrypi_clk_probe()
399 firmware_node = of_get_parent(dev->of_node); in raspberrypi_clk_probe()
402 "raspberrypi,bcm2835-firmware"); in raspberrypi_clk_probe()
405 return -ENOENT; in raspberrypi_clk_probe()
408 firmware = devm_rpi_firmware_get(&pdev->dev, firmware_node); in raspberrypi_clk_probe()
411 return -EPROBE_DEFER; in raspberrypi_clk_probe()
415 return -ENOMEM; in raspberrypi_clk_probe()
417 rpi->dev = dev; in raspberrypi_clk_probe()
418 rpi->firmware = firmware; in raspberrypi_clk_probe()
425 return -ENOMEM; in raspberrypi_clk_probe()
436 rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq", in raspberrypi_clk_probe()
437 -1, NULL, 0); in raspberrypi_clk_probe()
446 platform_device_unregister(rpi->cpufreq); in raspberrypi_clk_remove()
450 { .compatible = "raspberrypi,firmware-clocks" },
457 .name = "raspberrypi-clk",
468 MODULE_ALIAS("platform:raspberrypi-clk");