对于嵌入式设备来说,合适的电源管理,不仅可以延长电池的寿命,而且可以省电,延长设备运行时间,在提高用户体验方面有很大的好处。所以,各个soc厂家在这方面花了很多的功夫。下面,我们可以看看linux是如何处理电源管理驱动的。
1、代码目录
drivers/regulator
2、查看目录下的Kconfig文件
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、阅读文件,得知REGULATOR是最核心的模块macro,那我们可以找一个设备的macro看看
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、没有找到s3c,可以看一下stm32芯片的依赖属性,接着看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、看的出来stm32只依赖于stm32-verfbuf.c文件,继续查看
static const struct of_device_id stm32_vrefbuf_of_match[] = { { .compatible = "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、确认驱动为platform驱动,寻找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、由代码得知,regulator_ops和regulator_desc才是特有的regulator数据结构,当然也少不了注册函数
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、进一步确认of_device_id是不是真实存在,可以在arch/arm/boot/dts/stm32h743.dtsi找到对应内容
vrefbuf: regulator@58003C00 { compatible = "st,stm32-vrefbuf"; reg = <0x58003C00 0x8>; clocks = <&rcc VREF_CK>; regulator-min-microvolt = <1500000>; regulator-max-microvolt = <2500000>; status = "disabled"; };
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
2024年12月24日
2024年12月24日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]