驱动模型-platform (kernel 2.6.27)

设备驱动中的platform(kernel-4.7) platform驱动模型搭建platform核心层:为设备层和驱动层提供注册接口、为设备层和驱动层的匹配提供标准。 内核是这样描述它们的(Documentation/driver-model/platform.txt):Platform devices are devices that typically appear as autonomous entities in the system. T 阅读详情

 

/Documentation/driver-model/platform.txt

【部分翻译可能不准确,希望高人不吝赐教!】

 

Platform Devices and Drivers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See <linux/platform_device.h> for the driver model interface to the
platform bus:  platform_device, and platform_driver.  This pseudo-bus
is used to connect devices on busses with minimal infrastructure,
like those used to integrate peripherals on many system-on-chip
processors, or some "legacy" PC interconnects; as opposed to large
formally specified ones like PCI or USB.


Platform devices
~~~~~~~~~~~~~~~~
Platform devices are devices that typically appear as autonomous
entities in the system. This includes legacy port-based devices and
host bridges to peripheral buses, and most controllers integrated
into system-on-chip platforms.  What they usually have in common
is direct addressing from a CPU bus.  Rarely, a platform_device will
be connected through a segment of some other kind of bus; but its
registers will still be directly addressable.

Platform devices are given a name, used in driver binding, and a
list of resources such as addresses and IRQs.

Platform drivers
~~~~~~~~~~~~~~~~
Platform drivers follow the standard driver model convention, where
discovery/enumeration(枚举) is handled outside the drivers, and drivers
provide probe() and remove() methods.  They support power management
and shutdown notifications using the standard conventions(惯例).【使用标

准的规范,驱动部分支持电源管理以及关机通知】

Note that probe() should general verify that the specified device hardware
actually exists; sometimes platform setup code can't be sure.  The probing
can use device resources, including clocks, and device platform_data.

【probe()通常应确认指定的设备是否真正存在;有时,platform的setup代码是靠不住

的。probe()可以使用设备的资源,包括时钟和设备的platform_data】
Platform drivers register themselves the normal way:

Or, in common situations where the device is known not to be hot-pluggable,
the probe() routine can live in an init section to reduce the driver's
runtime memory footprint:

Device Enumeration
~~~~~~~~~~~~~~~~~~
As a rule, platform specific (and often board-specific) setup code will
register platform devices:

The general rule is to register only those devices that actually exist,
but in some cases extra devices might be registered.  For example, a kernel
might be configured to work with an external network adapter that might not
be populated(板载) on all boards, or likewise to work with an integrated controller
that some boards might not hook up(衔接) to any peripherals.

In some cases, boot firmware will export tables(输出表格) describing the devices
that are populated on a given board.   Without such tables, often the
only way for system setup code to set up the correct devices is to build
a kernel for a specific target board.  Such board-specific kernels are
common with embedded and custom systems development.

In many cases, the memory and IRQ resources associated with the platform
device are not enough to let the device's driver work.  Board setup code
will often provide additional information using the device's platform_data
field to hold additional information.

【在很多情况下,由platform device提供的相关的memory和IRQ资源信息不足以让device

driver工作。板子的setup代码通常还使用设备的platform_data域来提供额外的信息。】


Embedded systems frequently need one or more clocks for platform devices,
which are normally kept off until they're actively needed (to save power).
System setup also associates those clocks with the device, so that that
calls to clk_get(&pdev->dev, clock_name) return them as needed.

【嵌入式系统中的platform devices常常需要1个或多个时钟,为了节省功耗,在不需要它们时,

它们通常会被隔离。系统setup也向device提供这些时钟,设备可以通过clk_get(&pdev->dev,clock_name)

获得他们想要的。】

 


Legacy Drivers:  Device Probing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some drivers are not fully converted to the driver model, because they take
on a non-driver role:  the driver registers its platform device, rather than
leaving that for system infrastructure.  Such drivers can't be hotplugged
or coldplugged, since those mechanisms require device creation to be in a
different system component than the driver.

【一些(老式)驱动并不能完整的转换为现在的驱动模型,因为它们扮演着一个“非驱动”的角色:

这种驱动注册它的platform device,而不是留给系统底层结构去做。这种驱动不能支持热拔插

或者冷拔插,因为这种机制需要非驱动的不同系统组件来创建设备。】

The only "good" reason for this is to handle older system designs which, like
original IBM PCs, rely on error-prone "probe-the-hardware" models for hardware
configuration.  Newer systems have largely abandoned that model, in favor of
bus-level support for dynamic configuration (PCI, USB), or device tables
provided by the boot firmware (e.g. PNPACPI on x86).  There are too many
conflicting options about what might be where, and even educated(有根据的) guesses by
an operating system will be wrong often enough to make trouble.

This style of driver is discouraged.  If you're updating such a driver,
please try to move the device enumeration to a more appropriate location(更合适的位置),
outside the driver.  This will usually be cleanup, since such drivers
tend to(往往) already have "normal" modes, such as ones using device nodes that
were created by PNP or by platform device setup.


None the less(依然), there are some APIs to support such legacy drivers.  Avoid
using these calls except with such hotplug-deficient drivers.

You can use platform_device_alloc() to dynamically allocate a device, which
you will then initialize with resources and platform_device_register().
A better solution is usually:

You can use platform_device_register_simple() as a one-step call to allocate
and register a device.


Device Naming and Driver Binding
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The platform_device.dev.bus_id(注意格式) is the canonical(规范的) name for the devices.
It's built from two components:

    * platform_device.name ... which is also used to for driver matching.

    * platform_device.id ... the device instance(实例) number, or else "-1"
      to indicate there's only one.

These are concatenated(连接起来的), so name/id "serial"/0 indicates bus_id "serial.0", and
"serial/3" indicates bus_id "serial.3"; both would use the platform_driver
named "serial".  While "my_rtc"/-1 would be bus_id "my_rtc" (no instance id)
and use the platform_driver called "my_rtc".

Driver binding is performed automatically by the driver core, invoking
driver probe() after finding a match between device and driver.  If the
probe() succeeds, the driver and device are bound as usual.  There are
three different ways to find such a match:

【driver core将会自动的执行驱动绑定工作,即在找到相匹配的device和driver后,调用驱动的probe();

如果probe()执行成功,则driver和device像往常一样被绑定在一起。有三种不同的方法可以找到一组匹配】

    - Whenever a device is registered, the drivers for that bus are
      checked for matches.  Platform devices should be registered very
      early during system boot.

      【当一个device被注册时,该总线上的驱动被检测是否与该设备匹配。因此,在系统

         启动较早的时候,platform devices就应该被注册。】
    - When a driver is registered using platform_driver_register(), all
      unbound devices on that bus are checked for matches.  Drivers
      usually register later during booting, or by module loading.
      【当一个driver被platform_driver_register()注册时,该总线上所有没有被绑定的devices被检测是否

         与该驱动匹配。通常,该驱动在启动过程的后期就被注册,或者被module加载。】
    - Registering a driver using platform_driver_probe() works just like
      using platform_driver_register(), except that the driver won't
      be probed later if another device registers.  (Which is OK, since
      this interface is only for use with non-hotpluggable devices.)

      【使用platform_driver_probe()和使用platform_driver_register()注册一个驱动是一样的,不同的

         是,如果当其他的devices注册的时候,驱动不再被probed。不过,这样也无所谓,因为这种接口仅仅

         在非热拔插设备上使用。】

RTC驱动模型分析 ①RTC设备层: 设备资源的定义:arch/arm/plat-s3c24xx/devs.c static struct resource s3c_rtc_resource[] = { [0] = { .start = S3C24XX_PA_RTC, .end = S3C24XX_PA_RTC + 0xff, .flags = IORESOURCE_MEM, }, [1] 阅读详情

相关推荐

RK3568平台开发系列讲解(音视频篇)图像数据格式

📢当我们看视频时会看到很多图像,这些图像的展现形式我们中学学习几何课程的时候就接触过,是由一个个像素点组成的线,又由一条条线组成面,这个面铺在屏幕上展现出来的就是我们看到的图像。这些图像有黑白的,也有彩色的。这是因为图像输出设备支持的规格不同,所以色彩空间也有所不同,不同的色彩空间能展现的色彩明暗程度,颜色范围等也不同。为了让你对色彩空间有一个基本的认识,这篇博文我将给你介绍一些常见的色彩格式,分别是: GRAY 色彩空间 YUV 色彩空间 RGB 色彩空间 HSL 和 HSV 色彩空间

内核笔记 3214

Android驱动模型(kernel-hal-framework-app)

读书的时候有写博客的习惯,后面就再也没写过了,发现很多知识点整理在电脑上容易丢失,也不能共享,所以今天又拿起笔开始写博客了,这边文章的内容是基于兆芯平台的Android架构,实现了一个APP调用hal层来控制导光板的灯光效果。 Android上层平台和底层通信有两种模型: 1.NDK模型(不常用); 2.框架模型 Android系统使用JNI的原因有: 1、代码保护,Java程

chunerlaogong的博客 2795

Camera Linux 驱动模型与 Platform Driver 架构实战解析

本文深入解析了手机相机系统中 Linux Kernel 层的 Camera 驱动模型,重点剖析 V4L2 框架下的驱动结构、Platform Driver 与设备树的协同机制、Sensor 的注册与绑定流程,以及实际工程中如何在不同平台(如高通、MTK、海思)上构建稳定、可维护的 Camera 驱动模块。内容以实战为核心,基于目前主流平台实际代码结构与调试经验展开,旨在为嵌入式 Linux Camera 开发者提供一套系统化的驱动开发与维护参考。

努力分享一些人工智能、计算机视觉、影像等相关的知识干货! 1433

linux kernel 2.4 和 2.6 的区别

<br />作者:晏渭川<br /> 随着Linux2.6的发布,由于2.6内核做了教的改动,各个设备的驱动程序在不同程度上要<br /> 进行改写。为了方便各位Linux 爱好者我把自己整理的这分文档share出来。该文当列举<br /> 了2.6内核同以前版本的绝大多数变化,可惜的是由于时间和精力有限没有详细列出各个<br /> 函数的用法。<br /> 特别声明:该文档中的内容来自http://lwn.net,该网也上也有各个函数的较为详细的<br /> 说明可供各位参考。如果需要该文档

jiang_dlut 934

i.MX6ULL驱动开发 | 24 - 基于platform平台驱动模型点亮LED

编写驱动模块源码: 编写Makefile: 编译: 二、编写platform驱动框架 添加platform驱动框架: 三、编写字符设备驱动 四、编写LED驱动 和i.MX6ULL驱动开发 | 08 -基于pinctrl子系统和gpio子系统点亮LED一样。 查看platform总线是否注册: 查看总线设备是否注册(因为有设备树节点的描述): 注意,这里驱动加载的时候,内核会去匹配对应的设备,所以设备树节点描述的兼容性要与驱动中的兼容性一致: 查看设备节点: 运行测试程序,可以看到led闪烁:...

Mculover666的博客(嵌入式) 578

COMSOL+AI实战:5个超实用技巧让你的仿真效率翻倍(附Python代码)

本文详细介绍了如何将人工智能(AI)与COMSOL仿真软件结合,通过Python脚本实现五大实用技巧,包括自动化生成数据集、构建代理模型、集成AI优化算法、利用神经网络加速场量求解以及智能结果分析,从而显著提升多物理场仿真的效率和自动化水平。

weixin_29230865的博客 444

Linux内核--设备驱动模型

weixin_38812277的博客 236

四足机器人关节电机FOC控制实战:从磁编码器校准到SVPWM调试避坑指南

本文详细解析了四足机器人关节电机FOC控制实战,涵盖磁编码器校准、电流环调试和SVPWM波形优化等关键环节。通过MIT Cheetah案例展示如何解决21倍电气误差问题,并提供相序自动校正、PI参数整定等实用代码片段,帮助工程师避开永磁同步电机(PMSM)控制中的常见陷阱。

weixin_29281915的博客 490

linux 内核驱动模型,Linux驱动模型-简述

Linux - 宏内核. 支持越来越多的设备. 代码越来越多,越来越复杂设备的迭代,不仅仅是得驱动代码变得越来越难管理,还使得板级文件越来越多,而文件之间有很多重复的代码,这使得在3.0开始引入了设备树的概念。bus class device devicedriver,方便开发和管理bus - cpu和设备连接的通道,platform bus是通过控制器可以连接cpu的设备,添加的虚拟概念,统一在...

weixin_36357900的博客 292

RH850从0搭建Autosar开发环境【3X】- Davinci Configurator之OS模块配置详解(中)

RH850从0搭建Autosar开发环境【3X】- Davinci Configurator之OS模块配置详解(中)

weixin_42412049的博客 1518

OpenClaw Skill 开发全攻略|2026 最新机制 + 文件处理实操,看完直接落地开发

很多新手刚接触时,会把 Skill 想得很复杂,其实大可不必。OpenClaw 中的每个 Skill,本质就是一套“能力描述 + 执行逻辑”的组合包,简单说就是“告诉 AI 你能做什么、怎么做,它就会调用你”,核心特征可以总结为这几点,好记又实用:核心载体:以文件夹为单位,不管多简单的 Skill,文件夹里都必须有 SKILL.md 文件——这是 AI 识别技能的唯一依据,少了它,再完善的代码也没用;

haolove527的专栏 7032

基于platform的总线、设备、驱动模型分析

如I2C总线,I2C总线是集成在SOC内部的,因此总线是跟着平台走到,不同芯片厂商,所使用的I2C控制器不同,引起其驱动也有所不同,但又一个问题,如果不同芯片厂商与相同的I2C设备进行通讯,使这些外围的I2C设备工作起来,如果不对其解耦,那么每一个SOC平台都需要写一个对应的I2C设备驱动,这样耦合性过高,不方便移植。由 3.4 可知 module_init最终会注册一个设备到对应总线的总线设备链表中,再调用platform_driver_register时,即在总线中找到对应的设备,匹配成功。

jamecer的博客 1158

SpringBoot整合LangChain4j实现RAG检索实战详解

本文介绍了使用LangChain4j框架在Java生态中构建RAG(检索增强生成)应用的最佳实践。作为最接近Python LangChain的Java实现,LangChain4j提供了文档解析、向量化存储到检索增强的全套组件,并与SpringBoot深度集成。文章通过电商智能客服场景,详细演示了从零搭建RAG系统的完整流程:包括使用PostgreSQL+pgvector作为生产级向量数据库、文档加载与向量化处理、声明式AI服务实现以及查询压缩、结果重排等进阶优化技巧。同时对比了内存模式与生产级向量库的差异,

分享AI、区块链技术及应用,未来已来 433

Linux Platform驱动模型

Linux Platform驱动模型(一) _设备信息:https://www.cnblogs.com/xiaojiang1025/p/6367061.html Linux Platform驱动模型(二) _驱动方法:https://www.cnblogs.com/xiaojiang1025/p/6367910.html Linux Platform驱动模型(三) _platform+cdev:h...

卓越之路 502

从传统业务到 AI Skill:产品经理也能看懂的能力改造指南(含完整案例)

从传统业务到 AI Skill:产品经理也能看懂的能力改造指南(含完整案例)

专注于编程、AI、人工智能等多个领域内容研究和分析 646

ESP32学习笔记06-UART 的485 通讯模式

通信方式选择UART 控制器支持多种通信模式,使用函数 uart_set_mode() 可以选择模式。选择特定模式后,UART 驱动程序将处理已连接 UART 设备的相应行为。例如,主机开始向 Tx FIFO 缓冲区写入数据时,UART 驱动程序会自动置位 RTS 管脚(逻辑 1);最后一位数据传输完成后,驱动程序就会取消置位 RTS 管脚(逻辑 0)。要使用此模式,软件。

Car12 2477

详解Linux2.6内核中基于platform机制的驱动模型 (经典)

【摘要】本文以Linux 2.6.25 内核为例,分析了基于platform总线的驱动模型。首先介绍了Platform总线的基本概念,接着介绍了platform device和platform driver的定义和加载过程,分析了其与基类device 和driver的派生关系及在此过程中面向对象的设计思想。最后以ARM S3C2440中I2C控制器为例介绍了基于platform总线的驱动开发流程。

LoongEmbedded的专栏 1665

AI智能体丨使用Coze一键生成中式养生视频,39 条作品涨粉 37.9 万!(附保姆级教程)

本文介绍如何利用扣子(Coze)AI智能体工作流高效制作中式养生短视频。该方案通过AI自动生成养生文案、古风插画素材、语音合成和视频剪辑,将传统制作流程从2-3小时缩短至1-2分钟。工作流包含文案创作、音频生成、图片素材制作和视频合成四大模块,采用大模型处理各环节内容,最终输出可直接导入剪映的草稿文件。特别适合希望快速批量制作文化氛围感强、兼具干货与视觉效果的养生内容创作者,效率提升近百倍。

李同学Lino的博客 3031

Kernel 2.6系列的安装

  收藏 Kernel 2.6系列的安装安装kernel源代码: 1.解压缩包:   a.完成安装:      gzip -cd linux-2.6.XX.tar.gz | tar xvf -       or      bzip2 -dc linux-2.6.XX.tar.bz2 | tar xvf -      

不顾一切 的专栏 648

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Linux平台设备驱动模型:platform_device与platform_driver详解

在Linux内核开发中,设备驱动模型是连接硬件与操作系统的关键架构。platform总线作为一种特殊的软件抽象层,为SoC等嵌入式设备提供了统一的驱动管理接口,其核心机制通过platform_device描述硬件资源,platform_driver实现设备控制。这种模型解决了非标准总线设备的驱动管理问题,广泛应用于内存映射IO设备、片上系统外设等场景。从实现原理看,platform_device通过resource结构体声明硬件资源(如内存地址、中断号),而platform_driver则提供probe/r

weixin_29161785的博客 248

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

OpenCL中platform、context、kernel、program、command queue的理解

0. 以下理解是读《OpenCL in Action》后总结的,一些图也是从该书中引用。 1. OpenCL中的platform可以理解为不同的(vendor的)OpenCL实现,比如你的电脑中装有AMD显卡和NVIDIA显卡,那么如果在电脑中安装了AMD的OpenCL SDK和NVIDIA的OpenCL SDK的话,那么你的电脑中就包含了两个platform。 2. OpenCL中的cont

小子的专栏 2807

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

linux kernel之platform driver&device

在驱动程序的模型分层有一层总线基础层(PCI总线,I2C总线,USB总线等),总线层对应实际上的总线,然而,对于嵌入式开发领域而言,有很多SOC芯片内置了各种外设,并比如LCD,UART、audio、摄像头口等等,并没有总线。 为了统一驱动架构抽象,所以引入了platform bus这个虚拟的总线模型。 本文简要介绍一下platform driver&device怎么工作的,主要是如何发现并注册设备(probe)。 在系统上电后,start_kernel() -> rest_init()

shaohui973的专栏 762

linux kernel中module_platform_driver实现原理分析

介绍 在linux kernel中通过module_platform_driver来实现模块化平台驱动。 大量的设备驱动程序都基于该种方式来实现,使用频次非常的高,在linux kernel 5.4.124的代码中搜索module_platform_driver共有2356次引用。 这个宏的使用方式大相径庭,有一套成熟的代码书写方式,将驱动程序入口符号作为宏的参数,基本格式如下: 历史 它的定义在include/linux/platform_device.h中,从文件的名字来看可知它存在的意义是基于

多年芯片设计领域从业经验,负责芯片bringup以及kernel驱动开发。 1211

linux kernel中的DTS解析到platform_device的注册

在linux内核早期的时候,每个嵌入式系统的板载信息(总线,设备的寄存器地址等)都是hardcode在arch/<cpu>/match-xxx/board-xxx.c之类的文件中,即必须存在这样的c文件,里面定义了板子上的硬件的地址等信息。 这样做会造成很多很多的大量相似的没多少用的重复代码。 为了解决这个问题,而引入了DTS(device tree source)。 每个嵌入式系统的描述硬件信息的DTS文件存放在arch/<cpu>/boot/dts/目录下,比如ast250

shaohui973的专栏 2883
上一篇: Linux Platform Device and Driver
下一篇: ADROID 2.1 架构解析 8 触摸屏
android83
博客等级 码龄17年 4粉丝 10原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值