Writing a clock provider driver
While the purpose of a device tree is to describe the hardware at hand (the clock provider, in this case), it is worth noting that the code used to manage the underlying hardware needs to be written. This section deals with writing code for clock providers so that once their clock lines have been assigned to consumers, they behave the way they were designed to. When writing clock device drivers, it is a good practice to embed the full struct clk_hw
(not a pointer) into your private and bigger data structure, since it is given as the first parameter to each callback in clk_ops
. This lets you define a custom to_<my-data-structure>
helper upon the container_of
macro, which gives you back a pointer to your private data structure, as follows:
/* forward reference */ struct max9485_driver_data; struct max9485_clk_hw { struct clk_hw hw; struct clk_init_data init; u8 enable_bit...