深入理解Linux时钟驱动:从基础到实战
1. 编写时钟驱动程序
在Linux系统中,时钟驱动程序的编写至关重要。我们可以根据需求实现自己的解码器回调,就像max9485音频时钟生成器那样,其驱动代码位于内核源码树的 drivers/clk/clk-max9485.c 中。
编写时钟驱动时,将 struct clk_hw 完整嵌入到自定义的大数据结构中是个不错的做法。以下是相关示例代码:
/* forward reference */
struct max9485_driver_data;
struct max9485_clk_hw {
struct clk_hw hw;
struct clk_init_data init;
u8 enable_bit;
struct max9485_driver_data *drvdata;
};
struct max9485_driver_data {
struct clk *xclk;
struct i2c_client *client;
u8 reg_value;
struct regulator *supply;
struct gpio_desc *reset_gpio;
struct max9485_clk_hw hw[MAX9485_NUM_CLKS];
};
static inline struct max9485_clk_hw
*to_max9485_clk(struct clk_hw *hw)
{
return container
超级会员免费看
订阅专栏 解锁全文
1373

被折叠的 条评论
为什么被折叠?



