一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Linux|Centos|Ubuntu|系統進程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務器之家 - 服務器系統 - Linux - 詳解linux電源管理驅動編寫

詳解linux電源管理驅動編寫

2022-03-07 16:48feixiaoxing Linux

這篇文章主要介紹了詳解linux電源管理驅動編寫,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

對于嵌入式設備來說,合適的電源管理,不僅可以延長電池的壽命,而且可以省電,延長設備運行時間,在提高用戶體驗方面有很大的好處。所以,各個soc廠家在這方面花了很多的功夫。下面,我們可以看看linux是如何處理電源管理驅動的。

1、代碼目錄

?
1
drivers/regulator

2、查看目錄下的Kconfig文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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看看 

?
1
2
3
4
5
6
7
8
9
10
11
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

?
1
2
3
4
5
6
7
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文件,繼續查看

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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特有的數據結構

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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數據結構,當然也少不了注冊函數

?
1
2
3
4
5
6
7
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找到對應內容

?
1
2
3
4
5
6
7
8
vrefbuf: regulator@58003C00 {
  compatible = "st,stm32-vrefbuf";
  reg = <0x58003C00 0x8>;
  clocks = <&rcc VREF_CK>;
  regulator-min-microvolt = <1500000>;
  regulator-max-microvolt = <2500000>;
  status = "disabled";
};

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

原文鏈接:https://blog.csdn.net/feixiaoxing/article/details/79874311

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 免费看美女被靠到爽的视频 | 国产剧情一区二区三区 | 2048论坛永久入口 原创合集 | bt天堂在线最新版在线 | 国产成人精品日本亚洲网站 | 双性受合不垅腿攻np | 免费高清视频在线观看 | 青青青久在线视频免费观看 | 91热国内精品永久免费观看 | 日日碰日日操 | 亚洲国产视频一区 | 亚洲国产天堂在线观看 | 久久精品WWW人人爽人人 | zol中关村在线官网 yy6080欧美三级理论 | 白鹿扒开内裤露出尿孔 | 欧美同志gaypronvideos | 福利一区二区在线观看 | 性白俄罗斯高清xxxxx | 久久国产伦子伦精品 | 欧美在线一二三区 | 操国产美女 | 国产精品久久久久久久久久久搜索 | 欧美在线观看视频一区 | 精品在线播放 | 精品国产午夜久久久久九九 | 91在线视频免费观看 | 娇妻与公陈峰姚瑶小说在线阅读 | 精品国产美女福利在线 | 9总探花新品牛仔背带裤 | 99撸| 猛h辣h高h文湿校园1v1 | 亚瑟天堂久久一区二区影院 | 无人在线观看免费高清视频播放 | 亚洲精品中文字幕久久久久久 | 好 舒服 好 粗 好硬免费视频 | 亚洲黑人巨大videos0 | 国产亚洲视频网站 | 国产剧情一区二区三区 | 无人影院在线播放 | 亚洲视频第一页 | 美女脱小内内给男生摸j |