如何在linux内核设备树中定义时钟多路复用器(How to define a clock multiplexer in a linux kernel device tree)
我正在编写Linux设备驱动程序,需要在设备树文件中定义以下时钟树:
注意:在多路复用器中选择振荡器是通过将gpio输出拉高或拉低来完成的。 时钟发生器通过I2C编程。
这是我到目前为止的一个例子:
clocks { /* fixed clock oscillators */ osc22: oscillator22 { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <22579200>; }; osc24: oscillator24 { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <24576000>; }; /* clock multiplexer * I'm afraid the following is not going to work :( ? */ mux: multiplexer { compatible = "mux-clock"; /* <-------- ??? */ clocks = <&osc22>, <&osc24>; /* parent clocks */ }; }; i2c1 { /* clock generator */ si5351: si5351c@60 { #address-cells = <1>; #size-cells = <0>; #clock-cells = <1>; compatible = "silabs,si5351c"; reg = <0x60>; clocks = <0>, <&mux>; clock-names = "xtal", "clkin"; status = "okay"; clkout0 { reg = <0>; silabs,disable-state = <2>; silabs,clock-source = <3>; }; }; };
参考文献 :
如何在设备树中定义简单的gpio控制时钟多路复用器?
I am writing a linux device driver and need to define the following clock-tree in a device tree file:
Note: Selecting an oscillator in the multiplexer is done by pulling an gpio output high or low. The clock generator is programmed via I2C.
Here is an example of what I have so far:
clocks { /* fixed clock oscillators */ osc22: oscillator22 { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <22579200>; }; osc24: oscillator24 { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <24576000>; }; /* clock multiplexer * I'm afraid the following is not going to work :( ? */ mux: multiplexer { compatible = "mux-clock"; /* <-------- ??? */ clocks = <&osc22>, <&osc24>; /* parent clocks */ }; }; i2c1 { /* clock generator */ si5351: si5351c@60 { #address-cells = <1>; #size-cells = <0>; #clock-cells = <1>; compatible = "silabs,si5351c"; reg = <0x60>; clocks = <0>, <&mux>; clock-names = "xtal", "clkin"; status = "okay"; clkout0 { reg = <0>; silabs,disable-state = <2>; silabs,clock-source = <3>; }; }; };
References:
- Clock Bindings
- Binding for simple fixed-rate clock sources
- Binding for Silicon Labs Si5351a/b/c programmable i2c clock generator
How do I define a simple gpio-controlled clock multiplexer in a device tree?
原文:https://stackoverflow.com/questions/29153415
最满意答案
cblas_sdot
函数不应该返回指针。来自BLAS参考 :
cblas_sdot
计算两个向量的点积(单精度)。
float cblas_sdot(const int N, const float *X, const int incX, const float *Y, const int incY);
The
cblas_sdot
function is not supposed to return a pointer.From BLAS Reference:
cblas_sdot
Computes the dot product of two vectors (single-precision).
float cblas_sdot(const int N, const float *X, const int incX, const float *Y, const int incY);
相关问答
更多-
那么,方法只是常规函数,正如克里斯所说, self参数与Self类型有着隐含的联系。 用你的例子(稍加修改)使用C代码中的函数应该很简单: #[repr(C)] pub struct A { id: u32, } #[no_mangle] pub extern fn new_a(id: u32) -> A { A { id: id } } impl A { #[no_mangle] pub extern fn some_funct(&self) { println ...
-
这是不可能的,我不认为将来有可能。 C宏带来了太多问题。 如果你想在你的Rust源码上运行cpp ,你可以手动完成。 如果你不想这样做,并且如果有很多常量,并且你也不想将它们的值从C代码复制到Rust,你可以创建一个C封装器,它将为这些值提供全局变量: #define INIT_FLAG 0x00000001 ... const int init_flag = INIT_FLAG; 你编译这个文件,从它创建一个静态库并像往常一样链接到它: $ gcc -c init_flag.c $ ar r lib ...
-
请注意, rustbindgen以与C中一样多的安全性生成与C union绑定; 因此,在打电话时: event.xkey(); // gets the C union 'xkey' field 没有运行时检查xkey是当前包含值的字段。 这是因为由于C没有标记union (即union知道当前正在使用哪个字段),开发人员想出了各种编码此信息的方式(*),我知道这两种方式是: 外部供应商; 通常是union之前结构的另一个领域 union中每个结构的第一个领域 在这里,你在后一种情况下int type; ...
-
Rust“如果让”不工作?(Rust “if let” not working?)[2023-07-01]
您需要将实际模式传递给if let (与Swift之类的语言不同,特殊情况if let Option类型): if let Some(doc) = xml::parse_file("filename") { doc.simple_function(); } You need to pass the actual pattern to if let (unlike languages like Swift which special case if let for Option types): if ... -
感谢JJ Hakala的回答 ,我能够用纯Rust生产MCVE : extern crate libc; use std::ffi::CString; use libc::c_void; fn encode_coordinates(coordinates: &Vec<[f64; 2]>) -> String { format!("Encoded coordinates {:?}", coordinates) } struct Array { data: *const c_void, ...
-
CString不仅是一个指针, 它是一个指针加上一个布尔值 ,表示CString拥有C字符串。 因此,您的Lua代码中的声明与Rust代码中的定义不符。 通过在CString上使用*mut c_char方法返回*const c_char或a *mut c_char 。 如果你的函数返回一个动态分配的字符串,你还需要提供一个函数来释放Lua代码需要手动调用的字符串,否则会导致内存泄漏。 A CString isn't only a pointer; it's a pointer plus a boolean ...
-
阿德里安指出的问题是我正在向Vec推进弦乐。 FFI需要*const libc::c_char ,它可以从String转换。 let mut urls: Vec<*const libc::c_char> = vec![]; urls.push(CString::new(string_var.value.to_string()).unwrap().into_raw()); The issue, pointed out by Adrian, was that I was pushing strings in ...
-
Rust不支持使用C ++的FFI。 如果要使用此库,则必须查找或编写一个转换层,该转换层为库提供纯C接口,然后绑定到该库。 Rust doesn't support FFI with C++. If you want to use this library, you will have to find or write a translation layer that provides a pure C interface to the library, then bind to that.
-
use std::os::raw::c_void; extern "C" { #[no_mangle] static magic: *const c_void; } 可选地,在extern之前可以有#[link(kind="static", name="
")]来获得实际链接的符号。 这个常量被声明为static ,但是使用const关键字它会失败,“extern items不能是const ”。 ¯\ _(ツ)_ /¯ use std::os::raw:: ... -
cblas_sdot函数不应该返回指针。 来自BLAS参考 : cblas_sdot 计算两个向量的点积(单精度)。 float cblas_sdot(const int N, const float *X, const int incX, const float *Y, const int incY); The cblas_sdot function is not supposed to return a pointer. From BLAS Reference: cblas_sdot Computes ...