欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解linux電源管理驅(qū)動(dòng)編寫

 更新時(shí)間:2018年04月13日 09:36:31   作者:feixiaoxing  
這篇文章主要介紹了詳解linux電源管理驅(qū)動(dòng)編寫,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

對(duì)于嵌入式設(shè)備來(lái)說(shuō),合適的電源管理,不僅可以延長(zhǎng)電池的壽命,而且可以省電,延長(zhǎng)設(shè)備運(yùn)行時(shí)間,在提高用戶體驗(yàn)方面有很大的好處。所以,各個(gè)soc廠家在這方面花了很多的功夫。下面,我們可以看看linux是如何處理電源管理驅(qū)動(dòng)的。

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,那我們可以找一個(gè)設(shè)備的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、沒(méi)有找到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、看的出來(lái)stm32只依賴于stm32-verfbuf.c文件,繼續(xù)查看

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、確認(rèn)驅(qū)動(dòng)為platform驅(qū)動(dòng),尋找regulator特有的數(shù)據(jù)結(jié)構(gòu)

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數(shù)據(jù)結(jié)構(gòu),當(dāng)然也少不了注冊(cè)函數(shù)

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、進(jìn)一步確認(rèn)of_device_id是不是真實(shí)存在,可以在arch/arm/boot/dts/stm32h743.dtsi找到對(duì)應(yīng)內(nèi)容

vrefbuf: regulator@58003C00 { 
  compatible = "st,stm32-vrefbuf"; 
  reg = <0x58003C00 0x8>; 
  clocks = <&rcc VREF_CK>; 
  regulator-min-microvolt = <1500000>; 
  regulator-max-microvolt = <2500000>; 
  status = "disabled"; 
}; 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • LNMP部署及HTTPS服務(wù)開啟教程

    LNMP部署及HTTPS服務(wù)開啟教程

    本文主要給大家介紹的是LNMP環(huán)境的部署以及開啟https服務(wù)的方法和示例,有需要的小伙伴可以參考下
    2018-11-11
  • linux中 shell 歷史命令記錄功能

    linux中 shell 歷史命令記錄功能

    這篇文章主要介紹了在 Linux 下面可以使用 history 命令查看用戶的所有歷史操作的一些詳細(xì)配置小技巧,非常的簡(jiǎn)單實(shí)用,有需要的朋友可以參考下
    2014-10-10
  • 基于centos7 安裝python3.6.4出錯(cuò)的解決方法

    基于centos7 安裝python3.6.4出錯(cuò)的解決方法

    下面小編就為大家分享一篇基于centos7 安裝python3.6.4出錯(cuò)的解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-01-01
  • Linux漏洞掃描工具lynis使用方法解析

    Linux漏洞掃描工具lynis使用方法解析

    這篇文章主要介紹了Linux漏洞掃描工具lynis使用方法解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-08-08
  • VMware虛擬機(jī)安裝 CentOS 8 (1905)系統(tǒng)的教程圖解

    VMware虛擬機(jī)安裝 CentOS 8 (1905)系統(tǒng)的教程圖解

    這篇文章主要介紹了CentOS 8 (1905)系統(tǒng)安裝,本文圖文并茂給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-09-09
  • Linux系統(tǒng)下如何創(chuàng)建普通用戶并更改用戶組

    Linux系統(tǒng)下如何創(chuàng)建普通用戶并更改用戶組

    這篇文章主要介紹了Linux系統(tǒng)下如何創(chuàng)建普通用戶并更改用戶組問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • Linux shell tr 命令詳解

    Linux shell tr 命令詳解

    這篇文章主要介紹了Linux shell tr 命令詳解的相關(guān)資料,需要的朋友可以參考下
    2017-01-01
  • CentOS 7.6安裝MySQL 5.7 GA版的教程圖解

    CentOS 7.6安裝MySQL 5.7 GA版的教程圖解

    本文通過(guò)圖文并茂的形式給大家介紹了CentOS 7.6安裝MySQL 5.7 GA版,需要的朋友可以參考下
    2019-09-09
  • Nginx+PHP+MySQL雙機(jī)互備、全自動(dòng)切換方案

    Nginx+PHP+MySQL雙機(jī)互備、全自動(dòng)切換方案

    在生產(chǎn)應(yīng)用中,某臺(tái)“Nginx+PHP+MySQL”接口數(shù)據(jù)服務(wù)器,扮演的角色十分重要,如果服務(wù)器硬件或Nginx、MySQL發(fā)生故障,而短時(shí)間內(nèi)無(wú)法恢復(fù),后果將非常嚴(yán)重。為了避免單點(diǎn)故障,我設(shè)計(jì)了此套方案,編寫了failover.sh腳本,實(shí)現(xiàn)了雙機(jī)互備、全自動(dòng)切換,故障轉(zhuǎn)移時(shí)間只需幾十秒。
    2008-12-12
  • Linux中Netcat命令整理

    Linux中Netcat命令整理

    本篇文章給大家整理了Linux中Netcat的命令以及命令的功能詳解,一起學(xué)習(xí)下。
    2018-02-02

最新評(píng)論