Linux平台驱动程序和普通设备驱动程序有什么区别? [英] What is the difference between a Linux platform driver and normal device driver?

查看:539
本文介绍了Linux平台驱动程序和普通设备驱动程序有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前曾经考虑过平台驱动程序以及普通的设备驱动程序,例如:

I previously had a thought about the platform driver as well as normal device driver like :

  • 平台驱动程序用于芯片上的那些设备.
  • 普通设备驱动程序用于与处理器芯片接口的设备.

在遇到一个i2c驱动程序之前... 但是在这里,我正在阅读定义为平台驱动程序的多功能i2c驱动程序.我经历了 https://www.kernel.org/doc/Documentation /driver-model/platform.txt .但是对于如何定义驱动程序(如片上和接口设备),仍然没有一个清晰的主意可以得出结论.

Before coming across one i2c driver... But here, I am reading through multi function i2c driver defined as platform driver. I had gone through https://www.kernel.org/doc/Documentation/driver-model/platform.txt. But still could not get clear idea to come to an conclusion on how to define drivers, like for both onchip as well interfaced devices.

请有人解释.

推荐答案

您的参考文献很好,但是缺少什么是平台设备的定义. LWN 上有一个.我们可以从此页面中学到什么:

Your references are good but lack a definition of what is a platform device. There is one on LWN. What we can learn from this page:

  1. 平台设备本质上不可发现,即硬件无法对软件说嘿!我在场!" .典型示例是i2c设备,kernel/Documentation/i2c/instantiating-devices状态:

  1. Platform devices are inherently not discoverable, i.e. the hardware cannot say "Hey! I'm present!" to the software. Typical examples are i2c devices, kernel/Documentation/i2c/instantiating-devices states:

与PCI或USB设备不同,未在硬件级别(运行时)枚举I2C设备. 相反,软件必须(在编译时)知道每个I2C总线段上连接了哪些设备. 因此,USB和PCI并不是 平台设备.

Unlike PCI or USB devices, I2C devices are not enumerated at the hardware level (at run time). Instead, the software must know (at compile time) which devices are connected on each I2C bus segment. So USB and PCI are not platform devices.

  • 平台设备通过匹配名称绑定到驱动程序

    因此,基本上,"是平台设备还是标准设备?"问题是更多关于它使用哪种总线的问题.要使用特定的平台设备,您必须:

    So basically, the question "is it a platform device or a standard device?" is more a question of which bus it uses. To work with a particular platform device, you have to:

    1. 注册将要管理此设备的平台驱动程序.它应该定义一个 unique 名称,
    2. 注册平台设备,定义与驱动程序相同的名称.
    1. register a platform driver that will manage this device. It should define a unique name,
    2. register your platform device, defining the same name as the driver.

    平台驱动程序用于芯片上的那些设备.

    Platform driver is for those devices that are on chip.

    不是正确的(理论上是正确的,但实际上是正确的). i2c设备不是onChip,而是平台设备,因为它们是不可发现的.我们还可以想到属于 normal 设备的onChip设备.示例:现代x86处理器上的集成PCI GPU芯片.它是可发现的,因此不是平台设备.

    Not true (in theory, but true in practice). i2c devices are not onChip, but are platform devices because they are not discoverable. Also we can think of onChip devices which are normal devices. Example: an integrated PCI GPU chip on a modern x86 processor. It is discoverable, thus not a platform device.

    常规设备驱动程序用于与处理器芯片接口的设备.在遇到一个i2c驱动程序之前.

    Normal device driver are for those that are interfaced to the processor chip. before coming across one i2c driver.

    不正确.许多 normal 设备都连接到处理器,但没有通过i2c总线连接.例如:USB鼠标.

    Not true. Many normal devices are interfaced to the processor, but not through an i2c bus. Example: a USB mouse.

    在您的情况下,请查看drivers/usb/host/ohci-pnx4008.c,它是USB主机控制器平台设备(此处无法找到USB主机控制器,而将连接USB设备)对此).它是由 board文件(arch/arm/mach-pnx4008/core.c:pnx4008_init)注册的平台设备.并且在其探测功能内,它使用i2c_register_driver将其i2c设备注册到总线.我们可以推断出USB主机控制器芯片组通过i2c总线与CPU对话.

    In your case, have a look to drivers/usb/host/ohci-pnx4008.c, which is a USB host controller platform device (Here the USB host controller is not discoverable, whereas USB devices, which will connect to it, are). It is a platform device registered by the board file (arch/arm/mach-pnx4008/core.c:pnx4008_init). And within its probe function, it registers its i2c device to the bus with i2c_register_driver. We can infer that the USB Host controller chipset talks to the CPU through an i2c bus.

    为什么要使用这种架构?因为一方面,可以将此设备视为提供系统某些功能的裸机i2c设备.另一方面,它是具有USB主机功能的设备.它需要注册到USB堆栈(usb_create_hcd).因此仅探测i2c是不够的.看看Documentation/i2c/instantiating-devices.

    Why that architecture? Because on one hand, this device can be considered a bare i2c device providing some functionalities to the system. On the other hand, it is a USB Host capable device. It needs to register to the USB stack (usb_create_hcd). So probing only i2c will be insufficient. Have a look to Documentation/i2c/instantiating-devices.

    这篇关于Linux平台驱动程序和普通设备驱动程序有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆