Linux Device Driver clock management (3) ---- my cake

Source: Internet
Author: User

Linux Device Driver clock management (3) ---- my cake

What is missing in the 21st century? There is no shortage of programmers, no shortage of diaosi programmers, programmers everywhere, various training institutions, more than n programmers are born every month, they replace those who are far away from this industry from generation to generation. It is said that programmers have a lot of realm, such as me, which is a relatively impetuous programmer, thinking that they will have a lot of things, in fact, nothing.

After a long time, I found myself having no real things. Why? No, at least the cool programmer has a dream that he may eat a cake every day.

Recently, the three military regions of the motherland have all acted. What long-distance ballistic missiles and huge waves have brought the east wind to the ground. We have to fight with Japan to eat two more cakes while we are still in peace, I don't know if I have a chance to eat it tomorrow.

How can I get the cake from the clock management side?

Line 80: You can see that the dev_id is actually the name of the device.

Line 81 sets another layer, ah, short and refined functions. No nonsense ..

Row 68 locks the mutex lock. This mutex lock is global and looks good to you:

Line 69 calls the clk_find function based on the two IDs to find the required clk.

There are 40 rows of A for loop, which is traversed in the global linked list of clocks. All the locks are linked to it.

Lines 42-46. If dev_id matches, match + = 2

47-50 rows. If the con_id matches, match + = 1

If the mach value is greater than zero, it indicates that there is a match later. If match = 3, both conditions match. This is the perfect situation. If not, continue the loop.

We can see from the comments that the priority of matching is: dev + con> dev only> con only

Okay. Return to the clk_get_sys function.

70th-71 if no cl is found, set it to NULL.

72 rows release lock

73 rows return the target clk

This process is also very simple, not as complicated as you think.

Haha .. I got the clock. Are you interested in checking their enable and disable the functions that set the frequency? In fact, they are also very simple. They are all platform-related. Let's look at a function using Samsung's s3c2410 as an example. Other functions are similar to it. You don't have to talk about it any more, let's look at a common code:

This is a general function of the Samsung platform. Other functions, such as 2410,6410, can be used because they are separated from the specific board level, all operations are implemented using a function pointer.

Rows 90-90 judge the validity of a clk, reflecting a good example of a robust function

Line 92: You can see that it is called again. It is clearly a fucking nesting, but you can see a parameter .. You can understand it. To enable a device's clock, you must make sure that the clock of its parent device is enabled.

You can see lines 94-99 .. Interruption is prohibited during enabling.

97 rows, directly call the clk structure of the enable function, this is achieved in the specific board-level file, for us here is the s3c2410-clock.c, okay, go and have a look, kiss.

You see, dear, all their enable functions point to the same function: s3c2410_clkcon_enable. Do you have any questions? This function is very powerful. What kind of capabilities can it handle? You don't know if you go in. Walk you:

Haha .. Why did you suddenly realize it? Haha .. Okay, you're a success .. Haha .. As you can see, it depends on the Control Mark clk-> ctrlbit, which is implemented by the corresponding bit of the clock controller in the write controller. Sorry, I am tired of talking about it.

Let me have a rest. Listen to songs .. You can continue learning. I have to rest. I have to wait for a while. Weeping, beautiful women are gone!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.