這篇文章給大家分享的是有關(guān)linux電源管理驅(qū)動(dòng)編寫(xiě)的示例分析的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
10年積累的網(wǎng)站設(shè)計(jì)、做網(wǎng)站經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先做網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有路南免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。對(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"; };
感謝各位的閱讀!關(guān)于“l(fā)inux電源管理驅(qū)動(dòng)編寫(xiě)的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
分享題目:linux電源管理驅(qū)動(dòng)編寫(xiě)的示例分析-創(chuàng)新互聯(lián)
鏈接地址:http://www.rwnh.cn/article46/dgschg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營(yíng)銷型網(wǎng)站建設(shè)、微信公眾號(hào)、網(wǎng)站策劃、云服務(wù)器、網(wǎng)站建設(shè)、標(biāo)簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)