Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Clock Architecture

In Linux how is the Clock Architecture implemented. There is a file include/linux/clkdev.h

struct clk_lookup {
    struct list_head    node;
    const char      *dev_id;
    const char      *con_id;
    struct clk      *clk;
};

What are the various fields and it is extensively used in Clock architecture in arch/arm/Board***/... ?

like image 551
shingaridavesh Avatar asked Mar 06 '13 05:03

shingaridavesh


Video Answer


1 Answers

The generic Linux clock infra-structure is documented in clk.rst. For the ARM, Sasha Hauer created the common clock frame-work recently (last two years). The clocks are structured in a parent/child relation. Typical SOC (system on chip) has main clocks created from a crystal which are either scaled down (with a counter) or up with a PLL and maybe both. They hierarchy is important for power savings. Usually devices are only using one of the lowest/youngest clocks in the tree. When a device requests a clock, the infra-structure ensures that all parents are started.

Previously (legacy), clocks were passed from the machine file (reference arch/arm/Board***/) to the driver/device via platform data; ultimately through platform_device_register(). Sometimes, the clocks were/are derived from the device name. For example the fec driver might use fec-clk. This did not work well for multiple machine configurations, so the platform data mechanism was introduced. Even newer machinery uses a dt (or device table). Here, there are no machine files, only a device table that is passed from the boot loader to the kernel. In this case, the dt tells the driver which clock to use.

Originally, the dev_id and con_id were to relate clocks for a device and clocks that are connected (parent/child). Usually either dev_id or con_id are NULL as only one aspect is needed. I think that this view was found wanting; especially for starting an entire clock chain. So, depending on the Linux version, the answer varies. Even in the current source, some platforms (like orion) still use an older mechanism. I don't think orion supports device trees.

Specific answers will depend on your Linux version and the machine (and possibly platform) in use.
See also: clkdev.c, clk.c

Open source - There are many mutations. They all have a different plan.BSG re-imaged

Reference: Russell Kings message on ARM clkdev, original did not imply ordering.

like image 167
artless noise Avatar answered Oct 05 '22 11:10

artless noise