[通用时钟框架]:如果父时钟无法设置,如何设置复用时钟的速率?

[Common Clock Framework]: How to set rate of a muxed clock if its parent clock unable to set?

正在研究 Common Clock Framework 并对 muxed 时钟有疑问。

如果我们想设置一个 muxed 时钟的特定速率,而时钟的当前父级无法设置所需的速率(父级的速率较低)。

那么,有没有什么函数或机制可以自动切换时钟的父级(从其父级列表)并设置期望率?

一种可能的解决方案,我们可以手动调用set_parent(),然后调用set_rate(),这样可以设置期望率。但是如果我们只是调用 set_rate() 并且它会自动切换时钟的父级并设置所需的速率怎么办。

有些时钟可能 up-scale 定时器使用 PLL. So having a parent that has a lower clocking doesn't mean that automatically trying to increase the parent clock is the best solution. The Common clock framework (CCF)旨在允许多个 drivers/sub-systems 访问共享资源。 CCF 并没有试图变得智能,因为不同时钟树的行为方式很难一概而论。

One possible solution, we can call the set_parent() manually and then call set_rate(), which can set desire rate.

我想你的意思是调用 get_parent() 然后使用 set_rate?有时,调用 set_parent() 并不容易,因为它可能已修复。您需要阅读您的 SOC 文档。在某些情况下,有多个输入时钟可用。即,尽管 active 层次结构是 tree-like.

,但真正的时钟层次结构不是树而是 DAG

But what if we just call set_rate() and it switches parent of the clock automatically and sets desirable rate.

这可能对您正在查看的 SOC 时钟有意义,但不是通用的。可能有几十个时钟依赖于 parent 并且可能 re-rate grand-parents 等。这可能不是最好的选择 re-rate 系统时钟,因为音频驱动程序需要一个几赫兹的时钟?

可以编写 时钟驱动程序 以便在 child 上发出请求时它会 re-rate parent那行不通。然而,这是时钟驱动程序的一部分,而不是一般的 CCF


例子

例如,一个 SOC 可能有一个带三个输入源的音频时钟,

  1. 专用48000khz
  2. 一些低速总线时钟(平台通用)
  3. USB 时钟

选项1音质最好,功耗最高。选项 2 是通用的,但可能无法很好地匹配声音速率,从而导致 sub-optimal DAC/wave/sound 生成。选项三可能适用于某种 USB 声音从属设备,但如果您不使用 USB,这可能会耗电昂贵。

在上述情况下,如果 SOC 时钟驱动程序支持,set_parent() 可能是一种获得所需速率的方法。


CCF中没有智能;如果有一些灵活性,它在 时钟驱动程序 中,但这取决于时钟硬件。程序员需要阅读 SOC 文档并确定配置时钟树的最佳方法。也许您还应该检查您的 SOC 的时钟驱动程序和 Linux 版本以查看它支持什么。您不能在驱动程序中更改 parents 的时钟速率,因为其他设备可能依赖于它们。如果您需要为 SOC 系列中的特定 SOC 使用它,则需要通过检查设备树以查看驱动程序 运行 在哪个 SOC 上来对其进行特殊处理。在这种情况下,您可以为特定的 SOC 使用 get_parent()set_rate()

参考:A question on older Linux clock structure.