当前位置: 首页 > news >正文

【linux】regulartor-fixed

作用:创建一个固定的 regulator。一般是一个 GPIO 控制了一路电,只有开(enable) \ 关(disabled)两种操作。

device-tree node

io_vdd_en: regulator-JW5217DFND {compatible = "regulator-fixed";pinctrl-names = "default";pinctrl-0 = <&io_vdd_en_pins_default>;gpios = <&wkup_gpio0 69 GPIO_ACTIVE_HIGH>;regulator-name = "jw5217dfnd";regulator-min-microvolt = <3300000>;regulator-max-microvolt = <3300000>;regulator-always-on;regulator-boot-on;enable-active-high;vin-supply = <&vsys_3v3>;
};

解析:

compatible

compatible = “regulator-fixed”;

固定的 regulator。特点:不能控制电压,只能 enable 和 disabled,没设备用的时候自动关电(disabled)。相关代码如下:

// drivers/regulator/fixed.cstatic const struct regulator_ops fixed_voltage_ops = {
};static const struct regulator_ops fixed_voltage_clkenabled_ops = {.enable = reg_clock_enable,.disable = reg_clock_disable,.is_enabled = reg_clock_is_enabled,
};static const struct of_device_id fixed_of_match[] = {{.compatible = "regulator-fixed",.data = &fixed_voltage_data,},{.compatible = "regulator-fixed-clock",.data = &fixed_clkenable_data,},{},
};static struct platform_driver regulator_fixed_voltage_driver = {.probe		= reg_fixed_voltage_probe,.driver		= {.name		= "reg-fixed-voltage",.of_match_table = of_match_ptr(fixed_of_match),},
};static int reg_fixed_voltage_probe(struct platform_device *pdev)
{struct fixed_voltage_data *drvdata;drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data),GFP_KERNEL);...if (drvtype && drvtype->has_enable_clock) {drvdata->desc.ops = &fixed_voltage_clkenabled_ops;drvdata->enable_clock = devm_clk_get(dev, NULL);if (IS_ERR(drvdata->enable_clock)) {dev_err(dev, "Can't get enable-clock from devicetree\n");return -ENOENT;}} else {drvdata->desc.ops = &fixed_voltage_ops;}...}

gpios

gpios = <&wkup_gpio0 69 GPIO_ACTIVE_HIGH>;
控制电的 GPIO。开电时(enabled)的将 GPIO 置为有效电平,关电时(disabled)置为无效电平。相关代码如下:

// drivers/regulator/fixed.cstatic int reg_fixed_voltage_probe(struct platform_device *pdev)
{...cfg.ena_gpiod = gpiod_get_optional(&pdev->dev, NULL, gflags);if (IS_ERR(cfg.ena_gpiod))return PTR_ERR(cfg.ena_gpiod);...
}
// drivers/regulator/core.creg_fixed_voltage_probe-> devm_regulator_register-> regulator_register-> regulator_ena_gpio_requeststatic int regulator_ena_gpio_request(struct regulator_dev *rdev,const struct regulator_config *config)
{struct regulator_enable_gpio *pin, *new_pin;struct gpio_desc *gpiod;gpiod = config->ena_gpiod;new_pin = kzalloc(sizeof(*new_pin), GFP_KERNEL);...pin = new_pin;pin->gpiod = gpiod;rdev->ena_pin = pin;...
}

regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator 最小及最大电压限制。对于 regulator-fixed 无实际意义。
regulator-always-on;
一直开电,防止因其他原因被关电,否则需要在其他驱动中获取此 regulator 来手动控制:regulator_enable() \ regulator_disable()。
当指定了此选项后,会有一个的虚拟设备一直在使用此 regulator,可通过如下命令查看到:

cat /sys/class/regulator/regulator.*/num_users      # 查看有多少个设备在使用此 regulator
cat /sys/class/regulator/regulator.*/state          # 查看此 regulator 的状态:enabled or disabled

regulator-boot-on;
开机时自动上电。注意:若一段时间内无设备在使用此 regulator,则会自动关电(猜测应该和系统低功耗有关),因此必须加上 regulator-always-on。

相关代码如下:

// drivers/regulator/of_regulator.creg_fixed_voltage_probe-> of_get_fixed_voltage_config-> of_get_regulator_init_data-> of_get_regulation_constraintsstatic int of_get_regulation_constraints(struct device *dev,struct device_node *np,struct regulator_init_data **init_data,const struct regulator_desc *desc)
{struct regulation_constraints *constraints = &(*init_data)->constraints;... constraints->boot_on = of_property_read_bool(np, "regulator-boot-on");constraints->always_on = of_property_read_bool(np, "regulator-always-on");...
}
// drivers/regulator/core.creg_fixed_voltage_probe-> devm_regulator_register-> regulator_register-> set_machine_constraintsstatic int set_machine_constraints(struct regulator_dev *rdev)
{...if (rdev->constraints->always_on || rdev->constraints->boot_on) {/* If we want to enable this regulator, make sure that we know* the supplying regulator.*/if (rdev->supply_name && !rdev->supply)return -EPROBE_DEFER;if (rdev->supply) {ret = regulator_enable(rdev->supply);if (ret < 0) {_regulator_put(rdev->supply);rdev->supply = NULL;return ret;}}ret = _regulator_do_enable(rdev);if (ret < 0 && ret != -EINVAL) {rdev_err(rdev, "failed to enable: %pe\n", ERR_PTR(ret));return ret;}if (rdev->constraints->always_on)rdev->use_count++;}...
}
// drivers/regulator/core.creg_fixed_voltage_probe-> devm_regulator_register-> regulator_register-> set_machine_constraints-> _regulator_do_enablestatic int _regulator_do_enable(struct regulator_dev *rdev)
{...if (rdev->ena_pin) {if (!rdev->ena_gpio_state) {ret = regulator_ena_gpio_ctrl(rdev, true);if (ret < 0)return ret;rdev->ena_gpio_state = 1;}} else if (rdev->desc->ops->enable) {ret = rdev->desc->ops->enable(rdev);if (ret < 0)return ret;} else {return -EINVAL;}...
}
// drivers/regulator/core.creg_fixed_voltage_probe-> devm_regulator_register-> regulator_register-> set_machine_constraints-> _regulator_do_enable-> regulator_ena_gpio_ctrlstatic int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
{struct regulator_enable_gpio *pin = rdev->ena_pin;if (!pin)return -EINVAL;if (enable) {/* Enable GPIO at initial use */if (pin->enable_count == 0)gpiod_set_value_cansleep(pin->gpiod, 1);pin->enable_count++;} else {if (pin->enable_count > 1) {pin->enable_count--;return 0;}/* Disable GPIO if not used */if (pin->enable_count <= 1) {gpiod_set_value_cansleep(pin->gpiod, 0);pin->enable_count = 0;}}return 0;
}

自动关电的代码:

// drivers/regulator/core.cregulator_init_complete_work_function-> regulator_late_cleanup-> _regulator_do_disable-> regulator_ena_gpio_ctrl-> gpiod_set_value_cansleepstatic void regulator_init_complete_work_function(struct work_struct *work)
{/** Regulators may had failed to resolve their input supplies* when were registered, either because the input supply was* not registered yet or because its parent device was not* bound yet. So attempt to resolve the input supplies for* pending regulators before trying to disable unused ones.*/class_for_each_device(&regulator_class, NULL, NULL,regulator_register_resolve_supply);/* If we have a full configuration then disable any regulators* we have permission to change the status for and which are* not in use or always_on.  This is effectively the default* for DT and ACPI as they have full constraints.*/class_for_each_device(&regulator_class, NULL, NULL,regulator_late_cleanup);
}static DECLARE_DELAYED_WORK(regulator_init_complete_work,regulator_init_complete_work_function);

enable-active-high;
指定 enable GPIO 的有效电平为高(默认为低),仅适用于 regulator。在这里,GPIO 属性中的 GPIO_ACTIVE_xxx 不起作用(建议两者设置成一致,否则会有警告)。相关代码如下:

// drivers/gpio/gpiolib-of.cstatic void of_gpio_flags_quirks(struct device_node *np,const char *propname,enum of_gpio_flags *flags,int index)
{/** Some GPIO fixed regulator quirks.* Note that active low is the default.*/if (IS_ENABLED(CONFIG_REGULATOR) &&(of_device_is_compatible(np, "regulator-fixed") ||of_device_is_compatible(np, "reg-fixed-voltage") ||(!(strcmp(propname, "enable-gpio") &&strcmp(propname, "enable-gpios")) &&of_device_is_compatible(np, "regulator-gpio")))) {bool active_low = !of_property_read_bool(np,"enable-active-high");/** The regulator GPIO handles are specified such that the* presence or absence of "enable-active-high" solely controls* the polarity of the GPIO line. Any phandle flags must* be actively ignored.*/if ((*flags & OF_GPIO_ACTIVE_LOW) && !active_low) {pr_warn("%s GPIO handle specifies active low - ignored\n",of_node_full_name(np));*flags &= ~OF_GPIO_ACTIVE_LOW;}if (active_low)*flags |= OF_GPIO_ACTIVE_LOW;}...
}

相关文章:

【linux】regulartor-fixed

作用&#xff1a;创建一个固定的 regulator。一般是一个 GPIO 控制了一路电&#xff0c;只有开&#xff08;enable&#xff09; \ 关&#xff08;disabled&#xff09;两种操作。 device-tree node io_vdd_en: regulator-JW5217DFND {compatible "regulator-fixed"…...

11年408考研真题解析-计算机网络

第一题&#xff1a; 解析&#xff1a;网络层虚电路服务和数据报服务 传输服务只有&#xff1a;有连接可靠和无连接不可靠两种&#xff0c;直接排除BC。 网络层指的是IP协议&#xff0c;由图二可知&#xff1a;运输层&#xff0c;网际层&#xff0c;网络接口层唯一有连接可靠的协…...

wireshark使用要点

目录 IP过滤 端口过滤 内容过滤 过滤udp 过滤tcp IP过滤 ip.src XXX.XXX.XXX.XXX 只显示消息源地址为XXX.XXX.XXX.XXX的信息 ip.dst XXX.XXX.XXX.XXX 只显示消息目的地址为XXX.XXX.XXX.XXX的信息 ip.addr XXX.XXX.XXX.XXX显示消息源地址为XXX.XXX.XXX.XXX&#xff0…...

WebGL扩展与WebGPU

目录 WebGPU扩展的探索使用实验性或未标准化的特性示例:使用纹理压缩扩展多视口渲染自定义着色器阶段可变多重采样抗锯齿...

基于小安派AiPi-Eyes-Rx的N合1触摸屏游戏

基于小安派AiPi-Eyes-Rx的N合1触摸屏游戏 目前存在的游戏&#xff1a; 植物大战僵尸&#xff1a;demos/pvz羊了个羊&#xff1a;demos/yang消消乐&#xff1a;demos/xiaoxiaole华容道&#xff1a;demos/huarongdao PVZ功能展示可见&#xff1a; 羊了个羊&#xff1a; 消消…...

Java List sort() 排序

sort是java.util.List接口的默认方法。 List的排序方法在Java 8中被引入。 排序方法接受比较器作为参数&#xff0c;并根据指定的比较器对这个列表进行排序。 default void sort(Comparator<? super E> c) 示例代码&#xff1a; import java.text.Collator; import …...

Vue.js 与 Flask 或 Django 后端配合

Vue.js 与 Flask 或 Django 后端配合是一种常见的全栈开发方式&#xff0c;用于构建动态且响应迅速的 Web 应用程序。Vue.js 是一个用于构建用户界面的渐进式 JavaScript 框架&#xff0c;而 Flask 和 Django 是 Python 语言的两个非常流行的 Web 框架。下面将分别介绍 Vue.js …...

抽奖拼团卷轴模式系统开发小程序源代码解析

在当今的互联网商业环境中&#xff0c;抽奖、拼团与卷轴模式等创新玩法被广泛应用于小程序开发中&#xff0c;旨在通过多样化的互动方式吸引用户参与&#xff0c;提升用户粘性和平台活跃度。本文将围绕“抽奖拼团卷轴模式系统开发小程序源代码”这一主题&#xff0c;探讨其技术…...

MySql语言操作数据库---增删改查数据库,表,数据

思维导图 SQL语言共分为四大类&#xff1a; 数据定义语言DDL:数据定义语言DDL用来创建数据库中的各种对象-----[库]、[表]、[视图]、[索引]、 数据操纵语言DML:(1) 插入&#xff1a;INSERT (2) 更新&#xff1a;UPDATE (3) 删除&#xff1a;DELETE 数据查询语言DQL:数据查询语…...

C++深入学习string类成员函数(2):容器管理

引言 C 标准库中的容器&#xff08;如 std::string、std::vector、std::list 等&#xff09;都提供了一系列容器管理成员函数&#xff0c;用于处理容器的大小、容量、清空等操作。容器管理成员函数可以分为几类&#xff0c;主要包括容量查询、修改容器大小、清空容器等操作。 …...

MariaDB 和 MySQL 全面对比:选择数据库需要考虑这几点

谁在使用 MySQL 和 MariaDB&#xff1f; MySQL 和 MariaDB 都发布了各自的用户名单。 使用 MySQL 的有 Facebook、Github、YouTube、Twitter、PayPal、诺基亚、Spotify、Netflix 等。 使用 MariaDB 的有 Redhat、DBS、Suse、Ubuntu、1&#xff06;1、Ingenico 等。 功能比较…...

Python 实现图形学几何变换算法

目录 Python 实现图形学几何变换算法几何变换介绍变换矩阵Python 实现几何变换代码解释总结 Python 实现图形学几何变换算法 在计算机图形学中&#xff0c;几何变换是非常重要的概念。它们允许我们对对象的位置、大小、方向进行操作&#xff0c;比如平移、缩放、旋转、反射等。…...

接口测试|超详细面试题【附答案】

今天给姐妹们整理了一套超详细的附答案的接口测试面试题&#xff0c;姐妹们快学起来吧~ 接口测试的重要性&#xff0c;相信不用我多说了。接口测试是现在软件测试工程师一个加分项。因为很多朋友一开始做了几年的软件测试都是在做功能测试&#xff0c;做界面UI的测试&#xff…...

Qt网络编程——QTcpServer和QTcpSocket

文章目录 核心APITCP回显服务器TCP回显客户端 核心API QTcpServer用于监听端口和获取客户端连接 名称类型说明对标原生APIlisten(const QHostAddress&, quint16 port)方法绑定指定的地址和端口号&#xff0c;并开始监听bind和listennextPendingConnection()方法从系统中获…...

CentOS 7 aarch64制作openssh 9.9p1 rpm包 —— 筑梦之路

本篇文章还是基于开源项目openssh-rpms制作。 https://github.com/boypt/openssh-rpms.git 官方发行说明&#xff1a; OpenSSH: Release Notes 1. 修改version.env 2. 下载源码包 openssl网站改版&#xff0c;下载地址和之前不一样了 # 下载openssl1.1.1w源码包cd downlo…...

Flink和Spark的区别

1、设计理念不同 flink&#xff1a;Flink是基于事件驱动的&#xff0c;是面向流的处理框架, Flink基于每个事件一行一行地流式处理&#xff0c;是真正的流式计算. 另外他也可以基于流来模拟批进行计算实现批处理。 spark&#xff1a;Spark的技术理念是使用微批来模拟流的计算,…...

以太网开发基础-MAC和PHY

直接参考&#xff1a; 以太网基础-MAC和PHY-CSDN博客 路由器上一般有三类MAC地址 给一个范例: 00:0C:E5:4B:F2:85 这个地址就可以作为LAN MAC地址 00:0C:E5:4B:F2:86 这个地址就可以作为WAN MAC地址 00:0C:E5:4B:F2:87 这个地址就可以作为无线 MAC地址 通常&#xff0c;路由器…...

Java 发布jar包到maven中央仓库(2024年9月保姆级教程)

文章目录 前言一、账号准备1. 注册登录账号2. 新建命名空间3. 验证命名空间4. 生成令牌5. 为 maven 设置令牌二、GPG准备1. 下载GPG2. 发布证书2.1 新建证书2.2 发布证书到服务器2.3 验证发布三、发布jar包到中央仓库1. 编辑项目pom文件2. 打包上传3. 发布jar包4. 搜索我们的ja…...

Pandas和Seaborn可视化详解

1.Pandas绘图-单变量 概述 pandas库是Python数据分析的核心库 它不仅可以加载和转换数据&#xff0c;还可以做更多的事情&#xff1a;它还可以可视化 pandas绘图API简单易用&#xff0c;是pandas流行的重要原因之一 可视化小技巧: 如果是类别型 柱状 饼图 (类别相对较少 5-…...

【Python】Windows下安装使用FFmpeg

FFmpeg是一套可以用来记录、转换数字音频、视频&#xff0c;并能将其转化为流的开源计算机程序。之前为了MP3转wav&#xff0c;需要pip安装并import AudioSegment&#xff0c;但是会报错&#xff1a;FileNotFoundError: [WinError 2] 系统找不到指定的文件。 因为FFmpeg需要另…...

实战指南:基于虫洞ESP32S3-EYE开发板打造即插即用UVC摄像头

1. 开箱即用&#xff1a;为什么选择虫洞ESP32S3-EYE做UVC摄像头&#xff1f; 如果你手头正好有一块虫洞ESP32S3-EYE开发板&#xff0c;或者正在寻找一个成本不高、功能强大且能快速“变废为宝”的嵌入式项目&#xff0c;那把它打造成一个即插即用的USB摄像头&#xff0c;绝对是…...

基于RexUniNLU的Python入门教程智能问答系统

基于RexUniNLU的Python入门教程智能问答系统 你是不是刚开始学Python&#xff0c;经常被一些基础问题卡住&#xff1f;比如“列表和元组到底有什么区别&#xff1f;”、“这个报错是什么意思&#xff1f;”、“这个语法该怎么写&#xff1f;”。网上搜答案吧&#xff0c;要么太…...

Qwen-Image-Edit-F2P算法原理解析与实现

Qwen-Image-Edit-F2P算法原理解析与实现 1. 引言 你是否曾经遇到过这样的情况&#xff1a;手头只有一张普通的人脸照片&#xff0c;却想要生成一张精美的全身照&#xff1f;或者想要保持人物面部特征的同时&#xff0c;创造出不同风格的图像&#xff1f;这就是Qwen-Image-Edi…...

M2LOrder 模型 .NET 生态集成指南:为 C# 应用添加情感分析功能

M2LOrder 模型 .NET 生态集成指南&#xff1a;为 C# 应用添加情感分析功能 你是不是遇到过这样的场景&#xff1f;用户在你的应用里留下了一段评论&#xff0c;你想快速知道他是满意还是抱怨&#xff0c;好及时跟进。或者&#xff0c;你有一堆客服对话记录&#xff0c;想自动分…...

Janus-Pro-7B WebUI部署教程:Ubuntu 22.04 + NVIDIA驱动+Docker全链路

Janus-Pro-7B WebUI部署教程&#xff1a;Ubuntu 22.04 NVIDIA驱动Docker全链路 1. 引言 今天给大家带来一个超级实用的教程——如何在Ubuntu 22.04系统上&#xff0c;从零开始部署Janus-Pro-7B这个强大的多模态AI模型。Janus-Pro-7B是DeepSeek发布的一个统一多模态理解与生成…...

向日葵高危漏洞:一键获取系统权限

向日葵个人版Windows<11.0.0.33或向日葵简约版<V1.0.1.43315 而这些版本在运行时会开放一个大于40000的端口&#xff0c;而我们可以通过这个端口来拿到system权限。首先我们要确保目标主机开启向日葵&#xff0c;和有目标主机的ip地址。使用kali中的nmap&#xff0c;进行…...

ESP32复刻诺基亚功能机:嵌入式手持终端全栈设计

1. 项目概述复刻经典功能机并非怀旧情怀的简单投射&#xff0c;而是一次面向嵌入式系统工程实践的完整闭环训练。本项目以Nokia 1110为物理载体与交互范式蓝本&#xff0c;采用ESP32-WROOM-32作为主控平台&#xff0c;构建了一台具备现代嵌入式能力的微型手持终端。其设计目标明…...

航空航天需求:Vue3如何扩展WebUploader支持三维模型文件的分片校验?

网工大三党文件上传救星&#xff1a;原生JS实现10G大文件上传&#xff08;Vue3IE8兼容&#xff09; 兄弟&#xff0c;作为刚入坑网络工程的山西老狗&#xff0c;我太懂你现在的处境了——老师要10G大文件上传的毕业设计&#xff0c;网上找的代码全是“断头路”&#xff0c;后端…...

资源加速通道:百度网盘高效下载解决方案与实践指南

资源加速通道&#xff1a;百度网盘高效下载解决方案与实践指南 【免费下载链接】baidu-wangpan-parse 获取百度网盘分享文件的下载地址 项目地址: https://gitcode.com/gh_mirrors/ba/baidu-wangpan-parse 在数字化协作日益频繁的今天&#xff0c;云存储服务已成为信息传…...

无水印在线图片合成GIF:快速生成高清gif图片

gif图片制作的核心&#xff0c;在于选对工具——而对于新手和大部分用户来说&#xff0c;在线图片合成GIF工具无疑是最佳选择&#xff0c;无需安装、操作便捷、免费无水印&#xff0c;能轻松实现从静态图片到动态gif的无缝转换。但目前市面上的在线图片合成GIF工具&#xff08;…...