Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of linux Power Management driver

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shares with you the content of sample analysis written by linux power management drivers. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

For embedded devices, appropriate power management can not only prolong the battery life, but also save electricity, prolong the running time of the equipment, and have great benefits in improving user experience. Therefore, various soc manufacturers have spent a lot of efforts in this area. Next, we can take a look at how linux handles power management drivers.

1. Code directory

Drivers/regulator

2. View the Kconfig file in the directory

Menuconfig REGULATOR bool "Voltage and Current Regulator Support" help Generic Voltage and Current Regulator support. This framework is designed to provide a generic interface to voltage and current regulators within the Linux kernel. It's intended to provide voltage and current control to client or consumer drivers and also provide status information to user space applications through a sysfs interface. The intention is to allow systems to dynamically control regulator output in order to save power and prolong battery life. This applies to both voltage regulators (where voltage output is controllable) and current sinks (where current output is controllable). This framework safely compiles out if not selected so that client drivers can still be used in systems with no software controllable regulators. If unsure, say no.

3. Read the file and learn that REGULATOR is the core module macro, so we can find a device macro to have a look.

Config REGULATOR_STM32_VREFBUF tristate "STMicroelectronics STM32 VREFBUF" depends on ARCH_STM32 | | COMPILE_TEST help This driver supports STMicroelectronics STM32 VREFBUF (voltage reference buffer) which can be used as voltage reference for internal ADCs, DACs and also for external components through dedicated Vref+ pin. This driver can also be built as a module. If so, the module will be called stm32-vrefbuf.

4. If S3C is not found, you can take a look at the dependency properties of the stm32 chip, and then look at Makefile

Obj-$ (CONFIG_REGULATOR) + = core.o dummy.o fixed-helper.o helpers.o devres.o obj-$ (CONFIG_OF) + = of_regulator.o obj-$ (CONFIG_REGULATOR_FIXED_VOLTAGE) + = fixed.o obj-$ (CONFIG_REGULATOR_VIRTUAL_CONSUMER) + = virtual.o obj-$ (CONFIG_REGULATOR_USERSPACE_CONSUMER) + = userspace-consumer.o obj-$ (CONFIG_REGULATOR_STM32_VREFBUF) + = stm32-vrefbuf.o

5. You can see that stm32 only depends on the stm32-verfbuf.c file. Continue to check.

Static const struct of_device_id stm32_vrefbuf_of_match [] = {{.clients = "st,stm32-vrefbuf",}, {},}; MODULE_DEVICE_TABLE (of, stm32_vrefbuf_of_match) Static struct platform_driver stm32_vrefbuf_driver = {.probe = stm32_vrefbuf_probe, .remove = stm32_vrefbuf_remove, .driver = {.name = "stm32-vrefbuf", .of _ match_table = of_match_ptr (stm32_vrefbuf_of_match),},}; module_platform_driver (stm32_vrefbuf_driver)

6. Confirm that the driver is a platform driver, and find the unique data structure of regulator.

Static const struct regulator_ops stm32_vrefbuf_volt_ops = {.enable = stm32_vrefbuf_enable, .disable = stm32_vrefbuf_disable, .is _ enabled = stm32_vrefbuf_is_enabled, .get _ voltage_sel = stm32_vrefbuf_get_voltage_sel, .set _ voltage_sel = stm32_vrefbuf_set_voltage_sel, .list _ voltage = regulator_list_voltage_table,} Static const struct regulator_desc stm32_vrefbuf_regu = {.name = "vref", .supply _ name = "vdda", .volt _ table = stm32_vrefbuf_voltages, .n _ voltages = ARRAY_SIZE (stm32_vrefbuf_voltages), .ops = & stm32_vrefbuf_volt_ops, .type = REGULATOR_VOLTAGE, .owner = THIS_MODULE,}

7. According to the code, regulator_ops and regulator_desc are the unique regulator data structures, and of course, there are also registration functions.

Rdev = regulator_register (& stm32_vrefbuf_regu, & config); if (IS_ERR (rdev)) {ret = PTR_ERR (rdev); dev_err (& pdev- > dev, "register failed with error% d\ n", ret); goto err_clk_dis;} platform_set_drvdata (pdev, rdev)

8. To further confirm whether of_device_id really exists, you can find the corresponding content in arch/arm/boot/dts/stm32h743.dtsi.

Vrefbuf: regulator@58003C00 {compatible = "st,stm32-vrefbuf"; reg =; clocks =; regulator-min-microvolt =; regulator-max-microvolt =; status = "disabled";}; Thank you for reading! This is the end of the article on "sample Analysis of linux Power Management driver". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report