【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing @163.com】

对于嵌入式设备来说,合适的电源管理,不仅可以延长电池的寿命,而且可以省电,延长设备运行时间,在提高用户体验方面有很大的好处。所以,各个soc厂家在这方面花了很多的功夫。下面,我们可以看看linux是如何处理电源管理驱动的。

1、代码目录

drivers/regulator

2、查看目录下的Kconfig文件

menuconfig REGULATORbool "Voltage and Current Regulator Support"helpGeneric Voltage and Current Regulator support.This framework is designed to provide a generic interface to voltageand current regulators within the Linux kernel. It's intended toprovide voltage and current control to client or consumer drivers andalso provide status information to user space applications through asysfs interface.The intention is to allow systems to dynamically control regulatoroutput in order to save power and prolong battery life. This appliesto both voltage regulators (where voltage output is controllable) andcurrent sinks (where current output is controllable).This framework safely compiles out if not selected so that clientdrivers can still be used in systems with no software controllableregulators.If unsure, say no.

3、阅读文件,得知REGULATOR是最核心的模块macro,那我们可以找一个设备的macro看看

config REGULATOR_STM32_VREFBUFtristate "STMicroelectronics STM32 VREFBUF"depends on ARCH_STM32 || COMPILE_TESThelpThis driver supports STMicroelectronics STM32 VREFBUF (voltagereference buffer) which can be used as voltage reference forinternal ADCs, DACs and also for external components throughdedicated Vref+ pin.This driver can also be built as a module. If so, the modulewill 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.oobj-$(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";};

linux驱动编写(电源管理驱动)相关推荐

  1. 关闭linux服务器电源,linux关闭ACPI电源管理模块

    一.运行环境 # cat /etc/redhat-release CentOS release 6.2 (Final) # uname -a Linux web-server- 2.6.-.el6.x ...

  2. Linux内核配置电源管理

    最近测试板子辐射比较高,希望能在运行时降低功耗和辐射,CPU这部分没啥用到,可以降! [*] Power Management support //如果你想让你的Linux支持高级电源管理(也就是平常 ...

  3. android电源驱动程序,[转]Android虚拟电源管理驱动

    Android系统如果没有电源管理相关的驱动程序,在启动时将会提示如下错误: I/SystemServer(   50): Starting Battery Service. E/BatterySer ...

  4. Linux运行911,韦东山-Linux下编写GT911触摸驱动 - 百问网嵌入式问答社区

    源码在最下面 问题一:资源获取Gt911数据手册 在韦老师给的资料里,路径为\06_Datasheet\Extend_modules\7寸LCD模块\电容触控芯片GT911 Datasheet_121 ...

  5. WinCE电源管理----驱动增加电源管理属性

    原文地址::http://www.cnblogs.com/we-hjb/archive/2010/01/27/1657973.html 对于移动设备来说,电源管理是比较重要的.为了让设备有更长的待机和 ...

  6. linux驱动编写(pwm驱动)

    [ 声明:版权所有,欢迎转载,请勿用于商业用途. 联系信箱:feixiaoxing @163.com] pwm方波可以用来控制很多的设备,比如它可以被用来控制电机.简单来说,就是单位时间内的方波越多, ...

  7. Linux内核学习--电源管理

    目录 一.引言 二.电源管理 ------> 2.1.电源管理的两种模型 三.系统Suspend ------> 3.1.系统睡眠模型Suspend ------> 3.2.开启su ...

  8. linux时钟与电源管理,SOC的时钟和电源管理

    SOC的时钟和电源管理 (2013-04-27 18:58:07) 标签: it dm3730 时钟 linux 电源 现在的SOC,因为多用做手持设备,所以在节省能源方面都不遗余力.我看原因到不是为 ...

  9. android Sensor 驱动编写--opt3001光感驱动为例

    分析Android sensor Android sensor Framework 层以及APP如何读取sensor 数据.网上有很多文章不再累述. 由于我使用的是Android 5.1(kernel ...

最新文章

  1. html 怎么播放avi视频,iPhone4S视频格式播放巧用苹果转换器
  2. wordpress上传主题错误解决方法
  3. am.java_6.3.1 从am说起
  4. linux mysql 5.6.24_Mysql实例Linux安装MySQL5.6.24使用文字说明
  5. 160 - 11 Andrnalin.4
  6. SpringMvc+Tomcat+Angular4 部署运行
  7. pycharm里创建django项目竟然没有django选项
  8. 在X++中使用IoC/DI模式应对不断变化的客户需求
  9. python 归一化还原_对python3 一组数值的归一化处理方法详解
  10. html中不支持什么元素,HTML中不支持静态Expando的元素的问题
  11. 基于自抗扰控制的压力环控制算法研究
  12. 电容或电感的电压_眼见不一定为实!电阻、电容和电感的实际等效模型
  13. 酒类企业1919获阿里20亿入股 已与天猫及饿了么有深度合作
  14. 【MyBatis】缓存——使查询变得快快快!
  15. 校验码——海明码及码距,码距
  16. 纯css实现的娃娃机web前端html页面源码
  17. 【YOLOv5 数据集划分】训练和验证、训练验证和测试(train、val)(train、val、test)
  18. 【pandas问题】UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xca in position 0: invalid continuati
  19. java web开发实训心得,【JavaWeb实训心得体会材料】
  20. $‘\r‘: command not found,syntax error near unexpected token `$‘in\r‘‘

热门文章

  1. 收集一些常用的CDN链接!无需下载快速使用!
  2. commons-fileupload实现单次上传文件(word文档)
  3. 用户名错误则一直登录
  4. layer.prompt添加多个输入框
  5. JQuery实现轮播图及其原理
  6. kubernetes资源管理
  7. VI中的多行删除与复制
  8. 面试题:判断字符串是否回文
  9. mysql创建视图不允许子查询
  10. 微信小程序之----问题