![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
驱动
文章平均质量分 75
不止冬雷和夏雪
这个作者很懒,什么都没留下…
展开
-
驱动开发工作记录
工作记录原创 2022-02-25 16:48:41 · 331 阅读 · 0 评论 -
Android & linux充电模块分析
核心模块是drivers/power/supply/power_supply_core.cdrivers/power/supply/power_supply_leds.cdrivers/power/supply/power_supply_fysfs.c模块入口函数在power_supply_core.c中subsys_initcall(power_supply_class_init);提前于驱动模块的加载。// drivers/power/supply/power_supply_core.原创 2021-05-26 16:13:23 · 2260 阅读 · 1 评论 -
Linux内核高精度定时器(hrtimer)
内核为高精度定时器重新设计了一套软件架构,它可以为我们提供纳秒级的定时精度,以满足对精确时间有迫切需求的应用程序或内核驱动。该套架构相关文件为kernel\time\hrtimer.c和include\linux\hrtimer.h。...原创 2021-05-10 20:02:45 · 4230 阅读 · 0 评论 -
Linux内核通知链(notifier chain)
1、概述Linux内核中各个子系统相互依赖,当其中某个子系统状态发生改变时,就必须使用一定的机制告知使用其服务的其他子系统,以便其他子系统采取相应的措施。为满足这样的需求,内核实现了事件通知链机制(notification chain)。通知链只能用在各个子系统之间,而不能在内核和用户空间进行事件的通知。组成内核的核心系统代码均位于kernel目录下,通知链表位于kernel/notifier.c中,对应的头文件为include/linux/notifier.h。事件通知链表是一个事件处理函数的列表,原创 2021-05-08 17:20:59 · 1728 阅读 · 0 评论 -
linux开发版nfs加载根文件系统
1、设置windows、linux和arm能够相互ping通。1.1vmware中的ubuntu设置。1.1.1首先设置虚拟机,设置为桥接模式,然后选择PCIE相关选项。1.1.2设置ubuntu设置ubuntu的ip地址和子网掩码。ip地址和window的ip地址在一个地址段内。1.1.3设置好ubuntu中需要开发版使用的文件系统目录,然后启动nfs服务。sudo /etc/init.d/nfs-kernel-server restart1.2windows设置1.2.1右原创 2021-01-10 19:33:46 · 340 阅读 · 0 评论 -
linux内核休眠、唤醒流程分析之恢复(九)
// kernel\power\suspend.c /** * suspend_enter - Make the system enter the given sleep state. * @state: System sleep state to enter. * @wakeup: Returns information that the sleep state should not be re-entered. * * This function should be called aft.原创 2020-12-14 10:49:37 · 600 阅读 · 0 评论 -
linux内核休眠、唤醒流程分析之挂起:cpu(八)
从内核启动说起// init\main.casmlinkage __visible void __init start_kernel(void){ …… setup_arch(&command_line); ……// arch\arm64\kernel\setup.cvoid __init setup_arch(char **cmdline_p){ …… psci_dt_init(); ……// drivers\firmware\psci\psci.cstati原创 2020-12-11 21:42:13 · 561 阅读 · 0 评论 -
linux内核休眠、唤醒流程分析之挂起:pm.suspend_noirq(七)
// kernel\power\suspend.c /** * suspend_enter - Make the system enter the given sleep state. * @state: System sleep state to enter. * @wakeup: Returns information that the sleep state should not be re-entered. * * This function should be called aft.原创 2020-12-10 18:02:29 · 1573 阅读 · 2 评论 -
linux内核休眠、唤醒流程分析之挂起:pm.suspend_late(六)
// kernel\power\suspends.c/** * suspend_devices_and_enter - Suspend devices and enter system sleep state. * @state: System sleep state to enter. */int suspend_devices_and_enter(suspend_state_t state){ int error; bool wakeup = false; if (!sleep_s原创 2020-12-10 17:04:17 · 653 阅读 · 0 评论 -
linux内核休眠、唤醒流程分析之挂起:pm.prepare(四)
然后是进入函数// kernel\power\suspends.c/** * suspend_devices_and_enter - Suspend devices and enter system sleep state. * @state: System sleep state to enter. */int suspend_devices_and_enter(suspend_state_t state){ int error; bool wakeup = false; if (原创 2020-12-10 16:32:28 · 380 阅读 · 0 评论 -
linux内核休眠、唤醒流程分析之挂起:pm.suspend(五)
然后调用dpm_suspend实现挂起流程,即流程图中的过程4。// drivers\base\power\main.c/** * dpm_suspend - Execute "suspend" callbacks for all non-sysdev devices. * @state: PM transition of the system being carried out. */int dpm_suspend(pm_message_t state){ ktime_t startti原创 2020-12-10 16:06:54 · 907 阅读 · 0 评论 -
linux内核休眠、唤醒流程分析之挂起:Call Notifiers、Freeze任务(三)
linux内核休眠唤醒、流程分析之挂起:pm.prepare(3)入口函数为pm_suspend// kernel\power\suspend.c/** * pm_suspend - Externally visible function for suspending the system. * @state: System sleep state to enter. * * Check if the value of @state represents one of the support原创 2020-12-10 15:57:40 · 432 阅读 · 1 评论 -
linux内核休眠、唤醒流程分析之电源管理初始化(二)
linux内核休眠唤醒、流程分析之电源管理初始化(2)linux内核电源管理相关函数在kernel/power/main.c中。入口函数如下:// kernel\power\main.cstatic int __init pm_init(void){ int error = pm_start_workqueue(); if (error) return error; hibernate_image_size_init(); hibernate_reserved_size_init()原创 2020-12-10 15:49:01 · 315 阅读 · 0 评论 -
linux内核休眠、唤醒流程分析之挂起到RAM(一)
linux驱动之电源管理挂起到RAMLinux支持STANDBY、挂起到RAM、挂起到硬盘等形式的待机,如图所示。一般的嵌入式产品仅仅实现了挂起到RAM(s2ram/STR),即将系统的状态保存到内存中,并将SDRAM置于自刷新状态,待用户按键等操作后再重新恢复系统。少数嵌入式linux系统会实现挂起到硬盘(STD),它与挂起到RAM不同的是s2ram并不关机,STD则吧系统的状态保存于硬盘,然后关闭整个系统。...原创 2020-11-27 16:54:23 · 1042 阅读 · 0 评论 -
linux内核定时器的使用(基于kernel5.8.1)
linux内核定时器的使用1、timer的使用timer相关函数的定义在kernel\time\timer.c和include\linux\timer.h中。定时器的结构体为// include\linux\timer.hstruct timer_list { /* * All fields that change during normal runtime grouped to the * same cacheline */ struct hlist_node entry;原创 2020-10-20 19:54:53 · 1431 阅读 · 2 评论 -
Linux的LED子系统分析
Linux的LED子系统分析1、leds目录的创建led子系统的入口模块为drivers\leds\led-class.c// drivers\leds\led-class.cstatic int __init leds_init(void){ leds_class = class_create(THIS_MODULE, "leds"); if (IS_ERR(leds_class)) return PTR_ERR(leds_class); leds_class->pm = &a原创 2020-10-08 21:35:52 · 207 阅读 · 0 评论 -
sysfs设备节点创建分析
sysfs设备节点创建分析sysfs是一种基于ram的文件系统,它提供了一种用于向用户空间展现内核空间里的对象、属性和链接。1、使用流程1.1、使用DEVICE_ATTR设置设备属性。DEVICE_ATTR的定义如下#define DEVICE_ATTR(_name, _mode, _show, _store) \ struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)@_name:名称,也原创 2020-10-07 21:45:42 · 469 阅读 · 0 评论 -
linux内核中断详解
linux内核中断1、中断的硬件触发流程外设:如果外设有操作或者有数据可用,那么就会产生一个电信号,这个电信号发送给中断控制器。中断控制器:中断控制器接收到外设发来的电信号以后,进行进一步的处理,判断这个中断是否使能或者禁止,判断它的优先级等,如果需要发送给CPU一个信号,那么中断控制器就会给cup发送一个电信号。CPU:CPU接收到中断控制器发送过来的电信号以后,CPU就会无条件跳转到异常向量表的入口,后续CPU就处理对应的中断。2、中断处理程序编写时的注意事项1.中断处理函数不隶属于任何进程原创 2020-10-06 14:59:58 · 1913 阅读 · 0 评论 -
Linux GPIO子系统API
Linux GPIO子系统APIstatic inline bool gpio_is_valid(int number)该函数用来判断获取到的gpio号是否是有效的,只有有效的gpio号,才能向内核中进行申请使用,因此,当我们从设备树的设备节点获取到gpio号,可以使用该函数进行判断是否有效。int gpio_request(unsigned gpio, const char *label)该函数用于申请一个 GPIO管脚,在使用一个 GPIO之前一定要使用 gpio_request进行申请。原创 2020-10-05 13:38:28 · 3244 阅读 · 0 评论 -
linux设备树常用of操作函数
linux设备树常用of操作函数设备树描述了设备的详细信息,这些信息包括数字类型的、字符串类型的、数组类型的,这些信息一般通过of函数获取,这些of函数的原型大部分定义在include/linux/of.h文件中,其中GPIO相关的定义在include/inux/of_gpio.h中。1、 GPIO相关static inline int of_get_named_gpio(struct device_node *np, const char *propname, int index)@np: gp原创 2020-10-04 22:25:48 · 1542 阅读 · 0 评论 -
linux内核中的devm_kzalloc
linux内核中的内存分配1、devm_kzalloc & devm_kfree函数devm_kzalloc和kzalloc一样都是内核内存分配函数,但是devm_kzalloc是跟设备(装置)有关的,当设备(装置)被拆卸或者驱动(驱动程序)卸载(空载)时,内存会被自动释放。另外,当内存不在使用时,可以使用函数devm_kfree()释放。而kzalloc没有自动释放的功能,用的时候需要小心使用,如果忘记释放,会造成内存泄漏。函数原型为void * devm_kzalloc (struct原创 2020-10-04 10:48:01 · 9904 阅读 · 0 评论 -
linux内核i2c适配器功能
linux内核i2c适配器功能以kernel5.8.1为例,i2c适配器的功能定义在uapi/linux/i2c.h// i2c.h#define I2C_FUNC_I2C 0x00000001#define I2C_FUNC_10BIT_ADDR 0x00000002#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_IGNORE_NAK etc. */#define I2C_FUNC_SMBUS_PEC 0x00000008原创 2020-10-03 20:56:07 · 419 阅读 · 0 评论 -
linux内核模块加载顺序分析
linux内核模块加载顺序分析Linux内核中为了确定不同模块的加载顺序,通过一些宏定义了一些优先级,不同的模块通过不同的宏修饰,可以确定加载的先后顺序。以kernel5.8.1为例,在include\linux\module.h中定义了module_init。// module.h#define module_init(x) __initcall(x);其中__initcall的定义在include\linux\init.h中。// init.h#define __define_ini原创 2020-10-03 19:31:21 · 1166 阅读 · 0 评论 -
linux内核IIC架构分析(基于内核5.8.1)
linux内核IIC架构源码分析原创 2020-09-27 20:14:21 · 429 阅读 · 0 评论 -
Linux的input(输入)子系统详解(基于内核5.8.1)
Linux的input(输入)子系统详解该文章详细介绍了input子系统的内部流程架构和使用。分别从设备驱动层和事件处理层分析内核源码,最后介绍了从用户空间调用设备驱动和设备驱动的响应过程。原创 2020-09-26 20:57:53 · 600 阅读 · 0 评论