In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you the "sample analysis of pwm drivers in linux", which is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and study the "sample analysis of pwm drivers in linux".
Pwm square wave can be used to control many devices, for example, it can be used to control motors. To put it simply, the more square waves per unit time, the faster the speed of the motor will be, and vice versa. Through this feature, soc can easily use pwm peripherals for automatic control.
1. Driver directory
Drivers/pwm
2. Check the Kconfig in the corresponding directory
Config PWM_SAMSUNG tristate "Samsung PWM support" depends on PLAT_SAMSUNG | | ARCH_EXYNOS help Generic PWM framework driver for Samsung. To compile this driver as a module, choose M here: the module will be called pwm-samsung.
3. Make sure that PWM_SAMSUNG is only dependent on you, and continue to watch Makefile
Obj-$ (CONFIG_PWM) + = core.oobj-$ (CONFIG_PWM_SAMSUNG) + = pwm-samsung.o
4. Consult the pwm-samsung.c file according to Makefile, the structure is relatively clear
Static struct platform_driver pwm_samsung_driver = {.driver = {.name = "samsung-pwm", .pm = & pwm_samsung_pm_ops, .of _ match_table = of_match_ptr (samsung_pwm_matches),}, .probe = pwm_samsung_probe, .remove = pwm_samsung_remove,}; module_platform_driver (pwm_samsung_driver)
5. Most of the soc devices are platform devices. Continue to look for useful information in the probe function.
Ret = pwmchip_add (& chip- > chip); if (ret
< 0) { dev_err(dev, "failed to register PWM chip\n"); clk_disable_unprepare(chip->Base_clk); return ret;}
6. after you find the registration function, continue to see where the interface point of the function is.
Static const struct pwm_ops pwm_samsung_ops = {.request = pwm_samsung_request, .free = pwm_samsung_free, .enable = pwm_samsung_enable, .disable = pwm_samsung_disable, .config = pwm_samsung_config, .set _ polarity = pwm_samsung_set_polarity, .owner = THIS_MODULE,}
7. Pwm devices do not have interrupt functions, which usually take effect immediately. In addition, there is still the content of the device tree in the code. You can take a look at it.
Static const struct of_device_id samsung_pwm_matches [] = {{.girls = "samsung,s3c2410-pwm", .data = & s3c24xx_variant}, {.records = "samsung,s3c6400-pwm", .data = & s3c64xx_variant}, {.records = "samsung,s5p6440-pwm", .data = & s5p64x0_variant}, {.records = "samsung,s5pc100-pwm", .data = & s5pc100_variant}, {.records = "samsung,exynos4210-pwm" .data = & s5p64x0_variant}, {},} MODULE_DEVICE_TABLE (of, samsung_pwm_matches); static int pwm_samsung_parse_dt (struct samsung_pwm_chip * chip) {struct device_node * np = chip- > chip.dev- > of_node; const struct of_device_id * match; struct property * prop; const _ be32 * cur; U32 val; match = of_match_node (samsung_pwm_matches, np); if (! match) return-ENODEV; memcpy (& chip- > variant, match- > data, sizeof (chip- > variant)) Of_property_for_each_u32 (np, "samsung,pwm-outputs", prop, cur, val) {if (val > = SAMSUNG_PWM_NUM) {dev_err (chip- > chip.dev, "% s: invalid channel index in samsung,pwm-outputs property\ n", _ _ func__); continue;} chip- > variant.output_mask | = BIT (val);} return 0 } these are all the contents of the article "sample Analysis written by pwm drivers in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.